diff --git a/.swiftlint.yml b/.swiftlint.yml index 3fb9e6a..eeaa1ab 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -13,5 +13,5 @@ error: 120 excluded: - Toonie/Supporting Files/AppDelegate.swift -- Pods +- Toonie/Pods - Toonie/Common/CommonFunction.swift diff --git a/Podfile b/Podfile index d1f6cc7..3714dd7 100644 --- a/Podfile +++ b/Podfile @@ -1,5 +1,5 @@ # Uncomment the next line to define a global platform for your project -# platform :ios, '10.1' +# platform :ios, '11.0' target 'Toonie' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks @@ -11,12 +11,11 @@ target 'Toonie' do pod 'lottie-ios', '~> 3.1.0' pod 'SwiftLint' pod 'SnapKit', '~> 4.2' - pod 'Alamofire' + pod 'Alamofire', '~> 4.2' pod 'Firebase/Core' pod 'Firebase/Messaging' pod 'Fabric' pod 'Crashlytics' - pod 'Charts', '~> 3.2.0' target 'ToonieTests' do inherit! :search_paths diff --git a/Podfile.lock b/Podfile.lock index f3ab88b..ffc7964 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,8 +1,5 @@ PODS: - Alamofire (4.8.2) - - Charts (3.2.2): - - Charts/Core (= 3.2.2) - - Charts/Core (3.2.2) - Crashlytics (3.13.1): - Fabric (~> 1.10.1) - Fabric (1.10.1) @@ -77,8 +74,7 @@ PODS: - SwiftLint (0.32.0) DEPENDENCIES: - - Alamofire - - Charts (~> 3.2.0) + - Alamofire (~> 4.2) - Crashlytics - Fabric - Firebase/Core @@ -90,9 +86,8 @@ DEPENDENCIES: - SwiftLint SPEC REPOS: - https://github.com/cocoapods/specs.git: + https://github.com/CocoaPods/Specs.git: - Alamofire - - Charts - Crashlytics - Fabric - Firebase @@ -113,7 +108,6 @@ SPEC REPOS: SPEC CHECKSUMS: Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3 - Charts: f69cf0518b6d1d62608ca504248f1bbe0b6ae77e Crashlytics: 5aa8e90dcbf2f34898b4f5a0037787531246cca0 Fabric: f6f21452846788bb44595d73e9909d79d328e617 Firebase: 8d77bb33624ae9b62d745d82ec023de5f70f7e4f @@ -132,6 +126,6 @@ SPEC CHECKSUMS: SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a SwiftLint: 009a898ef2a1c851f45e1b59349bf6ff2ddc990d -PODFILE CHECKSUM: c388aaf1062b83710ab8d3b2aecea92ff8d3dd97 +PODFILE CHECKSUM: 1c4262268c6002aed5cd12af7b7793c9df5a6206 -COCOAPODS: 1.7.0 +COCOAPODS: 1.8.4 diff --git a/Toonie.xcodeproj/project.pbxproj b/Toonie.xcodeproj/project.pbxproj index ea486e4..5511bbd 100644 --- a/Toonie.xcodeproj/project.pbxproj +++ b/Toonie.xcodeproj/project.pbxproj @@ -91,7 +91,6 @@ B631B8F7968327C48928F96FC6378209 /* SwipeOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6DFA61908EBFE82D1698D239891682 /* SwipeOptions.swift */; }; D23CBF74B49019C4D424B8BBD0EECA96 /* SwipeResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5414960D1B6665D0EC9E38C91978EFB /* SwipeResult.swift */; }; 00B844A8E54481E4FA25E50FD8DCAAD1 /* SwipeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94BC01D7FE19730BC7ED7E301350E372 /* SwipeView.swift */; }; - 5F1E70F63A95A1FF272CCB653A4C2601 /* SwipeViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36354638E53497878C5439AC5660B77A /* SwipeViewDelegate.swift */; }; 9E6CBE75E90DB0F0A7FCD8CD72CF4A77 /* SwipeViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB7E8074D6C978182E7669BB6001E8A /* SwipeViewState.swift */; }; 4AE025D2C380F51BB508CE678B09CB78 /* TagCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3671FD5527EB6A77347C274B14DB174B /* TagCollectionViewCell.swift */; }; 5B5A91FF17C85623166C3C785AA24108 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05FF2AD238FECB950A261C5B8CA41D6 /* TodayViewController.swift */; }; @@ -255,7 +254,6 @@ 4E6DFA61908EBFE82D1698D239891682 /* SwipeOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeOptions.swift; sourceTree = ""; }; B5414960D1B6665D0EC9E38C91978EFB /* SwipeResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeResult.swift; sourceTree = ""; }; 94BC01D7FE19730BC7ED7E301350E372 /* SwipeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeView.swift; sourceTree = ""; }; - 36354638E53497878C5439AC5660B77A /* SwipeViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeViewDelegate.swift; sourceTree = ""; }; 5AB7E8074D6C978182E7669BB6001E8A /* SwipeViewState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeViewState.swift; sourceTree = ""; }; 3671FD5527EB6A77347C274B14DB174B /* TagCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagCollectionViewCell.swift; sourceTree = ""; }; D05FF2AD238FECB950A261C5B8CA41D6 /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = ""; }; @@ -443,6 +441,19 @@ path = Toonie; sourceTree = ""; }; + 51483B2FA5A46C3D0289677EDBBA0457 /* Pods */ = { + isa = PBXGroup; + children = ( + 46461D78EB2754C9A17D4352D5F97AC7 /* Pods-Toonie.debug.xcconfig */, + 300FB960FFEE2976C603D16E5DC4B10B /* Pods-Toonie.release.xcconfig */, + F9FED2BB74D689EF6B88421CC1B8579D /* Pods-ToonieTests.debug.xcconfig */, + 630481886041EA402305CF71D731B02B /* Pods-ToonieTests.release.xcconfig */, + 8AFEFE4CBE574CB4EC9D40CB2C33B674 /* Pods-ToonieWidget.debug.xcconfig */, + 647D3371521DDB35BF9F6896BA9AB234 /* Pods-ToonieWidget.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; 57EE88FD2A2AE25905F1BBA9889DD2BC /* Community */ = { isa = PBXGroup; children = ( @@ -502,19 +513,6 @@ path = Controllers; sourceTree = ""; }; - 51483B2FA5A46C3D0289677EDBBA0457 /* Pods */ = { - isa = PBXGroup; - children = ( - 46461D78EB2754C9A17D4352D5F97AC7 /* Pods-Toonie.debug.xcconfig */, - 300FB960FFEE2976C603D16E5DC4B10B /* Pods-Toonie.release.xcconfig */, - F9FED2BB74D689EF6B88421CC1B8579D /* Pods-ToonieTests.debug.xcconfig */, - 630481886041EA402305CF71D731B02B /* Pods-ToonieTests.release.xcconfig */, - 8AFEFE4CBE574CB4EC9D40CB2C33B674 /* Pods-ToonieWidget.debug.xcconfig */, - 647D3371521DDB35BF9F6896BA9AB234 /* Pods-ToonieWidget.release.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; 7836618FE7A43F2F101ED61B0304A6AB /* Extension */ = { isa = PBXGroup; children = ( @@ -725,7 +723,6 @@ 4E6DFA61908EBFE82D1698D239891682 /* SwipeOptions.swift */, B5414960D1B6665D0EC9E38C91978EFB /* SwipeResult.swift */, 94BC01D7FE19730BC7ED7E301350E372 /* SwipeView.swift */, - 36354638E53497878C5439AC5660B77A /* SwipeViewDelegate.swift */, 5AB7E8074D6C978182E7669BB6001E8A /* SwipeViewState.swift */, ); path = SwipeCard; @@ -921,7 +918,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 4039ED9FF2DB05B090E76221D04E96A3 /* [CP] Check Pods Manifest.lock */ = { + 0A03A8E701D8806A7558B618CCC2B0D5 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -936,14 +933,14 @@ outputFileListPaths = ( ); outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ToonieTests-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-Toonie-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 0A03A8E701D8806A7558B618CCC2B0D5 /* [CP] Check Pods Manifest.lock */ = { + 2FC97DFA743912EDF459972618878A0E /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -958,14 +955,14 @@ outputFileListPaths = ( ); outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Toonie-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-ToonieWidget-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 2FC97DFA743912EDF459972618878A0E /* [CP] Check Pods Manifest.lock */ = { + 4039ED9FF2DB05B090E76221D04E96A3 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -980,7 +977,7 @@ outputFileListPaths = ( ); outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ToonieWidget-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-ToonieTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -1010,32 +1007,11 @@ files = ( ); inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Toonie/Pods-Toonie-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", - "${BUILT_PRODUCTS_DIR}/Charts/Charts.framework", - "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework", - "${BUILT_PRODUCTS_DIR}/KTCenterFlowLayout/KTCenterFlowLayout.framework", - "${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework", - "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", - "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework", - "${BUILT_PRODUCTS_DIR}/lottie-ios/Lottie.framework", - "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", + "${PODS_ROOT}/Target Support Files/Pods-Toonie/Pods-Toonie-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Charts.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KTCenterFlowLayout.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Kingfisher.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lottie.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", + "${PODS_ROOT}/Target Support Files/Pods-Toonie/Pods-Toonie-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -1111,7 +1087,6 @@ B631B8F7968327C48928F96FC6378209 /* SwipeOptions.swift in Sources */, D23CBF74B49019C4D424B8BBD0EECA96 /* SwipeResult.swift in Sources */, 00B844A8E54481E4FA25E50FD8DCAAD1 /* SwipeView.swift in Sources */, - 5F1E70F63A95A1FF272CCB653A4C2601 /* SwipeViewDelegate.swift in Sources */, 9E6CBE75E90DB0F0A7FCD8CD72CF4A77 /* SwipeViewState.swift in Sources */, 4AE025D2C380F51BB508CE678B09CB78 /* TagCollectionViewCell.swift in Sources */, F57EDB00538821C89A0497742A6F2B14 /* TodayViewController.swift in Sources */, diff --git a/Toonie.xcodeproj/xcuserdata/ijaeeun.xcuserdatad/xcschemes/xcschememanagement.plist b/Toonie.xcodeproj/xcuserdata/ijaeeun.xcuserdatad/xcschemes/xcschememanagement.plist index e8b769f..5376d68 100644 --- a/Toonie.xcodeproj/xcuserdata/ijaeeun.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Toonie.xcodeproj/xcuserdata/ijaeeun.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ ToonieWidget.xcscheme_^#shared#^_ orderHint - 23 + 22 diff --git a/Toonie/Common/CommonUtility.swift b/Toonie/Common/CommonUtility.swift index b4eeab6..62d3ea4 100644 --- a/Toonie/Common/CommonUtility.swift +++ b/Toonie/Common/CommonUtility.swift @@ -27,7 +27,7 @@ final class CommonUtility: NSObject { var myTagDic = [String: String]() //싱글톤 - static let sharedInstance = CommonUtility() + static let shared = CommonUtility() ///userToken 가져옴 static func getUserToken() -> String? { @@ -46,10 +46,10 @@ final class CommonUtility: NSObject { } static func analytics(eventName: String, param: [String: Any]?) { -// var replaceEventName = eventName.replacingOccurrences(of: "Toonie.", with: "") -// replaceEventName = devSwitch ? "dev"+replaceEventName : replaceEventName -// Analytics.logEvent(replaceEventName, -// parameters: param) + // var replaceEventName = eventName.replacingOccurrences(of: "Toonie.", with: "") + // replaceEventName = devSwitch ? "dev"+replaceEventName : replaceEventName + // Analytics.logEvent(replaceEventName, + // parameters: param) } func compareToVersion(newVersion: String) -> Int { @@ -94,40 +94,38 @@ final class CommonUtility: NSObject { } return 0 } - + ///앱 3번 실행마다 앱리뷰 요청 func showStoreReview() { let detailEnterCnt = UserDefaults.standard.integer(forKey: "appStartCount") - if 3 <= detailEnterCnt { - SKStoreReviewController.requestReview() - UserDefaults.standard.set(0, forKey: "appStartCount") - } + if detailEnterCnt <= 3 { + SKStoreReviewController.requestReview() + UserDefaults.standard.set(0, forKey: "appStartCount") + } } ///오늘나는 인스타툰을 읽고 싶어요: 하루에 한번인데 오늘 하루 지났는지 체크함 - func isDateCompare(lastCloseTime: Date?, - hideDay: Int) -> Bool{ + func checkPassOneDay(by lastCloseTime: Date?, + hideDay: Int) -> Bool { //true: 안지남 -> 팝업뜨면안됨, false: 지남 -> 팝업떠야함 - guard lastCloseTime != nil else { + guard let lastCloseTime = lastCloseTime else { return false } - - if let lastCloseTime = lastCloseTime { - do { - let formatter = DateComponentsFormatter() - formatter.allowedUnits = [.hour] - formatter.unitsStyle = .full - if let hourString = formatter.string(from: lastCloseTime.addingTimeInterval(TimeInterval(86400 * hideDay)) - , to: Date.init()) { - print("\(hourString)만큼 차이납니다.") - - let hour = hourString.replacingOccurrences(of: " hours", with: "") - - if 0 <= Int(hour) ?? 0 { - return false - } + + do { + let formatter = DateComponentsFormatter() + formatter.allowedUnits = [.hour] + formatter.unitsStyle = .full + if let hourString = formatter.string(from: lastCloseTime.addingTimeInterval(TimeInterval(86400 * hideDay)) + , to: Date.init()) { + print("\(hourString)만큼 차이납니다.") + + let hour = Int(hourString.replacingOccurrences(of: " hours", with: "")) ?? 0 + + if hour <= 0 { + return false } } } diff --git a/Toonie/Community/CommunityTableViewCell.swift b/Toonie/Community/CommunityTableViewCell.swift index 0903351..d8aceb0 100644 --- a/Toonie/Community/CommunityTableViewCell.swift +++ b/Toonie/Community/CommunityTableViewCell.swift @@ -10,6 +10,8 @@ import UIKit final class CommunityTableViewCell: UITableViewCell { + // MARK: - IBOutlet + @IBOutlet private weak var nameLabel: UILabel! @IBOutlet private weak var modifyButton: UIButton! @IBOutlet private weak var dayAndTimeButton: UILabel! @@ -17,13 +19,11 @@ final class CommunityTableViewCell: UITableViewCell { @IBOutlet weak var recommendView: UIView! @IBOutlet weak var recommendCollectionView: UICollectionView! @IBOutlet weak var recommendButton: UIButton! - @IBOutlet weak var recommendViewHeightConstraint: NSLayoutConstraint! - override func awakeFromNib() { super.awakeFromNib() - // Initialization code + recommendCollectionView.dataSource = self recommendCollectionView.delegate = self } @@ -31,7 +31,6 @@ final class CommunityTableViewCell: UITableViewCell { override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) - // Configure the view for the selected state } override func layoutSubviews() { @@ -44,7 +43,10 @@ final class CommunityTableViewCell: UITableViewCell { } +// MARK: - UICollectionViewDataSource + extension CommunityTableViewCell: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 10 @@ -52,8 +54,9 @@ extension CommunityTableViewCell: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CommunityCollectionViewCell", - for: indexPath) as? CommunityCollectionViewCell + guard let cell = collectionView + .dequeueReusableCell(withReuseIdentifier: "CommunityCollectionViewCell", + for: indexPath) as? CommunityCollectionViewCell else { return UICollectionViewCell() } @@ -67,6 +70,8 @@ extension CommunityTableViewCell: UICollectionViewDataSource { } +// MARK: - UICollectionViewDelegate + extension CommunityTableViewCell: UICollectionViewDelegate { } diff --git a/Toonie/Community/CommunityViewController.swift b/Toonie/Community/CommunityViewController.swift index 06dee61..2332c9b 100644 --- a/Toonie/Community/CommunityViewController.swift +++ b/Toonie/Community/CommunityViewController.swift @@ -10,16 +10,22 @@ import UIKit final class CommunityViewController: UIViewController { + // MARK: - IBOutlet + @IBOutlet private weak var communityTableView: UITableView! @IBOutlet private weak var topButton: UIButton! @IBOutlet private weak var writeButton: UIButton! - + + // MARK: - Life Cycle + override func viewDidLoad() { super.viewDidLoad() } + // MARK: - IBAction + @IBAction func topButtonDidTap(_ sender: UIButton) { print("topbutton") } @@ -30,7 +36,10 @@ final class CommunityViewController: UIViewController { } +// MARK: - UITableViewDataSource + extension CommunityViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 10 @@ -67,6 +76,8 @@ extension CommunityViewController: UITableViewDataSource { } +// MARK: - UITableViewDelegate + extension CommunityViewController: UITableViewDelegate { } diff --git a/Toonie/Detail/Controller/DetailViewController.swift b/Toonie/Detail/Controller/DetailViewController.swift index 61fc6c8..a5c38c8 100644 --- a/Toonie/Detail/Controller/DetailViewController.swift +++ b/Toonie/Detail/Controller/DetailViewController.swift @@ -97,10 +97,18 @@ final class DetailToonViewController: GestureViewController, UITextFieldDelegate tagTextField.returnKeyType = .done hideKeyboard() guard let detailToonID = detailToonID else { return } - myTagLabel.text = CommonUtility.sharedInstance.myTagDic[detailToonID] ?? "" - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil) + myTagLabel.text = CommonUtility.shared.myTagDic[detailToonID] ?? "" + NotificationCenter.default + .addObserver(self, + selector: #selector(keyboardWillShow(_:)), + name: UIResponder.keyboardWillShowNotification, + object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil) + NotificationCenter.default + .addObserver(self, + selector: #selector(keyboardWillHide(_:)), + name: UIResponder.keyboardWillHideNotification, + object: nil) } override func viewWillAppear(_ animated: Bool) { @@ -117,7 +125,6 @@ final class DetailToonViewController: GestureViewController, UITextFieldDelegate CommonUtility.analytics(eventName: "DetailViewController", param: ["toonId": detailToonID ?? "toonId"]) - } // MARK: - Functions @@ -143,14 +150,15 @@ final class DetailToonViewController: GestureViewController, UITextFieldDelegate func textFieldShouldReturn(_ textField: UITextField) -> Bool { myTagLabel.text = tagTextField.text - CommonUtility.sharedInstance.myTagDic.updateValue(myTagLabel.text ?? "", forKey: detailToonID ?? "") + CommonUtility.shared.myTagDic.updateValue(myTagLabel.text ?? "", forKey: detailToonID ?? "") tagTextField.resignFirstResponder() return true } /// 상세화면 툰 정보 네트워크 요청 private func loadDetailToon(_ toonID: String) { - DetailToonService.shared.getDetailToon(toonId: toonID) { [weak self] result in + DetailToonService.shared + .getDetailToon(toonId: toonID) { [weak self] result in guard let self = self else { return } self.detailToon = result if let detailToon = self.detailToon { @@ -187,7 +195,7 @@ final class DetailToonViewController: GestureViewController, UITextFieldDelegate self.detailToonImageView.imageFromUrl(detailToon.instaThumnailUrl, defaultImgPath: "dum2") self.detailToonImageView.setCorner(cornerRadius: self.detailToonImageView.frame.width / 2) self.detailToonImageView.image = self.detailToonImageView.image? - .resize(newWidth: UIScreen.main.bounds.width) + .resizeToFit(newWidth: UIScreen.main.bounds.width) self.authorIDLabel.text = detailToon.instaID self.authorNameLabel.text = detailToon.toonName self.descriptionLabel.text = " " //detailToon.instaInfo diff --git a/Toonie/Extension/UIImage+.swift b/Toonie/Extension/UIImage+.swift index a70e251..7d5262b 100644 --- a/Toonie/Extension/UIImage+.swift +++ b/Toonie/Extension/UIImage+.swift @@ -9,8 +9,8 @@ import UIKit extension UIImage { - // 이미지 크기 변경. - func resize(newWidth: CGFloat) -> UIImage? { + /// 이미지 비율에 맞춰 넓이 조건으로 크기 변경 + func resizeToFit(newWidth: CGFloat) -> UIImage? { let scale = newWidth / size.width let newHeight = size.height * scale UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight)) diff --git a/Toonie/Extension/UIView+.swift b/Toonie/Extension/UIView+.swift index 9f16cdd..5834380 100644 --- a/Toonie/Extension/UIView+.swift +++ b/Toonie/Extension/UIView+.swift @@ -16,7 +16,7 @@ extension UIView { self.layer.cornerRadius = cornerRadius } - ///border corner 설정하는 메서드 + ///border corner 설정 func setBorder(color: CGColor = UIColor.black.cgColor, borderWidth: CGFloat = 1.0) { self.layer.borderWidth = borderWidth diff --git a/Toonie/Feed/Controller/EditorPick&ToonieUse/EditorPick/EditorPickView.swift b/Toonie/Feed/Controller/EditorPick&ToonieUse/EditorPick/EditorPickView.swift index fabb42e..22002a8 100644 --- a/Toonie/Feed/Controller/EditorPick&ToonieUse/EditorPick/EditorPickView.swift +++ b/Toonie/Feed/Controller/EditorPick&ToonieUse/EditorPick/EditorPickView.swift @@ -9,7 +9,7 @@ import UIKit final class EditorPickView: UIView { - + // MARK: - Properties // MARK: - IBOutlets @@ -23,12 +23,13 @@ final class EditorPickView: UIView { let nibName = UINib(nibName: "EditorPickCollectionViewCell", bundle: nil) editorCollectionView.register(nibName, - forCellWithReuseIdentifier: "EditorPickCollectionViewCell") + forCellWithReuseIdentifier: "EditorPickCollectionViewCell") } } -// MARK: - UICollectionViewDataSource, UICollectionViewDelegate +// MARK: - UICollectionViewDataSource + extension EditorPickView: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -37,8 +38,9 @@ extension EditorPickView: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "EditorPickCollectionViewCell", - for: indexPath) as? EditorPickCollectionViewCell + guard let cell = collectionView + .dequeueReusableCell(withReuseIdentifier: "EditorPickCollectionViewCell", + for: indexPath) as? EditorPickCollectionViewCell else { return UICollectionViewCell() } @@ -46,9 +48,10 @@ extension EditorPickView: UICollectionViewDataSource { return cell } - } +// MARK: - UICollectionViewDelegate + extension EditorPickView: UICollectionViewDelegate { } diff --git a/Toonie/Feed/Controller/FeedViewController.swift b/Toonie/Feed/Controller/FeedViewController.swift index 712e600..c9b4aa2 100644 --- a/Toonie/Feed/Controller/FeedViewController.swift +++ b/Toonie/Feed/Controller/FeedViewController.swift @@ -9,7 +9,6 @@ import UIKit import Lottie import SnapKit -import Charts // Feed의 NavigationController final class FeedNavigationController: UINavigationController { @@ -22,7 +21,7 @@ final class FeedNavigationController: UINavigationController { } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - CommonUtility.sharedInstance + CommonUtility.shared .feedNavigationViewController = self } } @@ -64,14 +63,14 @@ final class FeedViewController: GestureViewController { private var latestToonLists: [ToonList]? private var favoriteToonLists: [ToonList]? private var favoriteToon: [ToonList]? - private var detailToonId = "" - private var isFavorite = false + private var detailToonId: String = "" + private var isFavorite: Bool = false // MARK: - Life Cycle override func viewDidLoad() { super.viewDidLoad() -// setTagAnimationView() + // setTagAnimationView() setRecmdCardLayout() setEditorPickLayout() setToonieUseLayout() @@ -85,7 +84,7 @@ final class FeedViewController: GestureViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) -// playTagAnimationView() + // playTagAnimationView() loadFavoriteToon() CommonUtility.analytics(eventName: "FeedViewController", @@ -97,7 +96,8 @@ final class FeedViewController: GestureViewController { /// 피드>피드상세 이동 @IBAction func moveFeedDetailDidTap(_ sender: Any) { let storyboard = UIStoryboard(name: "Feed", bundle: nil) - let viewController = storyboard.instantiateViewController(withIdentifier: "RecommendViewController") + let viewController = storyboard + .instantiateViewController(withIdentifier: "RecommendViewController") self.navigationController?.pushViewController(viewController, animated: true) } @@ -108,14 +108,14 @@ final class FeedViewController: GestureViewController { as? RecommendPopupViewConroller { viewController.modalPresentationStyle = .overCurrentContext - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? - .present(viewController, - animated: false, - completion:nil) + .present(viewController, animated: false, completion: nil) } } + // MARK: - Function + private func setEditorPickLayout() { if let view = Bundle.main .loadNibNamed("EditorPickView", @@ -141,7 +141,7 @@ final class FeedViewController: GestureViewController { } private func setRecmdCardLayout() { - self.recmdCardView.setCorner(cornerRadius:10) + self.recmdCardView.setCorner(cornerRadius: 10) self.recmdCardImageView.setCorner(cornerRadius: self.recmdCardImageView.frame.width / 1.8) } @@ -161,7 +161,6 @@ final class FeedViewController: GestureViewController { } else { self.forYouToonLists = makeRandomList(result, number: 10) - } self.forYouCollectionView.reloadData() } @@ -232,7 +231,7 @@ final class FeedViewController: GestureViewController { .instantiateViewController(withIdentifier: "DetailToonView") as? DetailToonViewController { viewController.detailToonID = toonID - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .pushViewController(viewController, animated: true) @@ -323,15 +322,23 @@ extension FeedViewController: UICollectionViewDataSource { // MARK: - UICollectionViewDelegate extension FeedViewController: UICollectionViewDelegate { - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + func collectionView(_ collectionView: UICollectionView, + didSelectItemAt indexPath: IndexPath) { + collectionView.deselectItem(at: indexPath, animated: true) - if let currentCell = collectionView.cellForItem(at: indexPath) as? ForYouCollectionViewCell { + + if let currentCell = collectionView + .cellForItem(at: indexPath) as? ForYouCollectionViewCell { detailToonId = currentCell.toonIdLabel.text ?? "" } - if let currentCell = collectionView.cellForItem(at: indexPath) as? RecentCollectionViewCell { + + if let currentCell = collectionView + .cellForItem(at: indexPath) as? RecentCollectionViewCell { detailToonId = currentCell.toonIdLabel.text ?? "" } - if let currentCell = collectionView.cellForItem(at: indexPath) as? FavoriteCollectionViewCell { + + if let currentCell = collectionView + .cellForItem(at: indexPath) as? FavoriteCollectionViewCell { detailToonId = currentCell.toonIdLabel.text ?? "" } pushDetailToonViewController(toonID: detailToonId, isFavorite: isFavorite) diff --git a/Toonie/Feed/Controller/RecommendPopupViewConroller.swift b/Toonie/Feed/Controller/RecommendPopupViewConroller.swift index 9b706fd..9794cbd 100644 --- a/Toonie/Feed/Controller/RecommendPopupViewConroller.swift +++ b/Toonie/Feed/Controller/RecommendPopupViewConroller.swift @@ -15,7 +15,7 @@ final class RecommendPopupViewConroller: UIViewController { // MARK: - IBOutlets @IBOutlet private weak var buttonHeight: NSLayoutConstraint! - + // MARK: - Life Cycle override func viewDidLoad() { super.viewDidLoad() @@ -27,7 +27,7 @@ final class RecommendPopupViewConroller: UIViewController { } } - + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) UIView.animate(withDuration: 0.3) { @@ -39,13 +39,14 @@ final class RecommendPopupViewConroller: UIViewController { // MARK: - IBAction @IBAction private func closeButtonDidTap(_ sender: Any) { - UIView.animate(withDuration: 0.3, animations: { - self.buttonHeight.constant = self.initalHeight / 5 - self.view.alpha = 0 - self.view.layoutIfNeeded() + UIView.animate(withDuration: 0.3, + animations: { + self.buttonHeight.constant = self.initalHeight / 5 + self.view.alpha = 0 + self.view.layoutIfNeeded() }) { (_) in self.dismiss(animated: true, completion: nil) } } - + } diff --git a/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift b/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift index bec552a..1da1af9 100644 --- a/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift +++ b/Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift @@ -8,7 +8,7 @@ import UIKit -// '지금나는 +// '지금나는' final class RecommendCollectionViewCell: UICollectionViewCell { // MARK: - Properties @@ -68,7 +68,7 @@ final class RecommendCollectionViewCell: UICollectionViewCell { if let info = curationInfoList { DispatchQueue.main.async { self.recentToonImageView.image = self.recentToonImageView.image? - .resize(newWidth: UIScreen.main.bounds.width / 2) + .resizeToFit(newWidth: UIScreen.main.bounds.width / 2) self.recentToonImageView.imageFromUrl(info.instaThumnailUrl, defaultImgPath: "dum2") } diff --git a/Toonie/Feed/RecommendView/RecommendTableViewCell.swift b/Toonie/Feed/RecommendView/RecommendTableViewCell.swift index e195937..924e57c 100644 --- a/Toonie/Feed/RecommendView/RecommendTableViewCell.swift +++ b/Toonie/Feed/RecommendView/RecommendTableViewCell.swift @@ -87,7 +87,9 @@ final class RecommendTableViewCell: UITableViewCell { } // MARK: - UICollectionViewDataSource + extension RecommendTableViewCell: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return curationTagArray?.count ?? 0 @@ -95,6 +97,7 @@ extension RecommendTableViewCell: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView .dequeueReusableCell(withReuseIdentifier: "RecommendCollectionViewCell", for: indexPath) as? RecommendCollectionViewCell @@ -109,7 +112,9 @@ extension RecommendTableViewCell: UICollectionViewDataSource { } // MARK: - UICollectionViewDelegate + extension RecommendTableViewCell: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { @@ -118,10 +123,9 @@ extension RecommendTableViewCell: UICollectionViewDelegate { .instantiateViewController(withIdentifier: "DetailToonView") as? DetailToonViewController { viewController.detailToonID = curationTagArray?[indexPath.row].toonID - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? - .pushViewController(viewController, - animated: true) + .pushViewController(viewController, animated: true) } } diff --git a/Toonie/Feed/RecommendView/RecommendViewController.swift b/Toonie/Feed/RecommendView/RecommendViewController.swift index b793446..12e3c23 100644 --- a/Toonie/Feed/RecommendView/RecommendViewController.swift +++ b/Toonie/Feed/RecommendView/RecommendViewController.swift @@ -96,7 +96,10 @@ final class RecommendViewController: GestureViewController { func setTagFlowLayout() { tagCollectionViewFlowLayout.minimumInteritemSpacing = 10 tagCollectionViewFlowLayout.minimumLineSpacing = 9 //라인 사이의 최소간격 - tagCollectionViewFlowLayout.sectionInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0) + tagCollectionViewFlowLayout.sectionInset = UIEdgeInsets.init(top: 0, + left: 0, + bottom: 0, + right: 0) tagCollectionViewFlowLayout.estimatedItemSize = CGSize.init(width: 20, height: 30) } @@ -125,8 +128,10 @@ final class RecommendViewController: GestureViewController { } -// MARK: - TableView : 전체를 이루는 뷰 +// MARK: - UITableViewDataSource : 전체를 이루는 뷰 + extension RecommendViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if tagSelectArray.count == 0 { @@ -163,6 +168,7 @@ extension RecommendViewController: UITableViewDataSource { } // MARK: - CollectionView : TagView - UICollectionViewDataSource + extension RecommendViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -179,7 +185,7 @@ extension RecommendViewController: UICollectionViewDataSource { for: indexPath) as? TagCollectionViewCell else { return UICollectionViewCell() } let titleName = tagList[indexPath.row] - cell.setTitleLabel(titleString: titleName) + cell.setTitleLabel(titleName) cell.setCellStatus(bool: false) @@ -189,7 +195,6 @@ extension RecommendViewController: UICollectionViewDataSource { } } - return cell } @@ -232,9 +237,12 @@ extension RecommendViewController: UICollectionViewDataSource { } // MARK: - CollectionView : TagView - UICollectionViewDelegate + extension RecommendViewController: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + if let cell = collectionView.cellForItem(at: indexPath) as? TagCollectionViewCell { cell.setCellStatus(bool: !cell.getCellStatus()) @@ -257,10 +265,13 @@ extension RecommendViewController: UICollectionViewDelegate { } // MARK: - CollectionView : TagView - UICollectionViewDelegateFlowLayout + extension RecommendViewController: UICollectionViewDelegateFlowLayout { + 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) diff --git a/Toonie/Feed/RecommendView/TagCollectionViewCell.swift b/Toonie/Feed/RecommendView/TagCollectionViewCell.swift index 3a6cf39..85b1767 100644 --- a/Toonie/Feed/RecommendView/TagCollectionViewCell.swift +++ b/Toonie/Feed/RecommendView/TagCollectionViewCell.swift @@ -13,7 +13,7 @@ final class TagCollectionViewCell: UICollectionViewCell { @IBOutlet private weak var backView: UIView! @IBOutlet private weak var titleLabel: UILabel! - private var titleString: String? + private var title: String? private var cellStatus: Bool = false { didSet { @@ -42,19 +42,19 @@ final class TagCollectionViewCell: UICollectionViewCell { func setCellStatus(bool: Bool) { cellStatus = bool } + func getCellStatus() -> Bool { return cellStatus } - func setTitleLabel(titleString: String?) { - if let titleString = titleString { - titleLabel.text = "#\(titleString)" - self.titleString = titleString - } + func setTitleLabel(_ title: String) { + titleLabel.text = "#\(title)" + self.title = title } + func getTitleString() -> String { - if let titleString = self.titleString { - return titleString + if let title = self.title { + return title } return "" } diff --git a/Toonie/Feed/View/FavoriteCollectionViewCell.swift b/Toonie/Feed/View/FavoriteCollectionViewCell.swift index 12a3843..46dc623 100644 --- a/Toonie/Feed/View/FavoriteCollectionViewCell.swift +++ b/Toonie/Feed/View/FavoriteCollectionViewCell.swift @@ -61,7 +61,7 @@ final class FavoriteCollectionViewCell: UICollectionViewCell { defaultImgPath: "dum2") self.favoriteToonImageView.setCorner(cornerRadius: 4) self.favoriteToonImageView.image = self.favoriteToonImageView.image? - .resize(newWidth: UIScreen.main.bounds.width) + .resizeToFit(newWidth: UIScreen.main.bounds.width) self.favoriteToonTitleLabel.text = toonList.toonName self.toonIdLabel.text = toonList.toonID } diff --git a/Toonie/Feed/View/Feed.storyboard b/Toonie/Feed/View/Feed.storyboard index dcae703..451415f 100644 --- a/Toonie/Feed/View/Feed.storyboard +++ b/Toonie/Feed/View/Feed.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -659,13 +657,13 @@ - + - + diff --git a/Toonie/Feed/View/ForYouCollectionViewCell.swift b/Toonie/Feed/View/ForYouCollectionViewCell.swift index 56e5c22..01b4e6d 100644 --- a/Toonie/Feed/View/ForYouCollectionViewCell.swift +++ b/Toonie/Feed/View/ForYouCollectionViewCell.swift @@ -62,7 +62,7 @@ final class ForYouCollectionViewCell: UICollectionViewCell { defaultImgPath: "dum2") self.forYouToonImageView.setCorner(cornerRadius: 4) self.forYouToonImageView.image = self.forYouToonImageView.image? - .resize(newWidth: UIScreen.main.bounds.width) + .resizeToFit(newWidth: UIScreen.main.bounds.width) self.forYouToonTitleLabel.text = toonList.toonName self.toonIdLabel.text = toonList.toonID } diff --git a/Toonie/Feed/View/RecentCollectionViewCell.swift b/Toonie/Feed/View/RecentCollectionViewCell.swift index bd29a55..e08a420 100644 --- a/Toonie/Feed/View/RecentCollectionViewCell.swift +++ b/Toonie/Feed/View/RecentCollectionViewCell.swift @@ -59,7 +59,7 @@ final class RecentCollectionViewCell: UICollectionViewCell { defaultImgPath: "dum2") self.recentToonImageView.setCorner(cornerRadius: 4) self.recentToonImageView.image = self.recentToonImageView.image? - .resize(newWidth: UIScreen.main.bounds.width) + .resizeToFit(newWidth: UIScreen.main.bounds.width) self.recentToonTitleLabel.text = toonList.toonName self.toonIdLabel.text = toonList.toonID } diff --git a/Toonie/Library/SwipeCard/PileView.swift b/Toonie/Library/SwipeCard/PileView.swift index a0b13a7..6330d08 100755 --- a/Toonie/Library/SwipeCard/PileView.swift +++ b/Toonie/Library/SwipeCard/PileView.swift @@ -53,10 +53,10 @@ class PileView : UIView { self.swipeViews.remove(at: 0) if self.swipeViews.count == 0 { - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .dismiss(animated: false, completion: { - if let mainViewController = CommonUtility.sharedInstance + if let mainViewController = CommonUtility.shared .mainNavigationViewController? .rootViewController as? MainViewController { mainViewController.swipeCardComplete() diff --git a/Toonie/Library/SwipeCard/SwipeViewDelegate.swift b/Toonie/Library/SwipeCard/SwipeViewDelegate.swift deleted file mode 100755 index 794a22b..0000000 --- a/Toonie/Library/SwipeCard/SwipeViewDelegate.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// File.swift -// PileView -// -// Created by Jeff Barg on 6/16/14. -// Copyright (c) 2014 Fructose Tech. All rights reserved. -// - -import Foundation diff --git a/Toonie/Look/LookDetailViewController/LookDetailCell.swift b/Toonie/Look/LookDetailViewController/LookDetailCell.swift index e73985e..0b2f097 100644 --- a/Toonie/Look/LookDetailViewController/LookDetailCell.swift +++ b/Toonie/Look/LookDetailViewController/LookDetailCell.swift @@ -20,6 +20,6 @@ final class LookDetailCell: UICollectionViewCell { func setImageView(imageURL: String) { imageView.imageFromUrl(imageURL, defaultImgPath: "dum2") imageView.image = imageView.image? - .resize(newWidth: UIScreen.main.bounds.width / 3) + .resizeToFit(newWidth: UIScreen.main.bounds.width / 3) } } diff --git a/Toonie/Look/LookDetailViewController/LookDetailTopSelectCell.swift b/Toonie/Look/LookDetailViewController/LookDetailTopSelectCell.swift index 852d550..ed3e22c 100644 --- a/Toonie/Look/LookDetailViewController/LookDetailTopSelectCell.swift +++ b/Toonie/Look/LookDetailViewController/LookDetailTopSelectCell.swift @@ -42,6 +42,7 @@ final class LookDetailTopSelectCell: UICollectionViewCell { func setCellStatus(bool: Bool) { cellStatus = bool } + func getCellStatus() -> Bool { return cellStatus } diff --git a/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift b/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift index f8cacef..2eb4b75 100644 --- a/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift +++ b/Toonie/Look/LookDetailViewController/LookDetailTopSelectViewController.swift @@ -71,8 +71,8 @@ extension LookDetailTopSelectViewController: UICollectionViewDataSource { for: indexPath) as? LookDetailTopSelectCell else { return UICollectionViewCell() } - cell.setTitleLabel(text: tags[indexPath.row].tagName) - cell.setCellStatus(bool: tags[indexPath.row].state) + cell.setTitleLabel(text: tags[indexPath.item].tagName) + cell.setCellStatus(bool: tags[indexPath.item].state) return cell } @@ -81,7 +81,7 @@ extension LookDetailTopSelectViewController: UICollectionViewDataSource { didSelectItemAt indexPath: IndexPath) { if let closure = self.tagDidTapClosure { - closure(tags[indexPath.row] + closure(tags[indexPath.item] .tagName .replacingOccurrences(of: "#", with: "")) @@ -102,7 +102,7 @@ extension LookDetailTopSelectViewController: UICollectionViewDataSource { layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let keyword = tags[indexPath.row].tagName + let keyword = tags[indexPath.item].tagName let font = UIFont.getAppleSDGothicNeo(option: .medium, size: 14) var width = Int(keyword.widthWithConstrainedHeight(height: 17, @@ -123,11 +123,12 @@ extension LookDetailTopSelectViewController: UICollectionViewDelegate { // MARK: - CollectionView : TagView - UICollectionViewDelegateFlowLayout extension LookDetailTopSelectViewController: UICollectionViewDelegateFlowLayout { + private func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize { - let keyword = tags[indexPath.row].tagName + let keyword = tags[indexPath.item].tagName let font = UIFont.getAppleSDGothicNeo(option: .medium, size: 14) var width = Int(keyword.widthWithConstrainedHeight(height: 17, diff --git a/Toonie/Look/LookDetailViewController/LookDetailViewController.swift b/Toonie/Look/LookDetailViewController/LookDetailViewController.swift index 0fc1047..8b37c44 100644 --- a/Toonie/Look/LookDetailViewController/LookDetailViewController.swift +++ b/Toonie/Look/LookDetailViewController/LookDetailViewController.swift @@ -149,7 +149,7 @@ final class LookDetailViewController: GestureViewController { .instantiateViewController(withIdentifier: "DetailToonView") as? DetailToonViewController { viewController.detailToonID = toonID - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .pushViewController(viewController, animated: true) @@ -241,6 +241,7 @@ extension LookDetailViewController: UICollectionViewDelegate { // MARK: - UIViewControllerPreviewingDelegate extension LookDetailViewController: UIViewControllerPreviewingDelegate { + func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { diff --git a/Toonie/Look/LookViewController/LookViewController.swift b/Toonie/Look/LookViewController/LookViewController.swift index 2bc9679..ac73259 100644 --- a/Toonie/Look/LookViewController/LookViewController.swift +++ b/Toonie/Look/LookViewController/LookViewController.swift @@ -15,7 +15,7 @@ final class LookNavigationController: UINavigationController { } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - CommonUtility.sharedInstance + CommonUtility.shared .lookNavigationViewController = self } } diff --git a/Toonie/Main/Base.lproj/Main.storyboard b/Toonie/Main/Base.lproj/Main.storyboard index f301433..9953732 100644 --- a/Toonie/Main/Base.lproj/Main.storyboard +++ b/Toonie/Main/Base.lproj/Main.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -468,13 +466,13 @@ 관심 있는 키워드를 3개 이상 선택해주세요 - + diff --git a/Toonie/Main/MainViewController.swift b/Toonie/Main/MainViewController.swift index 75aa1ef..7d33645 100644 --- a/Toonie/Main/MainViewController.swift +++ b/Toonie/Main/MainViewController.swift @@ -14,14 +14,14 @@ final class MainNavigationController: UINavigationController { var rootViewController: UIViewController? { return viewControllers.first } - - + override init(rootViewController: UIViewController) { super.init(rootViewController: rootViewController) } + required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController = self } } @@ -80,31 +80,23 @@ final class MainViewController: GestureViewController { chkToonieUpdate() //앱리뷰요청 - CommonUtility.sharedInstance.showStoreReview() + CommonUtility.shared.showStoreReview() setLocalNotification() - inputNotification() + addLocalNotification() //심사용 swipeCardPresent { [weak self] in - guard let self = self else { return } - self.popupPresent() + self?.popupPresent() } - - //일반용 - - } - - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) } func swipeCardPresent(completion: @escaping () -> Void) { let lastCloseTime = UserDefaults.standard.object(forKey: "SwipeCloseTime") as? Date - if CommonUtility.sharedInstance - .isDateCompare(lastCloseTime: lastCloseTime, - hideDay: 7) == false { + if CommonUtility.shared + .checkPassOneDay(by: lastCloseTime, + hideDay: 7) == false { let storyboard = UIStoryboard(name: "Main", bundle: nil) if let viewController = storyboard @@ -112,7 +104,8 @@ final class MainViewController: GestureViewController { as? SwipeCardViewController { viewController.modalPresentationStyle = .overCurrentContext - let tagArray = ["가족", "반려동물", "사랑 연애", "심리 감정", "여행", "음식", "자기계발", "자취생활", "직업", "페미니즘", "학교생활", "해외"] + let tagArray = ["가족", "반려동물", "사랑 연애", "심리 감정", "여행", "음식", + "자기계발", "자취생활", "직업", "페미니즘", "학교생활", "해외"] let index = Int(arc4random_uniform(UInt32((tagArray.count - 1)))) CategoryToonAllListService @@ -146,7 +139,7 @@ final class MainViewController: GestureViewController { self.popupPresent() } - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .present(viewController, animated: false, @@ -164,9 +157,9 @@ final class MainViewController: GestureViewController { //오늘하루 체크 let lastCloseTime = UserDefaults.standard.object(forKey: "PopupCloseTime") as? Date - if CommonUtility.sharedInstance - .isDateCompare(lastCloseTime: lastCloseTime, - hideDay: 1) == false { + if CommonUtility.shared + .checkPassOneDay(by: lastCloseTime, + hideDay: 1) == false { getCurationTagList { (tagList) in let storyboard = UIStoryboard(name: "Main", bundle: nil) @@ -176,7 +169,7 @@ final class MainViewController: GestureViewController { viewController.modalPresentationStyle = .overCurrentContext viewController.setTagList(tagList: tagList) - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .present(viewController, animated: false, @@ -186,8 +179,7 @@ final class MainViewController: GestureViewController { } } - - + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "MyPage" { if let myPageNavigationController = segue.destination as? MyPageNavigationController { @@ -236,7 +228,6 @@ final class MainViewController: GestureViewController { } statusButton = sender - } // MARK: - Function @@ -244,19 +235,19 @@ final class MainViewController: GestureViewController { func didTapDoubleButton() { switch statusButton { case feedButton: - CommonUtility.sharedInstance + CommonUtility.shared .feedNavigationViewController? .popToRootViewController(animated: true) case lookButton: - CommonUtility.sharedInstance + CommonUtility.shared .lookNavigationViewController? .popToRootViewController(animated: true) case myPageButton: - CommonUtility.sharedInstance + CommonUtility.shared .myPageNavigationViewController? .popToRootViewController(animated: true) default: - CommonUtility.sharedInstance + CommonUtility.shared .feedNavigationViewController? .popToRootViewController(animated: true) } @@ -297,7 +288,7 @@ final class MainViewController: GestureViewController { guard let self = self else { return } if result.forcedUpdate == true { if let forcedVersion = result.forceInfo?.forcedVersion { - if CommonUtility.sharedInstance + if CommonUtility.shared .compareToVersion(newVersion: forcedVersion) < 0 { self.chkToonieUpdateAlertShow(message: result @@ -314,7 +305,7 @@ final class MainViewController: GestureViewController { } if result.targetUpdate == true { if let targetVersion = result.targetInfo?.targetVersion { - if CommonUtility.sharedInstance + if CommonUtility.shared .compareToVersion(newVersion: targetVersion) == 0 { self.chkToonieUpdateAlertShow(message: result @@ -342,8 +333,8 @@ final class MainViewController: GestureViewController { if let url = URL(string: urlString) { UIApplication.shared.open(url, options: [:]) } - } - .present(to: self) + } + .present(to: self) } else { UIAlertController .alert(title: nil, @@ -353,37 +344,39 @@ final class MainViewController: GestureViewController { if let url = URL(string: urlString) { UIApplication.shared.open(url, options: [:]) } - } - .action(title: "취소", style: .default) { _ in - } - .present(to: self) + } + .action(title: "취소", style: .default) { _ in + } + .present(to: self) } } /// 로컬 노티피케이션 설정 private func setLocalNotification() { - // MARK: - 여기 options에 원하는 option넣기. - UNUserNotificationCenter.current().requestAuthorization(options: [.alert], completionHandler: { (_, _) in - + UNUserNotificationCenter.current().requestAuthorization(options: [.alert], + completionHandler: { (_, _) in + }) UNUserNotificationCenter.current().delegate = self } - - private func inputNotification() { - + + /// 로컬 노티피케이션 추가 + private func addLocalNotification() { let content = UNMutableNotificationContent() content.body = "오늘은 어떤 툰을 볼까요? 투니가 추천해줄게요!" var dateComponents = DateComponents() - dateComponents.hour = 21 - dateComponents.minute = 07 + dateComponents.hour = 22 + dateComponents.minute = 00 - let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true) - let request = UNNotificationRequest(identifier: "DailyNoti", content: content, trigger: trigger) - let center = UNUserNotificationCenter.current() - center.add(request) { (error) in + let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, + repeats: true) + let request = UNNotificationRequest(identifier: "DailyNoti", + content: content, + trigger: trigger) + + UNUserNotificationCenter.current().add(request) { (error) in print(error?.localizedDescription ?? "") - } } @@ -401,7 +394,8 @@ final class MainViewController: GestureViewController { completion(randArray) } } - + + /// 카드 스와이프 완료 후 알림창 func swipeCardComplete() { UIAlertController .alert(title: nil, @@ -410,8 +404,8 @@ final class MainViewController: GestureViewController { .action(title: "확인", style: .default) { _ in UserDefaults.standard.set(Date.init(), forKey: "SwipeCloseTime") self.popupPresent() - } - .present(to: self) + } + .present(to: self) } } diff --git a/Toonie/Main/PopupViewController.swift b/Toonie/Main/PopupViewController.swift index 94d1e1d..2fe7e3c 100644 --- a/Toonie/Main/PopupViewController.swift +++ b/Toonie/Main/PopupViewController.swift @@ -25,7 +25,7 @@ final class PopupViewController: UIViewController { @IBAction private func closeButtonDidTap(_ sender: Any) { self.navigationController?.dismiss(animated: true, completion: nil) - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .dismiss(animated: false, completion: nil) @@ -34,7 +34,7 @@ final class PopupViewController: UIViewController { } @IBAction private func recommendMoveDidTap(_ sender: Any) { - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController?.dismiss(animated: false, completion: { self.moveRecommend() }) @@ -47,7 +47,7 @@ final class PopupViewController: UIViewController { .instantiateViewController(withIdentifier: "RecommendViewController") as? RecommendViewController { viewController.setTagSelectArray(selectArr: self.tagList) - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .pushViewController(viewController, animated: true) } @@ -76,7 +76,7 @@ extension PopupViewController: UICollectionViewDataSource { for: indexPath) as? TagCollectionViewCell else { return UICollectionViewCell() } let titleName = tagList[indexPath.row] - cell.setTitleLabel(titleString: titleName) + cell.setTitleLabel(titleName) cell.setCellStatus(bool: true) @@ -94,7 +94,6 @@ extension PopupViewController: UICollectionViewDataSource { font: font)) width += 28 - return CGSize(width: width, height: 30) } diff --git a/Toonie/Main/SwipeCardViewController.swift b/Toonie/Main/SwipeCardViewController.swift index 84e13b2..d03c1e7 100644 --- a/Toonie/Main/SwipeCardViewController.swift +++ b/Toonie/Main/SwipeCardViewController.swift @@ -70,17 +70,14 @@ class SwipeCardViewController: UIViewController { width: width, height: height) } - - override func viewDidAppear(_ animated: Bool) { - } - + override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } @IBAction private func closeButtonDidTap(_ sender: Any) { - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .dismiss(animated: false, completion: { [weak self] in guard let self = self else { return } @@ -90,7 +87,6 @@ class SwipeCardViewController: UIViewController { closure() } }) - - + } } diff --git a/Toonie/MyPage/Controllers/MypageViewController.swift b/Toonie/MyPage/Controllers/MypageViewController.swift index 8756cf1..d2a4e25 100644 --- a/Toonie/MyPage/Controllers/MypageViewController.swift +++ b/Toonie/MyPage/Controllers/MypageViewController.swift @@ -18,9 +18,10 @@ final class MyPageNavigationController: UINavigationController { override init(rootViewController: UIViewController) { super.init(rootViewController: rootViewController) } + required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - CommonUtility.sharedInstance + CommonUtility.shared .myPageNavigationViewController = self } } @@ -93,7 +94,7 @@ final class MypageViewController: GestureViewController { .instantiateViewController(withIdentifier: "DetailToonView") as? DetailToonViewController { viewController.detailToonID = toonID - CommonUtility.sharedInstance + CommonUtility.shared .mainNavigationViewController? .pushViewController(viewController, animated: true) diff --git a/Toonie/Network/API+Base.swift b/Toonie/Network/API+Base.swift index dfe2612..5ee33cd 100644 --- a/Toonie/Network/API+Base.swift +++ b/Toonie/Network/API+Base.swift @@ -64,7 +64,6 @@ class API { return baseURL + "/toon/category/" + index } - //kewords/:keyword static let keywordInfo = { (keyword) in return categorys + "/" + keyword diff --git a/Toonie/Network/Model/ChkToonieUpdate.swift b/Toonie/Network/Model/ChkToonieUpdate.swift index e6d5b71..a10e956 100644 --- a/Toonie/Network/Model/ChkToonieUpdate.swift +++ b/Toonie/Network/Model/ChkToonieUpdate.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import UIKit - struct ChkToonieUpdate: Codable { let forcedUpdate: Bool? let forceInfo: ForceInfo? diff --git a/Toonie/Network/Model/DetailToon.swift b/Toonie/Network/Model/DetailToon.swift index c1ac004..3cf1f24 100644 --- a/Toonie/Network/Model/DetailToon.swift +++ b/Toonie/Network/Model/DetailToon.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct DetailToon: Codable { let toonID: String? let toonName: String? diff --git a/Toonie/Network/Model/Keywords.swift b/Toonie/Network/Model/Keywords.swift index a1bc594..56e68c4 100644 --- a/Toonie/Network/Model/Keywords.swift +++ b/Toonie/Network/Model/Keywords.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation struct Keywords: Codable { let success: Bool? let keywords: [String]? diff --git a/Toonie/Network/Model/Recommends.swift b/Toonie/Network/Model/Recommends.swift index a9c6b96..aabfe9b 100644 --- a/Toonie/Network/Model/Recommends.swift +++ b/Toonie/Network/Model/Recommends.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation struct Recommends: Codable { let succeess: Bool? let curationTagList: [String]? diff --git a/Toonie/Network/Model/Token.swift b/Toonie/Network/Model/Token.swift index 522ede1..69ca403 100644 --- a/Toonie/Network/Model/Token.swift +++ b/Toonie/Network/Model/Token.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation struct Token: Codable { let success: Bool? let token: String? diff --git a/Toonie/Network/Model/ToonLists.swift b/Toonie/Network/Model/ToonLists.swift index b80f276..6db440e 100644 --- a/Toonie/Network/Model/ToonLists.swift +++ b/Toonie/Network/Model/ToonLists.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct ToonLists: Codable { let toonList: [ToonList]? } @@ -25,7 +23,6 @@ struct ToonList: Codable { let curationTagList: [String]? enum CodingKeys: String, CodingKey { - case toonID, toonName, instaID, instaUrl, instaThumnailUrl, instaInfo, toonTagList, curationTagList case instaFollowerCount = "instafollowerCnt" diff --git a/Toonie/Network/Model/ToonOfTag.swift b/Toonie/Network/Model/ToonOfTag.swift index 7c49d4e..e2ebbff 100644 --- a/Toonie/Network/Model/ToonOfTag.swift +++ b/Toonie/Network/Model/ToonOfTag.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct ToonOfTag: Codable { let toonTag: String? let toonInfoList: [ToonInfoList]? diff --git a/Toonie/Network/Model/WorkList.swift b/Toonie/Network/Model/WorkList.swift index 65797a8..cd0cf1c 100644 --- a/Toonie/Network/Model/WorkList.swift +++ b/Toonie/Network/Model/WorkList.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct WorkList: Codable { let success: Bool? let workListName: String? diff --git a/Toonie/Network/NetworkResult.swift b/Toonie/Network/NetworkResult.swift index 1a13f21..79c0b72 100644 --- a/Toonie/Network/NetworkResult.swift +++ b/Toonie/Network/NetworkResult.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - enum NetworkResult { case networkSuccess(T) case networkError((resCode: Int, msg: String)) diff --git a/Toonie/Network/Requestable.swift b/Toonie/Network/Requestable.swift index ed66f79..5506a38 100644 --- a/Toonie/Network/Requestable.swift +++ b/Toonie/Network/Requestable.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation import Alamofire protocol Requestable { @@ -190,7 +189,6 @@ extension Requestable { } - extension SessionManager { func paramArrayRequest(_ url: URLConvertible, method: HTTPMethod = .post, diff --git a/Toonie/Network/Service/CategorysService.swift b/Toonie/Network/Service/CategorysService.swift index cbabba0..d24ec16 100644 --- a/Toonie/Network/Service/CategorysService.swift +++ b/Toonie/Network/Service/CategorysService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import UIKit - struct CategorysService: Requestable { typealias NetworkData = [Categorys] static let shared = CategorysService() diff --git a/Toonie/Network/Service/ChkToonieUpdateService.swift b/Toonie/Network/Service/ChkToonieUpdateService.swift index 528f364..815f10c 100644 --- a/Toonie/Network/Service/ChkToonieUpdateService.swift +++ b/Toonie/Network/Service/ChkToonieUpdateService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import UIKit - struct ChkToonieUpdateService: Requestable { typealias NetworkData = ChkToonieUpdate static let shared = ChkToonieUpdateService() diff --git a/Toonie/Network/Service/CurationTagService.swift b/Toonie/Network/Service/CurationTagService.swift index c2d16e1..473afff 100644 --- a/Toonie/Network/Service/CurationTagService.swift +++ b/Toonie/Network/Service/CurationTagService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct CurationTagService: Requestable { typealias NetworkData = ToonOfTag static let shared = CurationTagService() diff --git a/Toonie/Network/Service/DetailToonService.swift b/Toonie/Network/Service/DetailToonService.swift index a17bdc4..fc20dd1 100644 --- a/Toonie/Network/Service/DetailToonService.swift +++ b/Toonie/Network/Service/DetailToonService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct DetailToonService: Requestable { typealias NetworkData = DetailToon static let shared = DetailToonService() diff --git a/Toonie/Network/Service/FavoriteService.swift b/Toonie/Network/Service/FavoriteService.swift index c38191d..fac0d87 100644 --- a/Toonie/Network/Service/FavoriteService.swift +++ b/Toonie/Network/Service/FavoriteService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct FavoriteService: Requestable { typealias NetworkData = WorkList static let shared = FavoriteService() diff --git a/Toonie/Network/Service/LatestService.swift b/Toonie/Network/Service/LatestService.swift index 5e6c4fe..8f2ac5c 100644 --- a/Toonie/Network/Service/LatestService.swift +++ b/Toonie/Network/Service/LatestService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct LatestService: Requestable { typealias NetworkData = WorkList static let shared = LatestService() diff --git a/Toonie/Network/Service/LookToonOfTagService.swift b/Toonie/Network/Service/LookToonOfTagService.swift index 2b5df6b..57946c5 100644 --- a/Toonie/Network/Service/LookToonOfTagService.swift +++ b/Toonie/Network/Service/LookToonOfTagService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct LookToonOfTagService: Requestable { typealias NetworkData = ToonOfTag static let shared = LookToonOfTagService() diff --git a/Toonie/Network/Service/RecommendService.swift b/Toonie/Network/Service/RecommendService.swift index f640789..b2b046d 100644 --- a/Toonie/Network/Service/RecommendService.swift +++ b/Toonie/Network/Service/RecommendService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct RecommendService: Requestable { typealias NetworkData = Recommends static let shared = RecommendService() diff --git a/Toonie/Network/Service/TokenService.swift b/Toonie/Network/Service/TokenService.swift index 2b80a30..54993d5 100644 --- a/Toonie/Network/Service/TokenService.swift +++ b/Toonie/Network/Service/TokenService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct TokenService: Requestable { typealias NetworkData = Token static let shared = TokenService() diff --git a/Toonie/Network/Service/ToonListService.swift b/Toonie/Network/Service/ToonListService.swift index 3265460..2abab11 100644 --- a/Toonie/Network/Service/ToonListService.swift +++ b/Toonie/Network/Service/ToonListService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct ToonListService: Requestable { typealias NetworkData = ToonLists static let shared = ToonListService() diff --git a/Toonie/Network/Service/ToonOfTagService.swift b/Toonie/Network/Service/ToonOfTagService.swift index 7ee3ddf..a85a516 100644 --- a/Toonie/Network/Service/ToonOfTagService.swift +++ b/Toonie/Network/Service/ToonOfTagService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct ToonOfTagService: Requestable { typealias NetworkData = ToonOfTag static let shared = ToonOfTagService() diff --git a/Toonie/Preview/PreviewViewController.swift b/Toonie/Preview/PreviewViewController.swift index 6bbba17..5ae3778 100644 --- a/Toonie/Preview/PreviewViewController.swift +++ b/Toonie/Preview/PreviewViewController.swift @@ -67,6 +67,6 @@ final class PreviewViewController: UIViewController { private func setImage() { self.previewImageView.imageFromUrl(imageUrl, defaultImgPath: "dum2") self.previewImageView.image = self.previewImageView.image? - .resize(newWidth: UIScreen.main.bounds.width) + .resizeToFit(newWidth: UIScreen.main.bounds.width) } } diff --git a/Toonie/Reviewer/Reviewer.swift b/Toonie/Reviewer/Reviewer.swift index 646698c..ac9560e 100644 --- a/Toonie/Reviewer/Reviewer.swift +++ b/Toonie/Reviewer/Reviewer.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct Reviewer: Codable { let inReview: Bool? let inReviewVersion: String? diff --git a/Toonie/Reviewer/ReviewerService.swift b/Toonie/Reviewer/ReviewerService.swift index 0a76773..41ed923 100644 --- a/Toonie/Reviewer/ReviewerService.swift +++ b/Toonie/Reviewer/ReviewerService.swift @@ -6,8 +6,6 @@ // Copyright © 2019 Yapp. All rights reserved. // -import Foundation - struct ReviewerService: Requestable { typealias NetworkData = Reviewer static let shared = ReviewerService() diff --git a/Toonie/Splash/KeywordCell.swift b/Toonie/Splash/KeywordCell.swift index 34f48fc..c0a6b3e 100644 --- a/Toonie/Splash/KeywordCell.swift +++ b/Toonie/Splash/KeywordCell.swift @@ -9,15 +9,22 @@ import UIKit final class KeywordCell: UICollectionViewCell { + + // MARK: - IBOutlet + @IBOutlet weak var backView: UIView! @IBOutlet weak var titleLabel: UILabel! - + + // MARK: - Property + var cellStatus: Bool = false { didSet { setBorderViewLayout(status: cellStatus) } } + // MARK: - Function + ///didTap 일어날때마다 cellBackgroundView 레이아웃 바꿔주는 함수 func setBorderViewLayout(status: Bool) { if status == false { //선택안함 diff --git a/Toonie/Splash/KeywordSelectViewController.swift b/Toonie/Splash/KeywordSelectViewController.swift index 3d9ee2e..241082d 100644 --- a/Toonie/Splash/KeywordSelectViewController.swift +++ b/Toonie/Splash/KeywordSelectViewController.swift @@ -10,17 +10,24 @@ import UIKit import KTCenterFlowLayout final class KeywordSelectViewController: GestureViewController { + + // MARK: - IBOutlet + @IBOutlet weak var bigTitleLabel: UILabel! @IBOutlet weak var keywordCollecionView: UICollectionView! @IBOutlet weak var keywordFlowLayout: KTCenterFlowLayout! @IBOutlet weak var keywordCountLabel: UILabel! @IBOutlet weak var mainMoveButton: UIButton! - + + // MARK: - Properties + private var layoutMode: Bool = false var selectingCategoryArray = [String]() // 선택할 카테고리가 들어갈 배열 var categorys = [Categorys]() - + + // MARK: - Life Cycle + override func viewDidLoad() { super.viewDidLoad() setUserToken() @@ -35,26 +42,30 @@ final class KeywordSelectViewController: GestureViewController { } } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) setKeywordValue() CommonUtility.analytics(eventName: "KeywordViewController", param: ["token": CommonUtility.getUserToken() ?? "toonie"]) } - + + // MARK: - IBAction + ///시작하기 버튼-메인으로 이동 @IBAction func startButtonDidTap(_ sender: UIButton) { print("선택한 카테고리 \(selectingCategoryArray)") -// // 누르면 -// postMyCategorys + // // 누르면 + // postMyCategorys MyCategorysService.shared.postMyCategorys(params: selectingCategoryArray) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let viewController = storyboard.instantiateViewController(withIdentifier: "RootViewController") UIApplication.shared.keyWindow?.rootViewController = viewController } } - + + // MARK: - Function + ///keywordFlowLayout 프로퍼티 설정 func setKeywordFlowLayout() { keywordFlowLayout.minimumInteritemSpacing = 10 @@ -108,7 +119,8 @@ final class KeywordSelectViewController: GestureViewController { } -extension KeywordSelectViewController: UICollectionViewDelegate, UICollectionViewDataSource { +// MARK: - UICollectionViewDataSource +extension KeywordSelectViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return categorys.count } @@ -125,57 +137,64 @@ extension KeywordSelectViewController: UICollectionViewDelegate, UICollectionVie cell.titleLabel.text = categorys[indexPath.row].name cell.cellStatus = false -// -// //사용자가 선택한 키워드는 활성화처리 -// for categorySelect in categorySelectArray -// where categorys[indexPath.row] == categorySelect { -// cell.cellStatus = true -// } + // + // //사용자가 선택한 키워드는 활성화처리 + // for categorySelect in categorySelectArray + // where categorys[indexPath.item] == categorySelect { + // cell.cellStatus = true + // } return cell } +} + +// MARK: - UICollectionViewDelegate + +extension KeywordSelectViewController: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - - if let category = categorys[indexPath.row].name{ + + if let category = categorys[indexPath.item].name{ let width = Int(category.widthWithConstrainedHeight(height: 49, font: UIFont.systemFont(ofSize: 20))) return CGSize(width: width + 20, height: 50) } - - return CGSize(width: 20, height: 50) - + + return CGSize(width: 20, height: 50) + } - + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if let cell = collectionView.cellForItem(at: indexPath) as? KeywordCell { cell.cellStatus = !cell.cellStatus - + //선택한 키워드 추가 및 삭제 if cell.cellStatus == true { - self.selectingCategoryArray.append(self.categorys[indexPath.row].name ?? "") + self.selectingCategoryArray.append(self.categorys[indexPath.item].name ?? "") } else { let findIndex = self.selectingCategoryArray.firstIndex(of: cell.titleLabel.text ?? "") - + if let index = findIndex { self.selectingCategoryArray.remove(at: index) } } - + //카운트레이블, 버튼 리로드 self.reloadKeywordView() } } - } +// MARK: - UICollectionViewDelegateFlowLayout + extension KeywordSelectViewController: UICollectionViewDelegateFlowLayout { private func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize { - if let category = categorys[indexPath.row].name{ + if let category = categorys[indexPath.item].name{ let width = Int(category.widthWithConstrainedHeight(height: 49, font: UIFont.systemFont(ofSize: 20))) return CGSize(width: width + 20, height: 50) diff --git a/Toonie/Splash/SplashViewController.swift b/Toonie/Splash/SplashViewController.swift index e26024e..2915486 100644 --- a/Toonie/Splash/SplashViewController.swift +++ b/Toonie/Splash/SplashViewController.swift @@ -10,12 +10,18 @@ import UIKit import Lottie final class SplashViewController: GestureViewController { - + + // MARK: - IBOutlet + @IBOutlet weak var logoFrameView: UIView! + + // MARK: - Property + private var logoAnimationView: AnimationView? - var moveMode: Bool = false - + + // MARK: - Life Cycle + override func viewDidLoad() { super.viewDidLoad() @@ -24,7 +30,7 @@ final class SplashViewController: GestureViewController { //사용자 상태 체크 후 애니메이션 실행. self.getUserSelectedKeyword { [weak self] (mode) in guard let self = self else { return } - self.logoAnimationView?.play { [weak self](finished) in + self.logoAnimationView?.play { [weak self] (finished) in guard let self = self else { return } if finished { if mode == true { @@ -36,7 +42,9 @@ final class SplashViewController: GestureViewController { } } } - + + // MARK: - Function + ///애니메이션 후 메인화면으로 이동 func moveMainView() { let storyboard = UIStoryboard(name: "Main", bundle: nil) diff --git a/ToonieWidget/TodayViewController.swift b/ToonieWidget/TodayViewController.swift index 4d24cee..1e4b9bc 100644 --- a/ToonieWidget/TodayViewController.swift +++ b/ToonieWidget/TodayViewController.swift @@ -10,14 +10,19 @@ import UIKit import NotificationCenter final class TodayViewController: UIViewController, NCWidgetProviding { - + + // MARK: - IBOutlet @IBOutlet private weak var widgetCollecionView: UICollectionView! @IBOutlet private weak var curtionButton: UIButton! - - private let tagArray = ["가족", "반려동물", "사랑 연애", "심리 감정", "여행", "음식", "자기계발", "자취생활", "직업", "페미니즘", "학교생활", "해외"] + // MARK: - Property + + private let tagArray = ["가족", "반려동물", "사랑 연애", "심리 감정", "여행", + "음식", "자기계발", "자취생활", "직업", "페미니즘", "학교생활", "해외"] private var tagList: [String] = [] - + + // MARK: - IBAction + @IBAction func curationButton(_ sender: Any) { let url = URL(string: "Toonie://")! @@ -28,6 +33,8 @@ final class TodayViewController: UIViewController, NCWidgetProviding { }) } + + // MARK: - Life Cycle override func viewDidLoad() { super.viewDidLoad() @@ -39,7 +46,9 @@ final class TodayViewController: UIViewController, NCWidgetProviding { tagList = makeRandomList(tagArray, number: 4) widgetCollecionView.reloadData() } - + + // MARK: - Function + func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) { completionHandler(NCUpdateResult.newData) @@ -47,8 +56,12 @@ final class TodayViewController: UIViewController, NCWidgetProviding { } +// MARK: - UICollectionViewDataSource + extension TodayViewController: UICollectionViewDataSource { - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + + func collectionView(_ collectionView: UICollectionView, + numberOfItemsInSection section: Int) -> Int { return tagList.count } @@ -69,6 +82,8 @@ extension TodayViewController: UICollectionViewDataSource { } } +// MARK: - UICollectionViewDelegate + extension TodayViewController: UICollectionViewDelegate { } diff --git a/ToonieWidget/WidgetCollectionViewCell.swift b/ToonieWidget/WidgetCollectionViewCell.swift index 7665a23..8607251 100644 --- a/ToonieWidget/WidgetCollectionViewCell.swift +++ b/ToonieWidget/WidgetCollectionViewCell.swift @@ -9,16 +9,20 @@ import UIKit final class WidgetCollectionViewCell: UICollectionViewCell { + + // MARK: - IBOutlet + @IBOutlet private weak var widgetImageView: UIImageView! override func prepareForReuse() { super.prepareForReuse() widgetImageView.image = nil } - + + // MARK: - Function + /// widget 컬렉션뷰셀 데이터 설정 func setWidgetCollectionViewCellProperties(tagName: String) { - widgetImageView.setCorner(cornerRadius: 5) widgetImageView.image = UIImage(named: tagImage(name: tagName, storyboardName: "Look"))