forked from Jae-eun/Toonie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.diff
More file actions
2044 lines (1966 loc) · 77.3 KB
/
Copy pathpatch.diff
File metadata and controls
2044 lines (1966 loc) · 77.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/Toonie/Common/CommonUtility.swift b/Toonie/Common/CommonUtility.swift
index d578364..f27412d 100644
--- a/Toonie/Common/CommonUtility.swift
+++ b/Toonie/Common/CommonUtility.swift
@@ -6,9 +6,9 @@
// Copyright © 2019 Yapp. All rights reserved.
//
-import UIKit
import Firebase
import StoreKit
+import UIKit
///애플리케이션에 필요한 잡다한 도구 모음
final class CommonUtility: NSObject {
@@ -17,7 +17,7 @@ final class CommonUtility: NSObject {
static let devSwitch: Bool = true
//디자인 가이드 기준 Xs
- static let deviceWidth: CGFloat = 375
+ static let deviceWidth: CGFloat = 375
static let deviceHeight: CGFloat = 812
weak var mainNavigationViewController: MainNavigationController?
diff --git a/Toonie/Detail/Controller/ToonWebViewController.swift b/Toonie/Detail/Controller/ToonWebViewController.swift
index a1b8b96..1a5e8ee 100644
--- a/Toonie/Detail/Controller/ToonWebViewController.swift
+++ b/Toonie/Detail/Controller/ToonWebViewController.swift
@@ -69,7 +69,7 @@ final class ToonWebViewController: UIViewController, WKNavigationDelegate {
private func setLabel() {
let javascript = "document.title\n"
- instagramWebView.evaluateJavaScript(javascript) { [weak self] (result, error) -> Void in
+ instagramWebView.evaluateJavaScript(javascript) { [weak self] result, error -> Void in
guard let self = self else { return }
if error == nil {
self.idLabel.text = result as? String
diff --git a/Toonie/Extension/UIButton+.swift b/Toonie/Extension/UIButton+.swift
index 26c9e22..d52e6e4 100644
--- a/Toonie/Extension/UIButton+.swift
+++ b/Toonie/Extension/UIButton+.swift
@@ -10,21 +10,23 @@ import UIKit
extension UIButton {
func centerImageAndButton(_ gap: CGFloat, imageOnTop: Bool) {
-
+
guard let imageView = self.imageView,
let titleLabel = self.titleLabel else { return }
-
+
let sign: CGFloat = imageOnTop ? 1 : -1
let imageSize = imageView.frame.size
- self.titleEdgeInsets = UIEdgeInsets.init(top: (imageSize.height+gap)*sign,
- left: -imageSize.width,
- bottom: 0,
- right: 0)
-
+ self.titleEdgeInsets = UIEdgeInsets(
+ top: (imageSize.height + gap) * sign,
+ left: -imageSize.width,
+ bottom: 0,
+ right: 0)
+
let titleSize = titleLabel.bounds.size
- self.imageEdgeInsets = UIEdgeInsets.init(top: -(titleSize.height+gap)*sign,
- left: 0,
- bottom: 0,
- right: -titleSize.width)
+ self.imageEdgeInsets = UIEdgeInsets(
+ top: -(titleSize.height + gap) * sign,
+ left: 0,
+ bottom: 0,
+ right: -titleSize.width)
}
}
diff --git a/Toonie/Extension/UIFont+.swift b/Toonie/Extension/UIFont+.swift
index f2985b9..323ad28 100644
--- a/Toonie/Extension/UIFont+.swift
+++ b/Toonie/Extension/UIFont+.swift
@@ -10,36 +10,44 @@ import Foundation
import UIKit
extension UIFont {
-
+
///AppleSDGothicNeo가져옴
public enum AppleSDOption {
case thin, ultraLight, semiBold, medium, regular, bold, light
}
-
- public static func getAppleSDGothicNeo(option: AppleSDOption,
- size: CGFloat) -> UIFont {
+
+ public static func getAppleSDGothicNeo(
+ option: AppleSDOption,
+ size: CGFloat) -> UIFont {
switch option {
case .thin:
- return UIFont.init(name: "AppleSDGothicNeo-Thin",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-Thin",
+ size: size) ?? UIFont.systemFont(ofSize: size)
case .ultraLight:
- return UIFont.init(name: "AppleSDGothicNeo-UltraLight",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-UltraLight",
+ size: size) ?? UIFont.systemFont(ofSize: size)
case .semiBold:
- return UIFont.init(name: "AppleSDGothicNeo-SemiBold",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-SemiBold",
+ size: size) ?? UIFont.systemFont(ofSize: size)
case .medium:
- return UIFont.init(name: "AppleSDGothicNeo-Medium",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-Medium",
+ size: size) ?? UIFont.systemFont(ofSize: size)
case .regular:
- return UIFont.init(name: "AppleSDGothicNeo-Regular",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-Regular",
+ size: size) ?? UIFont.systemFont(ofSize: size)
case .bold:
- return UIFont.init(name: "AppleSDGothicNeo-Bold",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-Bold",
+ size: size) ?? UIFont.systemFont(ofSize: size)
case .light:
- return UIFont.init(name: "AppleSDGothicNeo-Light",
- size: size) ?? UIFont.systemFont(ofSize: size)
+ return UIFont(
+ name: "AppleSDGothicNeo-Light",
+ size: size) ?? UIFont.systemFont(ofSize: size)
}
}
}
diff --git a/Toonie/Extension/UIViewController+.swift b/Toonie/Extension/UIViewController+.swift
index 0d9afe8..d70f2b0 100644
--- a/Toonie/Extension/UIViewController+.swift
+++ b/Toonie/Extension/UIViewController+.swift
@@ -28,7 +28,7 @@ extension UIViewController {
self.view.transform = CGAffineTransform(scaleX: 1.3,
y: 1.3)
self.view.alpha = 0.0},
- completion: { (_) in
+ completion: { _ in
self.view.removeFromSuperview()
})
}
diff --git a/Toonie/Feed/Controller/FeedViewController.swift b/Toonie/Feed/Controller/FeedViewController.swift
index ef2f84a..244c4cb 100644
--- a/Toonie/Feed/Controller/FeedViewController.swift
+++ b/Toonie/Feed/Controller/FeedViewController.swift
@@ -6,9 +6,9 @@
// Copyright © 2019 Yapp. All rights reserved.
//
-import UIKit
import Lottie
import SnapKit
+import UIKit
// Feed의 NavigationController
final class FeedNavigationController: UINavigationController {
@@ -168,7 +168,7 @@ final class FeedViewController: GestureViewController {
if let tagAnimationView = tagAnimationView {
tagAnimationView.contentMode = .scaleAspectFit
tagView.addSubview(tagAnimationView)
- tagAnimationView.snp.makeConstraints { (make) -> Void in
+ tagAnimationView.snp.makeConstraints { make -> Void in
make.width.equalTo(tagView.bounds.width)
make.height.equalTo(tagView.bounds.height)
make.center.equalTo(tagView)
diff --git a/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift b/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift
index bec552a..3b98685 100644
--- a/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift
+++ b/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift
@@ -31,7 +31,7 @@ final class RecommendCollectionViewCell: UICollectionViewCell {
super.prepareForReuse()
recentToonImageView.image = nil
toonNameTitle.text = nil
- bookMarkButton.isSelected = false
+ bookMarkButton.isSelected = false
recentToonImageView.setCorner(cornerRadius: 4.0)
}
diff --git a/Toonie/Feed/RecommendView/RecommendViewController.swift b/Toonie/Feed/RecommendView/RecommendViewController.swift
index 99ae1de..545317e 100644
--- a/Toonie/Feed/RecommendView/RecommendViewController.swift
+++ b/Toonie/Feed/RecommendView/RecommendViewController.swift
@@ -10,38 +10,38 @@ import UIKit
// '지금 나는' 태그에 따른 인스타툰 추천 화면
final class RecommendViewController: GestureViewController {
-
+
//tagCollectionView 5줄 고정 위한 상수, 변수
private let tagScrollContentViewWidthInitValue: CGFloat = 672
private let maxTagItemWidth = 168
-
+
///item들을 일렬로 쭉 나열했을때의 max길이(간격포함)
- private let maxTagAllItemWidth = 4256
-
+ private let maxTagAllItemWidth = 4_256
+
private let maxTagCount = 31
private let maxLine = 5
-
+
/// tagAllWidth - 현재 뿌려질 태그 아이템들을 일렬로 늘어왔을때의 총 길이 (간격포함)
private var tagAllWidth: Int = 0
private var tagList = [String]()
private var tagSelectArray = [String]()
-
+
private var isFavorite = false
-
+
// MARK: - IBOutlets
-
+
@IBOutlet private weak var recommendTableView: UITableView!
-
+
@IBOutlet private weak var tagFrameView: UIView!
@IBOutlet private weak var tagScrollView: UIScrollView!
-
+
///이 수치에 따라 태그 줄수를 컨트롤 가능.
@IBOutlet private weak var tagScrollContentViewWidth: NSLayoutConstraint!
-
+
@IBOutlet private weak var tagCollectionView: UICollectionView!
@IBOutlet private weak var tagCollectionViewFlowLayout: UICollectionViewFlowLayout!
@IBOutlet private weak var tagSelectedNotInfoView: UIView!
-
+
// MARK: - Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
@@ -49,23 +49,23 @@ final class RecommendViewController: GestureViewController {
setTableViewXib()
setTagFlowLayout()
setTagScrollContent()
-
+
// test
// getToonOfTagList(tag: "알콩달콩 결혼 생활")
}
-
+
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
reloadTagTableView()
}
-
+
// MARK: - IBActions
@IBAction func backButtionDidTap(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
-
+
// MARK: - Function
-
+
func getCurationTagList() {
RecommendService.shared.getRecommends { [weak self] res in
guard let self = self else { return }
@@ -73,129 +73,149 @@ final class RecommendViewController: GestureViewController {
self.tagCollectionView.reloadData()
}
}
-
+
// func getToonOfTagList(tag: String) {
// CurationTagService.shared.getCurationTagList(tagName: tag) { res in
// // test
// print("res : ", res!)
// }
// }
-//
+//
///cell xib 이용
func setTableViewXib() {
- let nibName = UINib(nibName: "RecommendTableViewCell",
- bundle: nil)
- recommendTableView.register(nibName,
- forCellReuseIdentifier: "RecommendTableViewCell")
+ let nibName = UINib(
+ nibName: "RecommendTableViewCell",
+ bundle: nil)
+ recommendTableView.register(
+ nibName,
+ forCellReuseIdentifier: "RecommendTableViewCell")
}
-
+
///tagFlowLayout 프로퍼티 설정
func setTagFlowLayout() {
tagCollectionViewFlowLayout.minimumInteritemSpacing = 10
tagCollectionViewFlowLayout.minimumLineSpacing = 9 //라인 사이의 최소간격
- tagCollectionViewFlowLayout.sectionInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
- tagCollectionViewFlowLayout.estimatedItemSize = CGSize.init(width: 20, height: 30)
+ tagCollectionViewFlowLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
+ tagCollectionViewFlowLayout.estimatedItemSize = CGSize(width: 20, height: 30)
}
-
+
///스크롤링 될 영역, 초기 보여질 영역 세팅
func setTagScrollContent() {
DispatchQueue.main.async {
let leftMagin = (self.tagScrollContentViewWidth.constant - self.view.bounds.width) / 2
- self.tagScrollView.contentInset = UIEdgeInsets.init(top: 0,
- left: leftMagin + 20,
- bottom: 0,
- right: 20)
+ self.tagScrollView.contentInset = UIEdgeInsets(
+ top: 0,
+ left: leftMagin + 20,
+ bottom: 0,
+ right: 20)
}
}
-
+
///태그 선택할때
func reloadTagTableView() {
// print("tagSelectArray \(tagSelectArray)")
recommendTableView.reloadData()
}
-
+
}
// MARK: - TableView : 전체를 이루는 뷰
extension RecommendViewController: UITableViewDataSource {
- func tableView(_ tableView: UITableView,
- numberOfRowsInSection section: Int) -> Int {
- if tagSelectArray.count == 0 {
- tagFrameView.bounds = CGRect.init(x: 0,
- y: 0,
- width: self.view.bounds.width,
- height: tableView.bounds.height)
+ func tableView(
+ _ tableView: UITableView,
+ numberOfRowsInSection section: Int
+ ) -> Int {
+ if tagSelectArray.isEmpty {
+ tagFrameView.bounds = CGRect(
+ x: 0,
+ y: 0,
+ width: self.view.bounds.width,
+ height: tableView.bounds.height)
tagSelectedNotInfoView.isHidden = false
} else {
- tagFrameView.bounds = CGRect.init(x: 0,
- y: 0,
- width: self.view.bounds.width,
- height: 326)
+ tagFrameView.bounds = CGRect(
+ x: 0,
+ y: 0,
+ width: self.view.bounds.width,
+ height: 326
+ )
tagSelectedNotInfoView.isHidden = true
}
return tagSelectArray.count
}
-
- func tableView(_ tableView: UITableView,
- cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+
+ func tableView(
+ _ tableView: UITableView,
+ cellForRowAt indexPath: IndexPath
+ ) -> UITableViewCell {
guard let cell = tableView
- .dequeueReusableCell(withIdentifier: "RecommendTableViewCell",
- for: indexPath) as? RecommendTableViewCell
+ .dequeueReusableCell(
+ withIdentifier: "RecommendTableViewCell",
+ for: indexPath) as? RecommendTableViewCell
else {
return UITableViewCell()
}
-
+
//역순 노출
let reverseIndex = tagSelectArray.count - (indexPath.row + 1)
cell.setRecommentTitleLabel(titleString: tagSelectArray[reverseIndex])
-
+
return cell
}
}
// MARK: - CollectionView : TagView - UICollectionViewDataSource
extension RecommendViewController: UICollectionViewDataSource {
- func collectionView(_ collectionView: UICollectionView,
- numberOfItemsInSection section: Int) -> Int {
+ func collectionView(
+ _ collectionView: UICollectionView,
+ numberOfItemsInSection section: Int
+ ) -> Int {
if maxTagCount < tagList.count {
return maxTagCount
}
return tagList.count
}
-
- func collectionView(_ collectionView: UICollectionView,
- cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+
+ func collectionView(
+ _ collectionView: UICollectionView,
+ cellForItemAt indexPath: IndexPath
+ ) -> UICollectionViewCell {
guard let cell = collectionView
- .dequeueReusableCell(withReuseIdentifier: "TagCollectionViewCell",
- for: indexPath) as? TagCollectionViewCell
+ .dequeueReusableCell(
+ withReuseIdentifier: "TagCollectionViewCell",
+ for: indexPath) as? TagCollectionViewCell
else { return UICollectionViewCell() }
let titleName = tagList[indexPath.row]
cell.setTitleLabel(titleString: titleName)
cell.setCellStatus(bool: false)
-
+
return cell
}
-
- func collectionView(_ collectionView: UICollectionView,
- layout collectionViewLayout: UICollectionViewLayout,
- sizeForItemAt indexPath: IndexPath) -> CGSize {
-
+
+ func collectionView(
+ _ collectionView: UICollectionView,
+ layout collectionViewLayout: UICollectionViewLayout,
+ sizeForItemAt indexPath: IndexPath
+ ) -> CGSize {
+
let keyword = tagList[indexPath.row]
- let font = UIFont.getAppleSDGothicNeo(option: .regular,
- size: 14)
- var width = Int(keyword.widthWithConstrainedHeight(height: 17,
- font: font))
+ let font = UIFont.getAppleSDGothicNeo(
+ option: .regular,
+ size: 14)
+ var width = Int(keyword.widthWithConstrainedHeight(
+ height: 17,
+ font: font))
width += 22
-
+
//최대길이제약 - 157
if maxTagItemWidth < width {
width = maxTagItemWidth
}
-
+
tagAllWidth += width
-
+
//마지막 아니면 간격인 10씩 더해줌
- if tagList.count-1 != indexPath.row {
+ if tagList.count - 1 != indexPath.row {
tagAllWidth += 10
} else {
// 개수, 길이에 상관없이 5줄, 가운데 정렬을 위한 수치 계산.
@@ -208,31 +228,32 @@ extension RecommendViewController: UICollectionViewDataSource {
}
}
}
-
+
return CGSize(width: width, height: 30)
}
-
+
}
// MARK: - CollectionView : TagView - UICollectionViewDelegate
extension RecommendViewController: UICollectionViewDelegate {
- func collectionView(_ collectionView: UICollectionView,
- didSelectItemAt indexPath: IndexPath) {
+ func collectionView(
+ _ collectionView: UICollectionView,
+ didSelectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? TagCollectionViewCell {
cell.setCellStatus(bool: !cell.getCellStatus())
-
+
//선택한 키워드 추가 및 삭제
if cell.getCellStatus() == true {
tagSelectArray.append(tagList[indexPath.row])
-
+
} else {
let findIndex = tagSelectArray.firstIndex(of: cell.getTitleLabel().text ?? "")
-
+
if let index = findIndex {
tagSelectArray.remove(at: index)
}
}
-
+
//카운트레이블, 버튼 리로드
reloadTagTableView()
}
@@ -241,21 +262,24 @@ extension RecommendViewController: UICollectionViewDelegate {
// MARK: - CollectionView : TagView - UICollectionViewDelegateFlowLayout
extension RecommendViewController: UICollectionViewDelegateFlowLayout {
- private func collectionView(collectionView: UICollectionView,
- layout collectionViewLayout: UICollectionViewLayout,
- sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
+ private func collectionView(
+ collectionView: UICollectionView,
+ layout collectionViewLayout: UICollectionViewLayout,
+ sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
let keyword = tagList[indexPath.row]
- let font = UIFont.getAppleSDGothicNeo(option: .regular,
- size: 14)
- var width = Int(keyword.widthWithConstrainedHeight(height: 17,
- font: font))
+ let font = UIFont.getAppleSDGothicNeo(
+ option: .regular,
+ size: 14)
+ var width = Int(keyword.widthWithConstrainedHeight(
+ height: 17,
+ font: font))
width += 22
-
+
//최대길이제약 - 157
if maxTagItemWidth < width {
width = maxTagItemWidth
}
-
+
return CGSize(width: width, height: 30)
}
}
diff --git a/Toonie/Feed/RecommendView/TagCollectionViewCell.swift b/Toonie/Feed/RecommendView/TagCollectionViewCell.swift
index 839d81a..d480a59 100644
--- a/Toonie/Feed/RecommendView/TagCollectionViewCell.swift
+++ b/Toonie/Feed/RecommendView/TagCollectionViewCell.swift
@@ -22,16 +22,15 @@ final class TagCollectionViewCell: UICollectionViewCell {
/// didTap 일어날 때마다 cellBackgroundView 레이아웃 바꿔주는 함수
func setBorderViewLayout(status: Bool) {
if status == false { // 선택 안함
- backView.setBorder(color: UIColor.init(white: 0.447, alpha: 0.4).cgColor,
+ backView.setBorder(color: UIColor(white: 0.447, alpha: 0.4).cgColor,
borderWidth: 1)
- titleLabel.textColor = UIColor.init(white: 0, alpha: 0.4)
+ titleLabel.textColor = UIColor(white: 0, alpha: 0.4)
} else { // 선택함
- let borderColor = UIColor.init(named: "tag")?.cgColor
+ let borderColor = UIColor(named: "tag")?.cgColor
- backView.setBorder(color: borderColor ?? UIColor.init(white: 0, alpha: 0.4).cgColor,
- borderWidth: 1)
- titleLabel.textColor = UIColor.init(white: 0, alpha: 1)
+ backView.setBorder(color: borderColor ?? UIColor(white: 0, alpha: 0.4).cgColor, borderWidth: 1)
+ titleLabel.textColor = UIColor(white: 0, alpha: 1)
}
backView.setCorner(cornerRadius: 5)
diff --git a/Toonie/Feed/View/FavoriteCollectionViewCell.swift b/Toonie/Feed/View/FavoriteCollectionViewCell.swift
index 12a3843..1f9199c 100644
--- a/Toonie/Feed/View/FavoriteCollectionViewCell.swift
+++ b/Toonie/Feed/View/FavoriteCollectionViewCell.swift
@@ -25,7 +25,7 @@ final class FavoriteCollectionViewCell: UICollectionViewCell {
favoriteToonTitleLabel.text = nil
favoriteToonTagLabel.text = nil
toonIdLabel.text = nil
- bookMarkButton.isSelected = false
+ bookMarkButton.isSelected = false
}
// MARK: - IBAction
diff --git a/Toonie/Feed/View/ForYouCollectionViewCell.swift b/Toonie/Feed/View/ForYouCollectionViewCell.swift
index 56e5c22..3e3485d 100644
--- a/Toonie/Feed/View/ForYouCollectionViewCell.swift
+++ b/Toonie/Feed/View/ForYouCollectionViewCell.swift
@@ -48,7 +48,7 @@ final class ForYouCollectionViewCell: UICollectionViewCell {
forYouToonTitleLabel.text = nil
forYouToonTagLabel.text = nil
toonIdLabel.text = nil
- bookMarkButton.isSelected = false
+ bookMarkButton.isSelected = false
}
// MARK: - Functions
diff --git a/Toonie/Feed/View/RecentCollectionViewCell.swift b/Toonie/Feed/View/RecentCollectionViewCell.swift
index bd29a55..ee45f81 100644
--- a/Toonie/Feed/View/RecentCollectionViewCell.swift
+++ b/Toonie/Feed/View/RecentCollectionViewCell.swift
@@ -46,7 +46,7 @@ final class RecentCollectionViewCell: UICollectionViewCell {
recentToonImageView.image = nil
recentToonTitleLabel.text = nil
toonIdLabel.text = nil
- bookMarkButton.isSelected = false
+ bookMarkButton.isSelected = false
}
// MARK: - Functions
diff --git a/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift b/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift
index 982ec48..db70d76 100644
--- a/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift
+++ b/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift
@@ -14,41 +14,39 @@ struct TagStructure {
}
final class LookDetailTopSelectViewController: UIViewController {
-
+
// MARK: - IBOutlets
-
+
@IBOutlet weak var lookDetailTopSelectCollectionView: UICollectionView!
-
+
// MARK: - Properties
-
+
//collectionView didSelected 했을시 호출할 클로저
var tagDidTapClosure: ((String) -> Void)?
var selectedKeyword: String = ""
-
+
//state로 on off 진행
var tags = [TagStructure]()
private var toonAllList = [ToonList]()
-
+
// MARK: - Life Cycle
-
+
override func viewDidLoad() {
super.viewDidLoad()
//맨처음 전체보기 기본세팅
setTags()
}
-
+
func setTags() {
- let tagStructure: TagStructure = TagStructure.init(tagName: "전체보기",
- state: true)
+ let tagStructure: TagStructure = TagStructure(tagName: "전체보기", state: true)
tags.append(tagStructure)
-
+
KeywordToonListService
.shared
- .getKeywords(keyword: selectedKeyword) { [weak self] (tags) in
+ .getKeywords(keyword: selectedKeyword) { [weak self] tags in
guard let self = self else { return }
for tag in tags ?? [String]() {
- self.tags.append(TagStructure.init(tagName: "#"+tag,
- state: false))
+ self.tags.append(TagStructure(tagName: "#" + tag, state: false))
}
self.lookDetailTopSelectCollectionView.reloadData()
}
@@ -58,83 +56,93 @@ final class LookDetailTopSelectViewController: UIViewController {
// MARK: - UICollectionViewDataSource
extension LookDetailTopSelectViewController: UICollectionViewDataSource {
-
+
func collectionView(_ collectionView: UICollectionView,
- numberOfItemsInSection section: Int) -> Int {
+ numberOfItemsInSection section: Int) -> Int {
return tags.count
}
-
- func collectionView(_ collectionView: UICollectionView,
- cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-
+
+ func collectionView(
+ _ collectionView: UICollectionView,
+ cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+
guard let cell = collectionView
- .dequeueReusableCell(withReuseIdentifier: "LookDetailTopSelectCell",
- for: indexPath) as? LookDetailTopSelectCell
+ .dequeueReusableCell(
+ withReuseIdentifier: "LookDetailTopSelectCell",
+ for: indexPath) as? LookDetailTopSelectCell
else { return UICollectionViewCell() }
-
+
cell.setTitleLabel(text: tags[indexPath.row].tagName)
cell.setCellStatus(bool: tags[indexPath.row].state)
-
+
return cell
}
-
- func collectionView(_ collectionView: UICollectionView,
- didSelectItemAt indexPath: IndexPath) {
-
+
+ func collectionView(
+ _ collectionView: UICollectionView,
+ didSelectItemAt indexPath: IndexPath) {
+
if let closure = self.tagDidTapClosure {
closure(tags[indexPath.row]
- .tagName
- .replacingOccurrences(of: "#",
- with: ""))
+ .tagName
+ .replacingOccurrences(
+ of: "#",
+ with: ""))
}
-
+
//우선 cell 상태 모두 초기화
for index in 0..<tags.count {
tags[index].state = false
}
-
+
//선택한 cell만 상태 변경
tags[indexPath.row].state = true
-
+
self.lookDetailTopSelectCollectionView.reloadData()
}
-
- func collectionView(_ collectionView: UICollectionView,
- layout collectionViewLayout: UICollectionViewLayout,
- sizeForItemAt indexPath: IndexPath) -> CGSize {
-
+
+ func collectionView(
+ _ collectionView: UICollectionView,
+ layout collectionViewLayout: UICollectionViewLayout,
+ sizeForItemAt indexPath: IndexPath) -> CGSize {
+
let keyword = tags[indexPath.row].tagName
- let font = UIFont.getAppleSDGothicNeo(option: .medium,
- size: 14)
- var width = Int(keyword.widthWithConstrainedHeight(height: 17,
- font: font))
+ let font = UIFont.getAppleSDGothicNeo(
+ option: .medium,
+ size: 14)
+ var width = Int(keyword.widthWithConstrainedHeight(
+ height: 17,
+ font: font))
width += 41
-
+
return CGSize(width: width, height: 30)
}
-
+
}
// MARK: - UICollectionViewDelegate
extension LookDetailTopSelectViewController: UICollectionViewDelegate {
-
+
}
// MARK: - CollectionView : TagView - UICollectionViewDelegateFlowLayout
extension LookDetailTopSelectViewController: UICollectionViewDelegateFlowLayout {
- private func collectionView(collectionView: UICollectionView,
- layout collectionViewLayout: UICollectionViewLayout,
- sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
-
+ private func collectionView(
+ collectionView: UICollectionView,
+ layout collectionViewLayout: UICollectionViewLayout,
+ sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
+
let keyword = tags[indexPath.row].tagName
- let font = UIFont.getAppleSDGothicNeo(option: .medium,
- size: 14)
- var width = Int(keyword.widthWithConstrainedHeight(height: 17,
- font: font))
+ let font = UIFont.getAppleSDGothicNeo(
+ option: .medium,
+ size: 14)
+ var width = Int(keyword.widthWithConstrainedHeight(
+ height: 17,
+ font: font))
width += 41
-
+
return CGSize(width: width, height: 30)
}
}
diff --git a/Toonie/Look/LookDetailViewController/LookDetailViewController.swift b/Toonie/Look/LookDetailViewController/LookDetailViewController.swift
index 65811fb..254519e 100644
--- a/Toonie/Look/LookDetailViewController/LookDetailViewController.swift
+++ b/Toonie/Look/LookDetailViewController/LookDetailViewController.swift
@@ -10,13 +10,13 @@ import UIKit
///둘러보기 상세 - LookViewController의 CollectionView의 didSelected시 이동되는 화면
final class LookDetailViewController: GestureViewController {
-
+
// MARK: - IBOutlets
-
+
@IBOutlet private weak var lookDetailTitleLabel: UILabel!
@IBOutlet private weak var lookDetailCollectionView: UICollectionView!
@IBOutlet private weak var lookDetailCollectionViewFlowLayout: UICollectionViewFlowLayout!
-
+
// MARK: - Properties
var selectedKeyword: String = ""
private var tag = "전체보기"
@@ -26,28 +26,29 @@ final class LookDetailViewController: GestureViewController {
private var selectedToonID: String?
private var favoriteToon: [ToonList]?
private var isFavorite = false
-
+
// MARK: - Life Cycle
-
+
override func viewDidLoad() {
super.viewDidLoad()
lookDetailTitleLabel.text = selectedKeyword
setCollectionViewData(keyword: selectedKeyword)
setCollectionViewLayout()
registerForPreviewing(with: self, sourceView: lookDetailCollectionView)
-
+
}
-
+
override func viewWillAppear(_ animated: Bool) {
+ super.viewWillAppear(animated)
loadFavoriteToon()
}
-
+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "topSetting" {
if let viewController = segue.destination as? LookDetailTopSelectViewController {
viewController.selectedKeyword = self.selectedKeyword
viewController.tagDidTapClosure = { [weak self]
- (tagString) -> Void in
+ tagString -> Void in
guard let self = self else { return }
self.tag = tagString
print("self.selectedKeyword : \(self.selectedKeyword)")
@@ -56,56 +57,60 @@ final class LookDetailViewController: GestureViewController {
}
}
}
-
+
// MARK: - IBAction
-
+
@IBAction func backButtonDidTap(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
-
+
// MARK: - Function
-
+
/// 컬렉션뷰 데이터 설정
private func setCollectionViewData(keyword: String) {
if tag == "전체보기" {
KeywordToonAllListService
.shared
- .getKeywordToonAllList(keyword: self.selectedKeyword,
- completion: { [weak self] (res) in
- guard let self = self else { return }
- guard let toonData = res else { return }
- self.toonAllList = toonData
- self.lookDetailCollectionView.reloadData()
- })
-
+ .getKeywordToonAllList(
+ keyword: self.selectedKeyword,
+ completion: { [weak self] res in
+ guard let self = self else { return }
+ guard let toonData = res else { return }
+ self.toonAllList = toonData
+ self.lookDetailCollectionView.reloadData()
+ })
+
} else {
LookToonOfTagService.shared
- .getLookToonOfTag(toonTag: tag,
- completion: { [weak self] res in
- guard let self = self else { return }
- self.toonList = [res]
- guard let toonData = res.toonInfoList else { return }
- self.toonDataList = toonData
- self.lookDetailCollectionView.reloadData()
- })
+ .getLookToonOfTag(
+ toonTag: tag,
+ completion: { [weak self] res in
+ guard let self = self else { return }
+ self.toonList = [res]
+ guard let toonData = res.toonInfoList else { return }
+ self.toonDataList = toonData
+ self.lookDetailCollectionView.reloadData()
+ })
}
}
-
+
/// 컬렉션 뷰 아이템 크기, 위치조정
private func setCollectionViewLayout() {
lookDetailCollectionViewFlowLayout.scrollDirection = .vertical
lookDetailCollectionViewFlowLayout.itemSize =
- CGSize(width: UIScreen.main.bounds.width * 0.322,
- height: UIScreen.main.bounds.width * 0.322)
+ CGSize(
+ width: UIScreen.main.bounds.width * 0.322,
+ height: UIScreen.main.bounds.width * 0.322)
lookDetailCollectionViewFlowLayout.sectionInset =
- UIEdgeInsets(top: 0,
- left: 5 * CommonUtility.getDeviceRatioWidth(),
- bottom: 0,
- right: 5 * CommonUtility.getDeviceRatioWidth())
+ UIEdgeInsets(
+ top: 0,
+ left: 5 * CommonUtility.getDeviceRatioWidth(),
+ bottom: 0,
+ right: 5 * CommonUtility.getDeviceRatioWidth())
lookDetailCollectionViewFlowLayout.minimumLineSpacing =
1.0 * CommonUtility.getDeviceRatioWidth()
- }
-
+ }
+
/// 인스타툰 상세정보 화면으로 이동
private func pushDetailToonViewController(toonID: String) {
let storyboard = UIStoryboard(name: "Detail", bundle: nil)
@@ -115,36 +120,37 @@ final class LookDetailViewController: GestureViewController {
viewController.detailToonID = toonID
CommonUtility.sharedInstance
.mainNavigationViewController?
- .pushViewController(viewController,
- animated: true)
+ .pushViewController(
+ viewController,
+ animated: true)
}
-
+
}
-
+
///타이틀 세팅
func setLookDetailTitleLabel(titleString: String) {
self.lookDetailTitleLabel.text = titleString
}
-
+
/// 찜한 툰 정보 네트워크 요청
func loadFavoriteToon() {
FavoriteService.shared.getFavoriteToon { [weak self] result in
guard let self = self else { return }
-
+
if let result = result {
self.favoriteToon = result
}
}
}
-
+
/// 찜한 상태인지 확인
private func checkFavoriteStatus(toonId: String) -> Bool {
isFavorite = false
guard let favoriteToon = favoriteToon else { return false }