From 14a816267a2dafe79213488512fa5fc4d072e812 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sat, 23 Sep 2023 12:05:40 +0900 Subject: [PATCH 01/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80ViewController=20=EC=BD=94=EB=93=9C=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeViewController.swift | 55 +++++++++++++------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index d5516f30..6521b322 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -49,31 +49,30 @@ enum BadgeLevel: String { } } +protocol ChallengeServiceProtocol { + func inquireChallengeInfo() async throws -> ChallengeData +} + final class ChallengeViewController: UIViewController { + private var challengeService: ChallengeServiceProtocol + var inputData: ChallengeData? { didSet { guard let babyNickname = inputData?.babyDaddyName else { return } - self.nicknameLabel.text = "\(babyNickname)아빠 님," - - if let howLongDay = inputData?.howLongDay { - self.challengeDayLabel.text = "\(howLongDay)일째 도전 중" - } - - self.levelBadge.image = BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeImage - - self.lottieImageView.animation = .named(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.progreddbarLottie ?? "") - self.lottieImageView.play() - - let fullText = "사자력 Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1) - - let attributtedString = NSMutableAttributedString(string: fullText) - attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.designSystem(.white) ?? .white, range: (fullText as NSString).range(of: "Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1))) - - self.challengelevelLabel.attributedText = attributtedString + configureData(babyNickname) + } } + init(challengeService: ChallengeServiceProtocol) { + self.challengeService = challengeService + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } private enum Size { static let cellOffset: CGFloat = 40 static let numberOfCellsinRow: CGFloat = 0 @@ -144,7 +143,7 @@ final class ChallengeViewController: UIViewController { Task { do { self.showLoading() - let model = try await ChallengeService.shared.inquireChallengeInfo() + let model = try await challengeService.inquireChallengeInfo() self.inputData = model self.tags = model.daddyAttendances self.challengeDayCheckCollectionView.reloadData() @@ -259,6 +258,26 @@ private extension ChallengeViewController { self.navigationController?.pushViewController(myPageViewController, animated: true) } } + + func configureData(_ babyNickname: String) { + self.nicknameLabel.text = "\(babyNickname)아빠 님," + + if let howLongDay = inputData?.howLongDay { + self.challengeDayLabel.text = "\(howLongDay)일째 도전 중" + } + + self.levelBadge.image = BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeImage + + self.lottieImageView.animation = .named(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.progreddbarLottie ?? "") + self.lottieImageView.play() + + let fullText = "사자력 Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1) + + let attributtedString = NSMutableAttributedString(string: fullText) + attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.designSystem(.white) ?? .white, range: (fullText as NSString).range(of: "Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1))) + + self.challengelevelLabel.attributedText = attributtedString + } } extension ChallengeViewController: From 25a02c11632d1cdc62a5e482a020346a9774a58f Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sat, 23 Sep 2023 12:06:22 +0900 Subject: [PATCH 02/39] =?UTF-8?q?=F0=9F=94=A5=20wrapper=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Network/Services/AuthMyPageServiceWrapper.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift index 592ceb02..65cac04f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift @@ -24,7 +24,6 @@ final class AuthMyPageServiceWrapper: AuthServiceProtocol, MyPageServiceProtocol } func reissueToken(token: Token) async throws -> Token? { - let model = try await authAPIService.reissueToken(token: token) return try await authAPIService.reissueToken(token: token) } From 644251b70d4cb01b693c025cf6c64c57de7a88d4 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sat, 23 Sep 2023 12:06:47 +0900 Subject: [PATCH 03/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Challenge=20DI?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 +++ .../Network/API/ChallengeAPI.swift | 26 ++++++++++++++++++ .../Network/Services/ChallengeService.swift | 27 ++++++++++--------- .../Challenge/Model/ChallengeData.swift | 6 +++++ .../Scenes/TabBar/TabBarViewController.swift | 2 +- 5 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 10f9f422..f3e1dd32 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -109,6 +109,7 @@ C06E382A2A662E3700B00600 /* ArticleService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E38292A662E3700B00600 /* ArticleService.swift */; }; C07CB81A2A62C54D000198CC /* TodayModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07CB8192A62C54D000198CC /* TodayModel.swift */; }; C07CB81E2A62C5B1000198CC /* TodayArticleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07CB81D2A62C5B1000198CC /* TodayArticleView.swift */; }; + C0856B602ABE840A0026D9F8 /* ChallengeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -320,6 +321,7 @@ C06E38292A662E3700B00600 /* ArticleService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleService.swift; sourceTree = ""; }; C07CB8192A62C54D000198CC /* TodayModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayModel.swift; sourceTree = ""; }; C07CB81D2A62C5B1000198CC /* TodayArticleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayArticleView.swift; sourceTree = ""; }; + C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeAPI.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1254,6 +1256,7 @@ C0903D012AAAD86A0014786F /* AuthAPI.swift */, C004D4982AAD8F880087F044 /* MyPageAPI.swift */, 4AD6A34B2AB1AB6700977224 /* BookmarkAPI.swift */, + C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */, ); path = API; sourceTree = ""; @@ -1587,6 +1590,7 @@ C0DF03A62A5CB8610037F740 /* CompleteOnbardingViewController.swift in Sources */, D342807C2A67FE4700DA1499 /* ChallengeService.swift in Sources */, C0DF034B2A5A9B6A0037F740 /* CurriculumViewController.swift in Sources */, + C0856B602ABE840A0026D9F8 /* ChallengeAPI.swift in Sources */, F435E0542A5E67BF0098E691 /* NSObject+.swift in Sources */, 4AE19A1F2A66F2E200C1DB7E /* BookmarkDetailCollectionViewCell.swift in Sources */, D3AB54B62A625A7B0017BF53 /* ArticleListByCategoryHeaderView.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift new file mode 100644 index 00000000..3cd6a980 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift @@ -0,0 +1,26 @@ +// +// ChallengeAPI.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/23. +// + +import Foundation + +protocol ChallengeServiceAPIProtocol { + func inquireChallengeInfo() async throws -> ChallengeDataResponse? +} + +final class ChallengeAPI: ChallengeServiceAPIProtocol { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func inquireChallengeInfo() async throws -> ChallengeDataResponse? { + let urlRequest = try NetworkRequest(path: "/v1/challenge/progress", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift index 8d9c0edd..0a1feb91 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift @@ -7,21 +7,22 @@ import Foundation -final class ChallengeService: Serviceable { - static let shared = ChallengeService() - private init() {} +final class ChallengeService: ChallengeServiceProtocol { + + private let challengeAPIService: ChallengeServiceAPIProtocol + + init(challengeAPIService: ChallengeServiceAPIProtocol) { + self.challengeAPIService = challengeAPIService + } func inquireChallengeInfo() async throws -> ChallengeData{ - let urlRequest = try NetworkRequest(path: "/v1/challenge/progress", httpMethod: .get) - .makeURLRequest(isLogined: true) + guard let model = try await challengeAPIService.inquireChallengeInfo() else { return ChallengeData.empty } + return toAppData(from: model) + } +} - let (data, _) = try await URLSession.shared.data(for: urlRequest) - - guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: ChallengeDataResponse.self) else { return ChallengeData(babyDaddyName: "", howLongDay: 0, daddyLevel: "", daddyAttendances: []) } - - return ChallengeData(babyDaddyName: model.babyNickname, - howLongDay: model.day, - daddyLevel: model.level, - daddyAttendances: model.attendances) +extension ChallengeService { + func toAppData(from input: ChallengeDataResponse) -> ChallengeData { + return .init(babyDaddyName: input.babyNickname, howLongDay: input.day, daddyLevel: input.level, daddyAttendances: input.attendances) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift index 7c3a99f8..c3ba77c7 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift @@ -13,3 +13,9 @@ struct ChallengeData: AppData { let daddyLevel: String let daddyAttendances: [String] } + +extension ChallengeData { + static var empty: Self { + return .init(babyDaddyName: "", howLongDay: 0, daddyLevel: "", daddyAttendances: []) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift index 675ffba4..7beb4ae5 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift @@ -23,7 +23,7 @@ final class TabBarViewController: UITabBarController { let curriculumViewController = UINavigationController(rootViewController: CurriculumViewController()) curriculumViewController.tabBarItem = UITabBarItem(title: "커리큘럼", image: .assetImage(.curriculum), tag: 2) - let challengeViewController = UINavigationController(rootViewController: ChallengeViewController()) + let challengeViewController = UINavigationController(rootViewController: ChallengeViewController(challengeService: ChallengeService(challengeAPIService: ChallengeAPI(apiService: APIService())))) challengeViewController.tabBarItem = UITabBarItem(title: "챌린지", image: .assetImage(.challenge), tag: 3) self.viewControllers = [todayViewController, articleCategoryViewController, curriculumViewController, challengeViewController] From c00900cca791da95085556ecbe180c4ea4ed898e Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 09:42:13 +0900 Subject: [PATCH 04/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Today=20DI=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 28 ++++++ .../DTO/Today/TodayArticleResponse.swift | 6 ++ .../Network/Manager/TodayManagerImpl.swift | 22 +++++ .../Network/Service/ArticleServiceImpl.swift | 43 +++++++++ .../Network/Services/ArticleService.swift | 88 +++++++++---------- .../ArticleListByCategoryViewController.swift | 3 + .../ViewControllers/TodayViewController.swift | 17 +++- 7 files changed, 162 insertions(+), 45 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/TodayManagerImpl.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/ArticleServiceImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index f3e1dd32..64522286 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -110,6 +110,9 @@ C07CB81A2A62C54D000198CC /* TodayModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07CB8192A62C54D000198CC /* TodayModel.swift */; }; C07CB81E2A62C5B1000198CC /* TodayArticleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07CB81D2A62C5B1000198CC /* TodayArticleView.swift */; }; C0856B602ABE840A0026D9F8 /* ChallengeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */; }; + C0856B652ABFB8640026D9F8 /* TodayManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */; }; + C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */; }; + C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -322,6 +325,9 @@ C07CB8192A62C54D000198CC /* TodayModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayModel.swift; sourceTree = ""; }; C07CB81D2A62C5B1000198CC /* TodayArticleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayArticleView.swift; sourceTree = ""; }; C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeAPI.swift; sourceTree = ""; }; + C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayManagerImpl.swift; sourceTree = ""; }; + C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleServiceImpl.swift; sourceTree = ""; }; + C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailManagerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -600,6 +606,8 @@ B532E8612A55260C00F0DB19 /* Network */ = { isa = PBXGroup; children = ( + C0856B662ABFB8DB0026D9F8 /* Service */, + C0856B632ABFB84E0026D9F8 /* Manager */, C0903D002AAAD8600014786F /* API */, B5C6A2C32A5EF4AC0021BE5E /* DTO */, B59893172A5D41E300CE1FEB /* Services */, @@ -1250,6 +1258,23 @@ path = Model; sourceTree = ""; }; + C0856B632ABFB84E0026D9F8 /* Manager */ = { + isa = PBXGroup; + children = ( + C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */, + C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */, + ); + path = Manager; + sourceTree = ""; + }; + C0856B662ABFB8DB0026D9F8 /* Service */ = { + isa = PBXGroup; + children = ( + C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */, + ); + path = Service; + sourceTree = ""; + }; C0903D002AAAD8600014786F /* API */ = { isa = PBXGroup; children = ( @@ -1611,6 +1636,7 @@ F4DB30AE2A611C7C00413EB9 /* CurriculumListByWeekViewController.swift in Sources */, B59892EC2A5B94E100CE1FEB /* UIApplication+.swift in Sources */, 4AE19A172A65864F00C1DB7E /* BookmarkService.swift in Sources */, + C0856B652ABFB8640026D9F8 /* TodayManagerImpl.swift in Sources */, 4AE19A1A2A65886100C1DB7E /* BookmarkReponse.swift in Sources */, B5F323E92A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift in Sources */, C0DF039F2A5CABC10037F740 /* GetPregnancyViewController.swift in Sources */, @@ -1650,6 +1676,7 @@ 4AD6AE1A2A68436B00A3D745 /* ArticleListByCategoryResponse.swift in Sources */, 4A8980D02A61850500746C58 /* MyPageAppSettingCollectionViewCell.swift in Sources */, C06E38232A65353F00B00600 /* LoginType.swift in Sources */, + C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */, B5C6A2B62A5DD5FE0021BE5E /* TitleTableViewCell.swift in Sources */, C0DF03962A5B8FB10037F740 /* Palette.swift in Sources */, 4A3D72872A5D405C00A36189 /* BookmarkListCollectionViewCell.swift in Sources */, @@ -1673,6 +1700,7 @@ B57BEB6C2A6149AD00D1727C /* NetworkRequest.swift in Sources */, C0DF03552A5A9BD60037F740 /* ArticleListByCategoryView.swift in Sources */, F4DB30B42A61250500413EB9 /* CurriculumListByWeekCollectionViewCell.swift in Sources */, + C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */, F46522FD2A6048660083FBB2 /* CurriculumImagesByWeek.swift in Sources */, 4A8980CA2A614F8700746C58 /* MyPageModel.swift in Sources */, C0DF03512A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/DTO/Today/TodayArticleResponse.swift b/LionHeart-iOS/LionHeart-iOS/Network/DTO/Today/TodayArticleResponse.swift index db6c9555..d28edf62 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/DTO/Today/TodayArticleResponse.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/DTO/Today/TodayArticleResponse.swift @@ -16,3 +16,9 @@ struct TodayArticleResponse: DTO, Response { let day: Int let articleId: Int } + +extension TodayArticleResponse { + func toAppData() -> TodayArticle { + return .init(fetalNickname: self.babyNickname, articleTitle: self.title, articleDescription: self.editorNoteContent, currentWeek: self.week, currentDay: self.day, mainImageURL: self.mainImageUrl, aticleID: self.articleId) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/TodayManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/TodayManagerImpl.swift new file mode 100644 index 00000000..5948ed42 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/TodayManagerImpl.swift @@ -0,0 +1,22 @@ +// +// TodayManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class TodayManagerImpl: TodayManager { + + private let articleService: ArticleService + + init(articleService: ArticleService) { + self.articleService = articleService + } + + func inquiryTodayArticle() async throws -> TodayArticle { + guard let model = try await articleService.inquiryTodayArticle() else { return .emptyArticle } + return model.toAppData() + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/ArticleServiceImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/ArticleServiceImpl.swift new file mode 100644 index 00000000..ce79e8af --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/ArticleServiceImpl.swift @@ -0,0 +1,43 @@ +// +// ArticleServiceImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +struct Query: Request { + let category: String +} + +protocol ArticleService { + func inquiryTodayArticle() async throws -> TodayArticleResponse? + func getArticleDetail(articleId: Int) async throws -> ArticleDetail? + func getArticleListByCategory(categoryString: String) async throws -> CategoryList? +} + +final class ArticleServiceImpl: ArticleService { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func inquiryTodayArticle() async throws -> TodayArticleResponse? { + let urlRequest = try NetworkRequest(path: "/v1/article/today", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } + + func getArticleDetail(articleId: Int) async throws -> ArticleDetail? { + let urlRequest = try NetworkRequest(path: "/v1/article/\(articleId)", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } + + func getArticleListByCategory(categoryString: String) async throws -> CategoryList? { + let query = Query(category: categoryString) + let urlRequest = try NetworkRequest(path: "/v1/article", httpMethod: .get, query: query).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift index 60c72d86..d4cbe79c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift @@ -7,47 +7,47 @@ import UIKit -struct Query: Request { - let category: String -} - -final class ArticleService: Serviceable { - static let shared = ArticleService() - private init() {} - - func inquiryTodayArticle() async throws -> TodayArticle { - let urlRequest = try NetworkRequest(path: "/v1/article/today", httpMethod: .get).makeURLRequest(isLogined: true) - let (data, _) = try await URLSession.shared.data(for: urlRequest) - - guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: TodayArticleResponse.self) - else { return TodayArticle.emptyArticle } - - return .init(fetalNickname: model.babyNickname, articleTitle: model.title, articleDescription: model.editorNoteContent, currentWeek: model.week, currentDay: model.day, mainImageURL: model.mainImageUrl, aticleID: model.articleId) - } - - func getArticleDetail(articleId: Int) async throws -> [BlockTypeAppData] { - let urlRequest = try NetworkRequest(path: "/v1/article/\(articleId)", httpMethod: .get).makeURLRequest(isLogined: true) - - let (data, _) = try await URLSession.shared.data(for: urlRequest) - - guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: ArticleDetail.self) else { - return [] - } - - return model.toAppData() - } - - func getArticleListByCategory(categoryString: String) async throws -> CurriculumWeekData { - let query = Query(category: categoryString) - - let urlRequest = try NetworkRequest(path: "/v1/article", httpMethod: .get, query: query).makeURLRequest(isLogined: true) - - let (data, _) = try await URLSession.shared.data(for: urlRequest) - - guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CategoryList.self) else { - return .init(articleData: [], week: nil) - } - - return model.toAppData() - } -} +//struct Query: Request { +// let category: String +//} +// +//final class ArticleService: Serviceable { +// static let shared = ArticleService() +// private init() {} +// +// func inquiryTodayArticle() async throws -> TodayArticle { +// let urlRequest = try NetworkRequest(path: "/v1/article/today", httpMethod: .get).makeURLRequest(isLogined: true) +// let (data, _) = try await URLSession.shared.data(for: urlRequest) +// +// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: TodayArticleResponse.self) +// else { return TodayArticle.emptyArticle } +// +// return .init(fetalNickname: model.babyNickname, articleTitle: model.title, articleDescription: model.editorNoteContent, currentWeek: model.week, currentDay: model.day, mainImageURL: model.mainImageUrl, aticleID: model.articleId) +// } +// +// func getArticleDetail(articleId: Int) async throws -> [BlockTypeAppData] { +// let urlRequest = try NetworkRequest(path: "/v1/article/\(articleId)", httpMethod: .get).makeURLRequest(isLogined: true) +// +// let (data, _) = try await URLSession.shared.data(for: urlRequest) +// +// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: ArticleDetail.self) else { +// return [] +// } +// +// return model.toAppData() +// } +// +// func getArticleListByCategory(categoryString: String) async throws -> CurriculumWeekData { +// let query = Query(category: categoryString) +// +// let urlRequest = try NetworkRequest(path: "/v1/article", httpMethod: .get, query: query).makeURLRequest(isLogined: true) +// +// let (data, _) = try await URLSession.shared.data(for: urlRequest) +// +// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CategoryList.self) else { +// return .init(articleData: [], week: nil) +// } +// +// return model.toAppData() +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift index 17b87682..48346f57 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift @@ -9,6 +9,9 @@ import UIKit import SnapKit + + + final class ArticleListByCategoryViewController: UIViewController { private let serviceProcotol: BookmarkOutProtocol diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift index 97ba1eac..c17a2a1e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift @@ -10,8 +10,23 @@ import UIKit import SnapKit +protocol TodayManager { + func inquiryTodayArticle() async throws -> TodayArticle +} + final class TodayViewController: UIViewController { + private let manager: TodayManager + + init(manager: TodayManager) { + self.manager = manager + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + enum TodayArticleImage { static let ratio: CGFloat = 400/335 } @@ -54,7 +69,7 @@ extension TodayViewController { func getInquireTodayArticle() { Task { do { - let responseArticle = try await ArticleService.shared.inquiryTodayArticle() + let responseArticle = try await manager.inquiryTodayArticle() let image = try await LHKingFisherService.fetchImage(with: responseArticle.mainImageURL) mainArticleView.mainArticlImageView.image = image titleLabel.userNickName = responseArticle.fetalNickname From 17af3e1c240303b9843f14dff99664958b7b3f36 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 09:51:44 +0900 Subject: [PATCH 05/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=95=84=ED=8B=B0?= =?UTF-8?q?=ED=81=B4=EC=83=81=EC=84=B8=EB=B7=B0=20DI=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 + .../Network/API/BookmarkAPI.swift | 80 +++++++++---------- .../Manager/ArticleDetailManagerImpl.swift | 29 +++++++ .../Network/Service/BookmarkServiceImpl.swift | 50 ++++++++++++ .../Network/Services/BookmarkService.swift | 58 +++++++------- .../ArticleDetailViewController.swift | 33 ++++---- 6 files changed, 170 insertions(+), 84 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleDetailManagerImpl.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/BookmarkServiceImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 64522286..6fc1683e 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -113,6 +113,7 @@ C0856B652ABFB8640026D9F8 /* TodayManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */; }; C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */; }; C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */; }; + C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -328,6 +329,7 @@ C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayManagerImpl.swift; sourceTree = ""; }; C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleServiceImpl.swift; sourceTree = ""; }; C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailManagerImpl.swift; sourceTree = ""; }; + C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkServiceImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1271,6 +1273,7 @@ isa = PBXGroup; children = ( C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */, + C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */, ); path = Service; sourceTree = ""; @@ -1666,6 +1669,7 @@ 4AD6A34C2AB1AB6700977224 /* BookmarkAPI.swift in Sources */, C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */, B59893192A5D41F600CE1FEB /* KingfisherService.swift in Sources */, + C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */, B59892EE2A5B9AF300CE1FEB /* NavigationBarLayoutManager.swift in Sources */, C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */, C0DF03372A5A93680037F740 /* CALayer+.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift index 8823c42b..ca8abe51 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift @@ -5,43 +5,43 @@ // Created by 황찬미 on 2023/09/13. // -import Foundation - -protocol BookmarkAPIProtocol { - func getBookmark() async throws -> BookmarkResponse? - func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? -} - -final class BookmarkAPI: BookmarkAPIProtocol { - - private let apiService: Requestable - - init(apiService: Requestable) { - self.apiService = apiService - } - - func getBookmark() async throws -> BookmarkResponse? { - let request = try makeGetBookmarkUrlRequest() - return try await apiService.request(request) - } - - func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? { - let request = try makePostBookmakrUrlRequest(model: model) - return try await apiService.request(request) - } -} - - -/// url request method -extension BookmarkAPI { - func makeGetBookmarkUrlRequest() throws -> URLRequest { - return try NetworkRequest(path: "/v1/article/bookmarks", httpMethod: .get).makeURLRequest(isLogined: true) - } - - func makePostBookmakrUrlRequest(model: BookmarkRequest) throws -> URLRequest { - let param = model.toDictionary() - let body = try JSONSerialization.data(withJSONObject: param) - - return try NetworkRequest(path: "/v1/article/bookmark", httpMethod: .post, body: body).makeURLRequest(isLogined: true) - } -} +//import Foundation +// +//protocol BookmarkAPIProtocol { +// func getBookmark() async throws -> BookmarkResponse? +// func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? +//} +// +//final class BookmarkAPI: BookmarkAPIProtocol { +// +// private let apiService: Requestable +// +// init(apiService: Requestable) { +// self.apiService = apiService +// } +// +// func getBookmark() async throws -> BookmarkResponse? { +// let request = try makeGetBookmarkUrlRequest() +// return try await apiService.request(request) +// } +// +// func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? { +// let request = try makePostBookmakrUrlRequest(model: model) +// return try await apiService.request(request) +// } +//} +// +// +///// url request method +//extension BookmarkAPI { +// func makeGetBookmarkUrlRequest() throws -> URLRequest { +// return try NetworkRequest(path: "/v1/article/bookmarks", httpMethod: .get).makeURLRequest(isLogined: true) +// } +// +// func makePostBookmakrUrlRequest(model: BookmarkRequest) throws -> URLRequest { +// let param = model.toDictionary() +// let body = try JSONSerialization.data(withJSONObject: param) +// +// return try NetworkRequest(path: "/v1/article/bookmark", httpMethod: .post, body: body).makeURLRequest(isLogined: true) +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleDetailManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleDetailManagerImpl.swift new file mode 100644 index 00000000..8548675f --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleDetailManagerImpl.swift @@ -0,0 +1,29 @@ +// +// ArticleDetailManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class ArticleDetailManagerImpl: ArticleDetailManager { + + private let articleService: ArticleService + private let bookmarkService: BookmarkOutService + + init(articleService: ArticleService, bookmarkService: BookmarkOutService) { + self.articleService = articleService + self.bookmarkService = bookmarkService + } + + func getArticleDetail(articleId: Int) async throws -> [BlockTypeAppData] { + guard let model = try await articleService.getArticleDetail(articleId: articleId) else { return []} + return model.toAppData() + } + + func postBookmark(model: BookmarkRequest) async throws { + guard let data = try await bookmarkService.postBookmark(model: model) else { throw NetworkError.badCasting } + print(data) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/BookmarkServiceImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/BookmarkServiceImpl.swift new file mode 100644 index 00000000..325364bb --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/BookmarkServiceImpl.swift @@ -0,0 +1,50 @@ +// +// BookmarkServiceImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +protocol BookmarkInOutService { + func getBookmark() async throws -> BookmarkResponse? + func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? +} + +protocol BookmarkOutService { + func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? +} + +typealias BookmarkService = BookmarkInOutService & BookmarkOutService + +final class BookmarkServiceImpl: BookmarkService { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func getBookmark() async throws -> BookmarkResponse? { + let request = try makeGetBookmarkUrlRequest() + return try await apiService.request(request) + } + + func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? { + let request = try makePostBookmakrUrlRequest(model: model) + return try await apiService.request(request) + } +} + +extension BookmarkServiceImpl { + func makeGetBookmarkUrlRequest() throws -> URLRequest { + return try NetworkRequest(path: "/v1/article/bookmarks", httpMethod: .get).makeURLRequest(isLogined: true) + } + + func makePostBookmakrUrlRequest(model: BookmarkRequest) throws -> URLRequest { + let param = model.toDictionary() + let body = try JSONSerialization.data(withJSONObject: param) + return try NetworkRequest(path: "/v1/article/bookmark", httpMethod: .post, body: body).makeURLRequest(isLogined: true) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift index 7817f5d5..8067cd82 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift @@ -7,32 +7,32 @@ import Foundation -/// 내 북마크 -protocol BookmarkInOutServiceProtocol { - func postBookmark(model: BookmarkRequest) async throws - func getBookmark() async throws -> BookmarkAppData -} - -// 동뷰, 성뷰 -protocol BookmarkOutProtocol { - func postBookmark(model: BookmarkRequest) async throws -} - -final class BookmarkService: BookmarkInOutServiceProtocol, BookmarkOutProtocol { - - private let bookmarkAPIProtocol: BookmarkAPIProtocol - - init(bookmarkAPIProtocol: BookmarkAPIProtocol) { - self.bookmarkAPIProtocol = bookmarkAPIProtocol - } - - func postBookmark(model: BookmarkRequest) async throws { - guard let data = try await bookmarkAPIProtocol.postBookmark(model: model) else { return } - print(data) - } - - func getBookmark() async throws -> BookmarkAppData { - guard let data = try await bookmarkAPIProtocol.getBookmark() else { return BookmarkAppData(nickName: "", articleSummaries: [])} - return data.toAppData() - } -} +///// 내 북마크 +//protocol BookmarkInOutServiceProtocol { +// func postBookmark(model: BookmarkRequest) async throws +// func getBookmark() async throws -> BookmarkAppData +//} +// +//// 동뷰, 성뷰 +//protocol BookmarkOutProtocol { +// func postBookmark(model: BookmarkRequest) async throws +//} +// +//final class BookmarkService: BookmarkInOutServiceProtocol, BookmarkOutProtocol { +// +// private let bookmarkAPIProtocol: BookmarkAPIProtocol +// +// init(bookmarkAPIProtocol: BookmarkAPIProtocol) { +// self.bookmarkAPIProtocol = bookmarkAPIProtocol +// } +// +// func postBookmark(model: BookmarkRequest) async throws { +// guard let data = try await bookmarkAPIProtocol.postBookmark(model: model) else { return } +// print(data) +// } +// +// func getBookmark() async throws -> BookmarkAppData { +// guard let data = try await bookmarkAPIProtocol.getBookmark() else { return BookmarkAppData(nickName: "", articleSummaries: [])} +// return data.toAppData() +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift index 1d63310b..de6272a2 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift @@ -10,11 +10,15 @@ import UIKit import SnapKit +protocol ArticleDetailManager { + func getArticleDetail(articleId: Int) async throws -> [BlockTypeAppData] + func postBookmark(model: BookmarkRequest) async throws +} + final class ArticleDetailViewController: UIViewController { // MARK: - UI Components - - private let serviceProtocol: BookmarkOutProtocol + private let manager: ArticleDetailManager private lazy var navigationBar = LHNavigationBarView(type: .articleMain, viewController: self) @@ -33,17 +37,7 @@ final class ArticleDetailViewController: UIViewController { button.isHidden = true return button }() - - init(serviceProtocol: BookmarkOutProtocol) { - self.serviceProtocol = serviceProtocol - /// 이 코드는 왜 있어야 하지? - super.init(nibName: nil, bundle: nil) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - + // MARK: - Properties private var isBookMarked: Bool? { @@ -63,6 +57,15 @@ final class ArticleDetailViewController: UIViewController { private var articleId: Int? private var contentOffsetY: CGFloat = 0 + + init(manager: ArticleDetailManager) { + self.manager = manager + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } public override func viewDidLoad() { super.viewDidLoad() @@ -94,7 +97,7 @@ extension ArticleDetailViewController { Task { do { guard let articleId else { return } - self.articleDatas = try await ArticleService.shared.getArticleDetail(articleId: articleId) + self.articleDatas = try await manager.getArticleDetail(articleId: articleId) } catch { guard let error = error as? NetworkError else { return } handleError(error) @@ -106,7 +109,7 @@ extension ArticleDetailViewController { Task { do { let bookmarkRequest = BookmarkRequest(articleId: articleId, bookmarkRequestStatus: isSelected) - try await serviceProtocol.postBookmark(model: bookmarkRequest) + try await manager.postBookmark(model: bookmarkRequest) isBookMarked = isSelected } catch { From f8d50de12e518f2a639131cb6f0d35375b9918ae Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:02:35 +0900 Subject: [PATCH 06/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 8 ++++ .../DTO/Challenge/ChallengeDataResponse.swift | 6 +++ .../Manager/ChallengeManagerImpl.swift | 22 +++++++++++ .../Service/ChallengeServiceImpl.swift | 26 +++++++++++++ .../Network/Services/ChallengeService.swift | 38 +++++++++---------- .../ChallengeViewController.swift | 21 +++++----- 6 files changed, 92 insertions(+), 29 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/ChallengeManagerImpl.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/ChallengeServiceImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 6fc1683e..1042544b 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -114,6 +114,8 @@ C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */; }; C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */; }; C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */; }; + C0856B6F2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */; }; + C0856B712ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -330,6 +332,8 @@ C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleServiceImpl.swift; sourceTree = ""; }; C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailManagerImpl.swift; sourceTree = ""; }; C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkServiceImpl.swift; sourceTree = ""; }; + C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceImpl.swift; sourceTree = ""; }; + C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeManagerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1265,6 +1269,7 @@ children = ( C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */, C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */, + C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1274,6 +1279,7 @@ children = ( C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */, C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */, + C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */, ); path = Service; sourceTree = ""; @@ -1717,6 +1723,7 @@ C09A33222A62D46300B40770 /* LHToast.swift in Sources */, B53BA2022A68717B006F9BFB /* LoadingIndicator.swift in Sources */, C06E381B2A65346700B00600 /* UserDefaultToken.swift in Sources */, + C0856B6F2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift in Sources */, B5C6A2B82A5DDDFD0021BE5E /* EditorTableViewCell.swift in Sources */, C0F029C72A5EFB9D00E0D185 /* LHProgressView.swift in Sources */, B5C6A2BA2A5DE14E0021BE5E /* ChapterTitleTableViewCell.swift in Sources */, @@ -1754,6 +1761,7 @@ B5C6A2B22A5DB0B10021BE5E /* ArticleDetailTableView.swift in Sources */, B59892E12A5AF39300CE1FEB /* LHNavigationBarView.swift in Sources */, C0F029E62A5FB9E000E0D185 /* ContainerView.swift in Sources */, + C0856B712ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift in Sources */, C0DF03672A5A9C680037F740 /* ArticleDetailViewController.swift in Sources */, 4AE19A1E2A6597E700C1DB7E /* BookmarkRequest.swift in Sources */, ); diff --git a/LionHeart-iOS/LionHeart-iOS/Network/DTO/Challenge/ChallengeDataResponse.swift b/LionHeart-iOS/LionHeart-iOS/Network/DTO/Challenge/ChallengeDataResponse.swift index bd88cea5..c2a1cfb8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/DTO/Challenge/ChallengeDataResponse.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/DTO/Challenge/ChallengeDataResponse.swift @@ -13,3 +13,9 @@ struct ChallengeDataResponse: DTO, Response { let level: String let attendances: [String] } + +extension ChallengeDataResponse { + func toAppData() -> ChallengeData { + return .init(babyDaddyName: self.babyNickname, howLongDay: self.day, daddyLevel: self.level, daddyAttendances: self.attendances) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/ChallengeManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/ChallengeManagerImpl.swift new file mode 100644 index 00000000..4281c39d --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/ChallengeManagerImpl.swift @@ -0,0 +1,22 @@ +// +// ChallengeManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class ChallengeManagerImpl: ChallengeManager { + + private let challengeService: ChallengeService + + init(challengeService: ChallengeService) { + self.challengeService = challengeService + } + + func inquireChallengeInfo() async throws -> ChallengeData { + guard let model = try await challengeService.inquireChallengeInfo() else { return .empty } + return model.toAppData() + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/ChallengeServiceImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/ChallengeServiceImpl.swift new file mode 100644 index 00000000..c5477bab --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/ChallengeServiceImpl.swift @@ -0,0 +1,26 @@ +// +// ChallengeServiceImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +protocol ChallengeService { + func inquireChallengeInfo() async throws -> ChallengeDataResponse? +} + +final class ChallengeServiceImpl: ChallengeService { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func inquireChallengeInfo() async throws -> ChallengeDataResponse? { + let urlRequest = try NetworkRequest(path: "/v1/challenge/progress", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift index 0a1feb91..58da2089 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift @@ -7,22 +7,22 @@ import Foundation -final class ChallengeService: ChallengeServiceProtocol { - - private let challengeAPIService: ChallengeServiceAPIProtocol - - init(challengeAPIService: ChallengeServiceAPIProtocol) { - self.challengeAPIService = challengeAPIService - } - - func inquireChallengeInfo() async throws -> ChallengeData{ - guard let model = try await challengeAPIService.inquireChallengeInfo() else { return ChallengeData.empty } - return toAppData(from: model) - } -} - -extension ChallengeService { - func toAppData(from input: ChallengeDataResponse) -> ChallengeData { - return .init(babyDaddyName: input.babyNickname, howLongDay: input.day, daddyLevel: input.level, daddyAttendances: input.attendances) - } -} +//final class ChallengeService: ChallengeServiceProtocol { +// +// private let challengeAPIService: ChallengeServiceAPIProtocol +// +// init(challengeAPIService: ChallengeServiceAPIProtocol) { +// self.challengeAPIService = challengeAPIService +// } +// +// func inquireChallengeInfo() async throws -> ChallengeData { +// guard let model = try await challengeAPIService.inquireChallengeInfo() else { return ChallengeData.empty } +// return toAppData(from: model) +// } +//} +// +//extension ChallengeService { +// func toAppData(from input: ChallengeDataResponse) -> ChallengeData { +// return .init(babyDaddyName: input.babyNickname, howLongDay: input.day, daddyLevel: input.level, daddyAttendances: input.attendances) +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index 6521b322..9d0a87f8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -49,13 +49,18 @@ enum BadgeLevel: String { } } -protocol ChallengeServiceProtocol { +protocol ChallengeManager { func inquireChallengeInfo() async throws -> ChallengeData } final class ChallengeViewController: UIViewController { - private var challengeService: ChallengeServiceProtocol + private enum Size { + static let cellOffset: CGFloat = 40 + static let numberOfCellsinRow: CGFloat = 0 + } + + private var manager: ChallengeManager var inputData: ChallengeData? { didSet { @@ -65,19 +70,15 @@ final class ChallengeViewController: UIViewController { } } - init(challengeService: ChallengeServiceProtocol) { - self.challengeService = challengeService + init(manager: ChallengeManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - private enum Size { - static let cellOffset: CGFloat = 40 - static let numberOfCellsinRow: CGFloat = 0 - } - + private let leftSeperateLine: UIView = { let view = UIView() view.backgroundColor = .designSystem(.background) @@ -143,7 +144,7 @@ final class ChallengeViewController: UIViewController { Task { do { self.showLoading() - let model = try await challengeService.inquireChallengeInfo() + let model = try await manager.inquireChallengeInfo() self.inputData = model self.tags = model.daddyAttendances self.challengeDayCheckCollectionView.reloadData() From 1f6f6e5fbdc876319384d0573c47e3fc6b880717 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:12:10 +0900 Subject: [PATCH 07/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EB=B6=81=EB=A7=88?= =?UTF-8?q?=ED=81=AC=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 +++ .../Network/Manager/BookmarkMangerImpl.swift | 27 +++++++++++++++++++ .../Scenes/BookMark/Model/BookmarkModel.swift | 6 +++++ .../BookmarkViewController.swift | 18 ++++++++----- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/BookmarkMangerImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 1042544b..50f8a7e4 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -116,6 +116,7 @@ C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */; }; C0856B6F2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */; }; C0856B712ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */; }; + C0856B732ABFC3070026D9F8 /* BookmarkMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -334,6 +335,7 @@ C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkServiceImpl.swift; sourceTree = ""; }; C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceImpl.swift; sourceTree = ""; }; C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeManagerImpl.swift; sourceTree = ""; }; + C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkMangerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1270,6 +1272,7 @@ C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */, C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */, C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */, + C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1735,6 +1738,7 @@ D3BA0B712A5CFA2300B6361F /* ArticleCategoryCollectionViewCell.swift in Sources */, B532E8342A5525C600F0DB19 /* SceneDelegate.swift in Sources */, C0F029CD2A5F8D2F00E0D185 /* UIPageViewController+.swift in Sources */, + C0856B732ABFC3070026D9F8 /* BookmarkMangerImpl.swift in Sources */, B57BEB632A612DA100D1727C /* UserDefaultsManager.swift in Sources */, C0DF037B2A5A9CF30037F740 /* OnboardingViewController.swift in Sources */, C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/BookmarkMangerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/BookmarkMangerImpl.swift new file mode 100644 index 00000000..b301afdd --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/BookmarkMangerImpl.swift @@ -0,0 +1,27 @@ +// +// BookmarkMangerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class BookmarkMangerImpl: BookmarkManger { + + private let bookmarkService: BookmarkService + + init(bookmarkService: BookmarkService) { + self.bookmarkService = bookmarkService + } + + func getBookmark() async throws -> BookmarkAppData { + guard let model = try await bookmarkService.getBookmark() else { return .empty } + return model.toAppData() + } + + func postBookmark(model: BookmarkRequest) async throws { + guard let data = try await bookmarkService.postBookmark(model: model) else { throw NetworkError.badCasting } + print(data) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Model/BookmarkModel.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Model/BookmarkModel.swift index 21691e6b..1e4ec572 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Model/BookmarkModel.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Model/BookmarkModel.swift @@ -12,6 +12,12 @@ struct BookmarkAppData: AppData { let articleSummaries: [ArticleSummaries] } +extension BookmarkAppData { + static var empty: Self { + return .init(nickName: "", articleSummaries: []) + } +} + struct ArticleSummaries: AppData { let title: String let articleID: Int diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift index a23a25b3..a14b8ec9 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift @@ -10,9 +10,14 @@ import UIKit import SnapKit +protocol BookmarkManger { + func getBookmark() async throws -> BookmarkAppData + func postBookmark(model: BookmarkRequest) async throws +} + final class BookmarkViewController: UIViewController { - private let serviceProtocol: BookmarkInOutServiceProtocol + private let manager: BookmarkManger private var bookmarkAppData = BookmarkAppData(nickName: "", articleSummaries: [ArticleSummaries]()) private var bookmarkList = [ArticleSummaries]() @@ -26,12 +31,11 @@ final class BookmarkViewController: UIViewController { return collectionView }() - init(serviceProtocol: BookmarkInOutServiceProtocol) { - self.serviceProtocol = serviceProtocol - + init(manager: BookmarkManger) { + self.manager = manager super.init(nibName: nil, bundle: nil) } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -51,7 +55,7 @@ final class BookmarkViewController: UIViewController { showLoading() Task { do { - self.bookmarkAppData = try await serviceProtocol.getBookmark() + self.bookmarkAppData = try await manager.getBookmark() self.bookmarkList = bookmarkAppData.articleSummaries hideLoading() bookmarkCollectionView.reloadData() @@ -158,7 +162,7 @@ extension BookmarkViewController: UICollectionViewDataSource { cell.bookmarkButtonClosure = { indexPath in Task { do { - try await self.serviceProtocol.postBookmark(model: BookmarkRequest(articleId: self.bookmarkList[indexPath.item].articleID, + try await self.manager.postBookmark(model: BookmarkRequest(articleId: self.bookmarkList[indexPath.item].articleID, bookmarkRequestStatus: !self.bookmarkList[indexPath.item].bookmarked)) self.bookmarkList.remove(at: indexPath.item) collectionView.deleteItems(at: [indexPath]) From 03134c7fe0dc79885b957c00203e8d571d4fab5c Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:27:01 +0900 Subject: [PATCH 08/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 12 ++ .../Network/Manager/MyPageManagerImpl.swift | 32 ++++++ .../Network/Service/AuthServiceImpl.swift | 103 ++++++++++++++++++ .../Network/Service/MyPageServiceImpl.swift | 26 +++++ .../MyPageViewController.swift | 14 +-- 5 files changed, 180 insertions(+), 7 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/MyPageManagerImpl.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/AuthServiceImpl.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/MyPageServiceImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 50f8a7e4..b93375f3 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -117,6 +117,9 @@ C0856B6F2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */; }; C0856B712ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */; }; C0856B732ABFC3070026D9F8 /* BookmarkMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */; }; + C0856B752ABFC4CB0026D9F8 /* MyPageManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */; }; + C0856B772ABFC4EA0026D9F8 /* MyPageServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */; }; + C0856B792ABFC56E0026D9F8 /* AuthServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -336,6 +339,9 @@ C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceImpl.swift; sourceTree = ""; }; C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeManagerImpl.swift; sourceTree = ""; }; C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkMangerImpl.swift; sourceTree = ""; }; + C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageManagerImpl.swift; sourceTree = ""; }; + C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageServiceImpl.swift; sourceTree = ""; }; + C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthServiceImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1273,6 +1279,7 @@ C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */, C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */, C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */, + C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1283,6 +1290,8 @@ C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */, C0856B6C2ABFBD840026D9F8 /* BookmarkServiceImpl.swift */, C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */, + C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */, + C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */, ); path = Service; sourceTree = ""; @@ -1707,6 +1716,7 @@ C0F029DE2A5FAC6100E0D185 /* LHOnboardingTitleLabel.swift in Sources */, F435E04C2A5DA6A40098E691 /* CurriculumUserInfoView.swift in Sources */, 4A8980C72A6146DA00746C58 /* MyPageCustomerServiceCollectionViewCell.swift in Sources */, + C0856B752ABFC4CB0026D9F8 /* MyPageManagerImpl.swift in Sources */, C0DF03752A5A9CD00037F740 /* TabBarViewController.swift in Sources */, C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */, C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */, @@ -1731,9 +1741,11 @@ C0F029C72A5EFB9D00E0D185 /* LHProgressView.swift in Sources */, B5C6A2BA2A5DE14E0021BE5E /* ChapterTitleTableViewCell.swift in Sources */, C0DF034D2A5A9B8D0037F740 /* (null) in Sources */, + C0856B772ABFC4EA0026D9F8 /* MyPageServiceImpl.swift in Sources */, C0DF03982A5B90790037F740 /* UIColor+.swift in Sources */, C0F029E02A5FAD1200E0D185 /* LHOnboardingDescriptionLabel.swift in Sources */, C0DF03492A5A9ACB0037F740 /* DummyModel.swift in Sources */, + C0856B792ABFC56E0026D9F8 /* AuthServiceImpl.swift in Sources */, C09217732A61895A00231C66 /* UIWindow+.swift in Sources */, D3BA0B712A5CFA2300B6361F /* ArticleCategoryCollectionViewCell.swift in Sources */, B532E8342A5525C600F0DB19 /* SceneDelegate.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/MyPageManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/MyPageManagerImpl.swift new file mode 100644 index 00000000..d3fc9680 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/MyPageManagerImpl.swift @@ -0,0 +1,32 @@ +// +// MyPageManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class MyPageManagerImpl: MyPageManager { + + private let mypageService: MypageService + private let authService: AuthUserOutService + + init(mypageService: MypageService, authService: AuthUserOutService) { + self.mypageService = mypageService + self.authService = authService + } + + func getMyPage() async throws -> MyPageAppData { + guard let model = try await mypageService.getMyPage() else { throw NetworkError.badCasting } + return MyPageAppData(badgeImage: model.level, nickname: model.babyNickname, isAlarm: model.notificationStatus) + } + + func resignUser() async throws { + try await authService.resignUser() + } + + func logout(token: UserDefaultToken) async throws { + try await authService.logout(token: token) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/AuthServiceImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/AuthServiceImpl.swift new file mode 100644 index 00000000..1c4e2846 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/AuthServiceImpl.swift @@ -0,0 +1,103 @@ +// +// AuthServiceImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +import Foundation + +protocol AuthUserInService { + func reissueToken(token: Token) async throws -> Token? + func login(type: LoginType, kakaoToken: String) async throws + func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws +} + +protocol AuthUserOutService { + @discardableResult func logout(token: UserDefaultToken) async throws -> String? + func resignUser() async throws +} + +typealias AuthService = AuthUserInService & AuthUserOutService + +final class AuthServiceImpl: AuthService { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func reissueToken(token: Token) async throws -> Token? { + let urlRequest = try makeReissueTokenUrlRequest(token: token) + return try await apiService.request(urlRequest) + } + + func login(type: LoginType, kakaoToken: String) async throws { + let urlRequest = try makeLoginUrlRequest(type: type, kakaoToken: kakaoToken) + userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) + } + + func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { + let urlRequest = try makeSignUpUrlRequest(type: type, onboardingModel: onboardingModel) + userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) + } + + func logout(token: UserDefaultToken) async throws -> String? { + let urlRequest = try makeLogoutUrlRequest() + return try await apiService.request(urlRequest) + } + + func resignUser() async throws { + let urlRequest = try makeResignUserUrlRequest() + _ = try await URLSession.shared.data(for: urlRequest) + UserDefaultsManager.tokenKey?.refreshToken = nil + } +} + +extension AuthServiceImpl { + private func userdefaultsSettingWhenUserIn(model: Token?) { + UserDefaultsManager.tokenKey?.accessToken = model?.accessToken + UserDefaultsManager.tokenKey?.refreshToken = model?.refreshToken + } +} + +extension AuthServiceImpl { + func makeResignUserUrlRequest() throws -> URLRequest { + return try NetworkRequest(path: "/v1/member", httpMethod: .delete).makeURLRequest(isLogined: true) + } + + func makeLogoutUrlRequest() throws -> URLRequest { + return try NetworkRequest(path: "/v1/auth/logout", httpMethod: .post).makeURLRequest(isLogined: true) + } + + func makeSignUpUrlRequest(type: LoginType, onboardingModel: UserOnboardingModel) throws -> URLRequest { + guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken, + let kakaoToken = onboardingModel.kakaoAccessToken, + let pregnantWeeks = onboardingModel.pregnacny, + let babyNickname = onboardingModel.fetalNickname else { throw NetworkError.badCasting } + let requestModel = SignUpRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken, pregnantWeeks: pregnantWeeks, babyNickname: babyNickname) + let param = requestModel.toDictionary() + let body = try JSONSerialization.data(withJSONObject: param) + return try NetworkRequest(path: "/v1/auth/signup", httpMethod: .post, body: body).makeURLRequest(isLogined: false) + } + + func makeReissueTokenUrlRequest(token: Token) throws -> URLRequest { + let params = token.toDictionary() + let body = try JSONSerialization.data(withJSONObject: params, options: []) + return try NetworkRequest(path: "/v1/auth/reissue", httpMethod: .post, body: body) + .makeURLRequest(isLogined: false) + } + + func makeLoginUrlRequest(type: LoginType, kakaoToken: String) throws -> URLRequest { + guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken else { + throw NetworkError.clientError(code: "", message: "\(String(describing: UserDefaultsManager.tokenKey))") + } + let loginRequest = LoginRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken) + let param = loginRequest.toDictionary() + let body = try JSONSerialization.data(withJSONObject: param) + return try NetworkRequest(path: "/v1/auth/login", httpMethod: .post, body: body).makeURLRequest(isLogined: false) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/MyPageServiceImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/MyPageServiceImpl.swift new file mode 100644 index 00000000..93bedf3f --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/MyPageServiceImpl.swift @@ -0,0 +1,26 @@ +// +// MyPageServiceImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +protocol MypageService { + func getMyPage() async throws -> MyPageResponse? +} + +final class MyPageServiceImpl: MypageService { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func getMyPage() async throws -> MyPageResponse? { + let urlRequest = try NetworkRequest(path: "/v1/member/profile", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift index c1d619bb..da4323e1 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift @@ -10,7 +10,7 @@ import UIKit import SnapKit -protocol MyPageServiceProtocol: AnyObject { +protocol MyPageManager { func getMyPage() async throws -> MyPageAppData func resignUser() async throws func logout(token: UserDefaultToken) async throws @@ -30,7 +30,7 @@ final class MyPageViewController: UIViewController { } } - private let service: MyPageServiceProtocol + private let manager: MyPageManager // MARK: - UI Components @@ -49,11 +49,11 @@ final class MyPageViewController: UIViewController { return button }() - init(service: MyPageServiceProtocol) { - self.service = service + init(manager: MyPageManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -76,7 +76,7 @@ final class MyPageViewController: UIViewController { Task { do { - let data = try await service.getMyPage() + let data = try await manager.getMyPage() myPageAppData = data } catch { guard let error = error as? NetworkError else { return } @@ -125,7 +125,7 @@ private extension MyPageViewController { do { guard let window = self.view.window else { return } self.resignButton.isUserInteractionEnabled = false - try await self.service.resignUser() + try await self.manager.resignUser() ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) } catch { print(error) From bbe1c0bcfebd080986ff1a301ad1f615a282b88e Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:34:54 +0900 Subject: [PATCH 09/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=8A=A4=ED=94=8C?= =?UTF-8?q?=EB=9E=98=EC=8B=9C=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 +++ .../Network/Manager/SplashManagerImpl.swift | 25 +++++++++++++++++++ .../Scenes/Splash/SplashViewController.swift | 20 +++++---------- 3 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/SplashManagerImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index b93375f3..a2bc826b 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -120,6 +120,7 @@ C0856B752ABFC4CB0026D9F8 /* MyPageManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */; }; C0856B772ABFC4EA0026D9F8 /* MyPageServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */; }; C0856B792ABFC56E0026D9F8 /* AuthServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */; }; + C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -342,6 +343,7 @@ C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageManagerImpl.swift; sourceTree = ""; }; C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageServiceImpl.swift; sourceTree = ""; }; C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthServiceImpl.swift; sourceTree = ""; }; + C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashManagerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1280,6 +1282,7 @@ C0856B702ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift */, C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */, C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */, + C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1646,6 +1649,7 @@ D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */, B57BEB652A6134B800D1727C /* setRootViewController.swift in Sources */, B5C6A2C22A5DEA1B0021BE5E /* CopyRightTableViewCell.swift in Sources */, + C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */, B59892E52A5B109900CE1FEB /* ScreenUtils.swift in Sources */, C0F029E82A5FB9EF00E0D185 /* RoundContainerView.swift in Sources */, B532E8652A5529F100F0DB19 /* BaseResponse.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/SplashManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/SplashManagerImpl.swift new file mode 100644 index 00000000..c4aac6da --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/SplashManagerImpl.swift @@ -0,0 +1,25 @@ +// +// SplashManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class SplashManagerImpl: SplashManager { + + private let authService: AuthService + + init(authService: AuthService) { + self.authService = authService + } + + func reissueToken(token: Token) async throws -> Token? { + return try await authService.reissueToken(token: token) + } + + func logout(token: UserDefaultToken) async throws { + try await authService.logout(token: token) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift index bc5c82e4..d0d16b6e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift @@ -11,19 +11,11 @@ import UIKit import SnapKit import Lottie -protocol UserInProtocol { +protocol SplashManager { func reissueToken(token: Token) async throws -> Token? - func login(type: LoginType, kakaoToken: String) async throws - func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws -} - -protocol UserOutProtocol { - func resignUser() async throws func logout(token: UserDefaultToken) async throws } -protocol AuthServiceProtocol: UserInProtocol, UserOutProtocol {} - final class SplashViewController: UIViewController { // MARK: - UI Components @@ -36,12 +28,12 @@ final class SplashViewController: UIViewController { // MARK: - Properties - private let authService: AuthServiceProtocol + private let manager: SplashManager // MARK: - Life Cycle - init(authService: AuthServiceProtocol) { - self.authService = authService + init(manager: SplashManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } @@ -111,7 +103,7 @@ private extension SplashViewController { func reissueToken(refreshToken: String, accessToken: String) async throws { do { - let dtoToken = try await authService.reissueToken(token: Token(accessToken: accessToken, refreshToken: refreshToken)) + let dtoToken = try await manager.reissueToken(token: Token(accessToken: accessToken, refreshToken: refreshToken)) UserDefaultsManager.tokenKey?.accessToken = dtoToken?.accessToken UserDefaultsManager.tokenKey?.refreshToken = dtoToken?.refreshToken @@ -125,7 +117,7 @@ private extension SplashViewController { func logout(token: UserDefaultToken) async { do { - try await authService.logout(token: token) + try await manager.logout(token: token) } catch { print(error) } From 6a5220bdb92f843bac829a11de3e92c24591669a Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:38:04 +0900 Subject: [PATCH 10/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 ++++ .../Network/Manager/LoginMangerImpl.swift | 21 +++++++++++++++++++ .../Scenes/Login/LoginViewController.swift | 12 +++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/LoginMangerImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index a2bc826b..c6aaf96c 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -121,6 +121,7 @@ C0856B772ABFC4EA0026D9F8 /* MyPageServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */; }; C0856B792ABFC56E0026D9F8 /* AuthServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */; }; C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */; }; + C0856B7D2ABFCA330026D9F8 /* LoginMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -344,6 +345,7 @@ C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageServiceImpl.swift; sourceTree = ""; }; C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthServiceImpl.swift; sourceTree = ""; }; C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashManagerImpl.swift; sourceTree = ""; }; + C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginMangerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1283,6 +1285,7 @@ C0856B722ABFC3070026D9F8 /* BookmarkMangerImpl.swift */, C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */, C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */, + C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1718,6 +1721,7 @@ B51220642A6039AA006CBE2D /* HttpMethod.swift in Sources */, B532E8322A5525C600F0DB19 /* AppDelegate.swift in Sources */, C0F029DE2A5FAC6100E0D185 /* LHOnboardingTitleLabel.swift in Sources */, + C0856B7D2ABFCA330026D9F8 /* LoginMangerImpl.swift in Sources */, F435E04C2A5DA6A40098E691 /* CurriculumUserInfoView.swift in Sources */, 4A8980C72A6146DA00746C58 /* MyPageCustomerServiceCollectionViewCell.swift in Sources */, C0856B752ABFC4CB0026D9F8 /* MyPageManagerImpl.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/LoginMangerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/LoginMangerImpl.swift new file mode 100644 index 00000000..2c70db34 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/LoginMangerImpl.swift @@ -0,0 +1,21 @@ +// +// LoginMangerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class LoginMangerImpl: LoginManager { + + private let authService: AuthUserInService + + init(authService: AuthUserInService) { + self.authService = authService + } + + func login(type: LoginType, kakaoToken: String) async throws { + try await authService.login(type: type, kakaoToken: kakaoToken) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift index d51e93ae..de813329 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift @@ -13,6 +13,10 @@ import SnapKit import KakaoSDKAuth import KakaoSDKUser +protocol LoginManager { + func login(type: LoginType, kakaoToken: String) async throws +} + final class LoginViewController: UIViewController { private var kakaoAccessToken: String? { @@ -25,7 +29,7 @@ final class LoginViewController: UIViewController { } } - private let authService: AuthServiceProtocol + private let manager: LoginManager private let loginMainImageView: UIImageView = { let imageView = UIImageView(image: ImageLiterals.Login.loginBackgroundImage) @@ -60,8 +64,8 @@ final class LoginViewController: UIViewController { return button }() - init(authService: AuthServiceProtocol) { - self.authService = authService + init(manager: LoginManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } @@ -99,7 +103,7 @@ extension LoginViewController { private func loginAPI(kakaoToken: String) { Task { do { - try await authService.login(type: .kakao, kakaoToken: kakaoToken) + try await manager.login(type: .kakao, kakaoToken: kakaoToken) guard let window = self.view.window else { LHToast.show(message: "로그인api에서 window guard let 88") return From 30d3f8fa084f7527ccd35d78c6b6d390213f6e16 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:47:58 +0900 Subject: [PATCH 11/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=95=84=ED=8B=B0?= =?UTF-8?q?=ED=81=B4=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=EB=B7=B0=20DI?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 +++ .../ArticleListByCategoryMangerImpl.swift | 29 +++++++++++++++ .../ArticleListByCategoryViewController.swift | 36 +++++-------------- 3 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleListByCategoryMangerImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index c6aaf96c..5d60bed2 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -122,6 +122,7 @@ C0856B792ABFC56E0026D9F8 /* AuthServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */; }; C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */; }; C0856B7D2ABFCA330026D9F8 /* LoginMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */; }; + C0856B7F2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -346,6 +347,7 @@ C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthServiceImpl.swift; sourceTree = ""; }; C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashManagerImpl.swift; sourceTree = ""; }; C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginMangerImpl.swift; sourceTree = ""; }; + C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryMangerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1286,6 +1288,7 @@ C0856B742ABFC4CB0026D9F8 /* MyPageManagerImpl.swift */, C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */, C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */, + C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1743,6 +1746,7 @@ C0DF034D2A5A9B8D0037F740 /* (null) in Sources */, C09A33222A62D46300B40770 /* LHToast.swift in Sources */, B53BA2022A68717B006F9BFB /* LoadingIndicator.swift in Sources */, + C0856B7F2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift in Sources */, C06E381B2A65346700B00600 /* UserDefaultToken.swift in Sources */, C0856B6F2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift in Sources */, B5C6A2B82A5DDDFD0021BE5E /* EditorTableViewCell.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleListByCategoryMangerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleListByCategoryMangerImpl.swift new file mode 100644 index 00000000..446662bd --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/ArticleListByCategoryMangerImpl.swift @@ -0,0 +1,29 @@ +// +// ArticleListByCategoryMangerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class ArticleListByCategoryMangerImpl: ArticleListByCategoryManager { + + private let articleService: ArticleService + private let bookmarkService: BookmarkOutService + + init(articleService: ArticleService, bookmarkService: BookmarkOutService) { + self.articleService = articleService + self.bookmarkService = bookmarkService + } + + func getArticleListByCategory(categoryString: String) async throws -> CurriculumWeekData { + guard let model = try await articleService.getArticleListByCategory(categoryString: categoryString) else { throw NetworkError.badCasting } + return model.toAppData() + } + + func postBookmark(model: BookmarkRequest) async throws { + guard let data = try await bookmarkService.postBookmark(model: model) else { throw NetworkError.badCasting } + print(data) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift index 48346f57..51735a0b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift @@ -10,11 +10,15 @@ import UIKit import SnapKit +protocol ArticleListByCategoryManager { + func getArticleListByCategory(categoryString: String) async throws -> CurriculumWeekData + func postBookmark(model: BookmarkRequest) async throws +} final class ArticleListByCategoryViewController: UIViewController { - private let serviceProcotol: BookmarkOutProtocol + private let manager: ArticleListByCategoryManager var categoryString = String() var articleListData: [ArticleDataByWeek] = [] { @@ -39,9 +43,8 @@ final class ArticleListByCategoryViewController: UIViewController { return tableView }() - init(serviceProcotol: BookmarkOutProtocol) { - self.serviceProcotol = serviceProcotol - + init(manager: ArticleListByCategoryManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } @@ -56,7 +59,6 @@ final class ArticleListByCategoryViewController: UIViewController { setLayout() setDelegate() setTableView() - setNotificationCenter() } override func viewWillAppear(_ animated: Bool) { @@ -64,7 +66,7 @@ final class ArticleListByCategoryViewController: UIViewController { showLoading() Task { do { - self.articleListData = try await ArticleService.shared.getArticleListByCategory(categoryString: categoryString).articleData + self.articleListData = try await manager.getArticleListByCategory(categoryString: categoryString).articleData self.articleListTableView.reloadData() hideLoading() } catch { @@ -105,26 +107,6 @@ private extension ArticleListByCategoryViewController { func setTableView() { CurriculumArticleByWeekTableViewCell.register(to: articleListTableView) } - - func setNotificationCenter() { -// NotificationCenter.default.addObserver(self, selector: #selector(bookmarkButtonTapped), name: NSNotification.Name("isArticleBookmarked"), object: nil) - } - -// @objc func bookmarkButtonTapped(notification: NSNotification) { -// Task { -// do { -// guard let indexPath = notification.userInfo?["bookmarkCellIndexPath"] as? Int else { return } -// guard let buttonSelected = notification.userInfo?["bookmarkButtonSelected"] as? Bool else { return } -// -// try await BookmarkService.shared.postBookmark(BookmarkRequest(articleId: articleListData[indexPath+1].articleId, -// bookmarkStatus: buttonSelected)) -// buttonSelected ? LHToast.show(message: "북마크에 추가되었습니다", isTabBar: true) : LHToast.show(message: "북마크에 해제되었습니다", isTabBar: true) -// } catch { -// guard let error = error as? NetworkError else { return } -// handleError(error) -// } -// } -// } } extension ArticleListByCategoryViewController: ViewControllerServiceable { @@ -163,7 +145,7 @@ extension ArticleListByCategoryViewController: UITableViewDataSource { Task { do { - try await self.serviceProcotol.postBookmark(model: BookmarkRequest(articleId: self.articleListData[indexPath.row].articleId, + try await self.manager.postBookmark(model: BookmarkRequest(articleId: self.articleListData[indexPath.row].articleId, bookmarkRequestStatus: isSelected)) print(self.articleListData[indexPath.row].articleId) isSelected ? LHToast.show(message: "북마크에 추가되었습니다", isTabBar: true) : LHToast.show(message: "북마크에 해제되었습니다", isTabBar: true) From 34eafb79417af8fa7c4cb12feb308008e80b654e Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 10:52:46 +0900 Subject: [PATCH 12/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=98=A8=EB=B3=B4?= =?UTF-8?q?=EB=94=A9=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 ++++ .../Manager/OnboardingManagerImpl.swift | 21 +++++++++++++++++++ .../OnboardingViewController.swift | 12 +++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/OnboardingManagerImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 5d60bed2..1af92218 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -123,6 +123,7 @@ C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */; }; C0856B7D2ABFCA330026D9F8 /* LoginMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */; }; C0856B7F2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */; }; + C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -348,6 +349,7 @@ C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashManagerImpl.swift; sourceTree = ""; }; C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginMangerImpl.swift; sourceTree = ""; }; C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryMangerImpl.swift; sourceTree = ""; }; + C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingManagerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1289,6 +1291,7 @@ C0856B7A2ABFC9640026D9F8 /* SplashManagerImpl.swift */, C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */, C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */, + C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1731,6 +1734,7 @@ C0DF03752A5A9CD00037F740 /* TabBarViewController.swift in Sources */, C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */, C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */, + C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */, B57BEB6C2A6149AD00D1727C /* NetworkRequest.swift in Sources */, C0DF03552A5A9BD60037F740 /* ArticleListByCategoryView.swift in Sources */, F4DB30B42A61250500413EB9 /* CurriculumListByWeekCollectionViewCell.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/OnboardingManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/OnboardingManagerImpl.swift new file mode 100644 index 00000000..5a51d44a --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/OnboardingManagerImpl.swift @@ -0,0 +1,21 @@ +// +// OnboardingManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class OnboardingManagerImpl: OnboardingManager { + + private let authService: AuthUserInService + + init(authService: AuthUserInService) { + self.authService = authService + } + + func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { + try await authService.signUp(type: type, onboardingModel: onboardingModel) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift index 0dcb76ac..b8f8666f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift @@ -10,11 +10,15 @@ import UIKit import SnapKit +protocol OnboardingManager { + func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws +} + final class OnboardingViewController: UIViewController { typealias OnboardingViews = [UIViewController] - private let authService: AuthServiceProtocol + private let manager: OnboardingManager /// passing data property private var fetalNickName: String? @@ -50,8 +54,8 @@ final class OnboardingViewController: UIViewController { } } - init(authService: AuthServiceProtocol) { - self.authService = authService + init(manager: OnboardingManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } @@ -181,7 +185,7 @@ private extension OnboardingViewController { Task { showLoading() do { - try await authService.signUp(type: .kakao, onboardingModel: passingData) + try await manager.signUp(type: .kakao, onboardingModel: passingData) hideLoading() self.navigationController?.pushViewController(completeViewController, animated: true) From d9a90bb739f8844cb8b7208152bd55d1aad7d999 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:08:05 +0900 Subject: [PATCH 13/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BB=A4=EB=A6=AC?= =?UTF-8?q?=ED=81=98=EB=9F=BC=EB=B7=B0=20DI=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 52 +++---------------- .../Manager/CurriculumManagerImpl.swift | 22 ++++++++ .../Service/CurriculumServiceImpl.swift | 32 ++++++++++++ .../Services/CurriculumViewService.swift | 52 +++++++++---------- .../CurriculumViewController.swift | 17 +++++- 5 files changed, 104 insertions(+), 71 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumManagerImpl.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/CurriculumServiceImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 1af92218..e7fbc3d8 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -124,6 +124,8 @@ C0856B7D2ABFCA330026D9F8 /* LoginMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */; }; C0856B7F2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */; }; C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */; }; + C0856B832ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */; }; + C0856B852ABFD0F50026D9F8 /* CurriculumManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -154,9 +156,6 @@ C0DF03552A5A9BD60037F740 /* ArticleListByCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03542A5A9BD60037F740 /* ArticleListByCategoryView.swift */; }; C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */; }; C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */; }; - C0DF035D2A5A9C260037F740 /* ArticleListByWeekTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF035C2A5A9C260037F740 /* ArticleListByWeekTableViewCell.swift */; }; - C0DF035F2A5A9C330037F740 /* ArticleListByWeekViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF035E2A5A9C330037F740 /* ArticleListByWeekViewController.swift */; }; - C0DF03612A5A9C400037F740 /* ArticleListByWeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03602A5A9C400037F740 /* ArticleListByWeekView.swift */; }; C0DF03652A5A9C610037F740 /* ArticleDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */; }; C0DF03672A5A9C680037F740 /* ArticleDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03662A5A9C680037F740 /* ArticleDetailViewController.swift */; }; C0DF036B2A5A9C930037F740 /* BookMarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036A2A5A9C930037F740 /* BookMarkView.swift */; }; @@ -350,6 +349,8 @@ C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginMangerImpl.swift; sourceTree = ""; }; C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryMangerImpl.swift; sourceTree = ""; }; C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingManagerImpl.swift; sourceTree = ""; }; + C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumServiceImpl.swift; sourceTree = ""; }; + C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumManagerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -378,9 +379,6 @@ C0DF03542A5A9BD60037F740 /* ArticleListByCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryView.swift; sourceTree = ""; }; C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewController.swift; sourceTree = ""; }; C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryView.swift; sourceTree = ""; }; - C0DF035C2A5A9C260037F740 /* ArticleListByWeekTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByWeekTableViewCell.swift; sourceTree = ""; }; - C0DF035E2A5A9C330037F740 /* ArticleListByWeekViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByWeekViewController.swift; sourceTree = ""; }; - C0DF03602A5A9C400037F740 /* ArticleListByWeekView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByWeekView.swift; sourceTree = ""; }; C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailView.swift; sourceTree = ""; }; C0DF03662A5A9C680037F740 /* ArticleDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailViewController.swift; sourceTree = ""; }; C0DF036A2A5A9C930037F740 /* BookMarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookMarkView.swift; sourceTree = ""; }; @@ -859,7 +857,6 @@ children = ( B598920C2A56B3B700CE1FEB /* ArticleListByCategory */, B59892102A56B47C00CE1FEB /* ArticleCategory */, - B598920D2A56B3E900CE1FEB /* ArticleListByWeek */, B598920B2A56B3A300CE1FEB /* ArticleDetail */, ); path = Article; @@ -886,16 +883,6 @@ path = ArticleListByCategory; sourceTree = ""; }; - B598920D2A56B3E900CE1FEB /* ArticleListByWeek */ = { - isa = PBXGroup; - children = ( - B59892282A56B6AF00CE1FEB /* Cells */, - B59892272A56B6AA00CE1FEB /* ViewControllers */, - B59892262A56B6A500CE1FEB /* Views */, - ); - path = ArticleListByWeek; - sourceTree = ""; - }; B598920E2A56B41500CE1FEB /* MyPage */ = { isa = PBXGroup; children = ( @@ -970,30 +957,6 @@ path = ViewControllers; sourceTree = ""; }; - B59892262A56B6A500CE1FEB /* Views */ = { - isa = PBXGroup; - children = ( - C0DF03602A5A9C400037F740 /* ArticleListByWeekView.swift */, - ); - path = Views; - sourceTree = ""; - }; - B59892272A56B6AA00CE1FEB /* ViewControllers */ = { - isa = PBXGroup; - children = ( - C0DF035E2A5A9C330037F740 /* ArticleListByWeekViewController.swift */, - ); - path = ViewControllers; - sourceTree = ""; - }; - B59892282A56B6AF00CE1FEB /* Cells */ = { - isa = PBXGroup; - children = ( - C0DF035C2A5A9C260037F740 /* ArticleListByWeekTableViewCell.swift */, - ); - path = Cells; - sourceTree = ""; - }; B59892292A56B6BA00CE1FEB /* ViewControllers */ = { isa = PBXGroup; children = ( @@ -1292,6 +1255,7 @@ C0856B7C2ABFCA330026D9F8 /* LoginMangerImpl.swift */, C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */, C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */, + C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1304,6 +1268,7 @@ C0856B6E2ABFBFF00026D9F8 /* ChallengeServiceImpl.swift */, C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */, C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */, + C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */, ); path = Service; sourceTree = ""; @@ -1674,7 +1639,6 @@ 4AE19A1A2A65886100C1DB7E /* BookmarkReponse.swift in Sources */, B5F323E92A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift in Sources */, C0DF039F2A5CABC10037F740 /* GetPregnancyViewController.swift in Sources */, - C0DF035F2A5A9C330037F740 /* ArticleListByWeekViewController.swift in Sources */, F4DB30BC2A61691F00413EB9 /* CurriculumArticleByWeekRowZeroTableViewCell.swift in Sources */, C0DF039A2A5B908E0037F740 /* CGColor+.swift in Sources */, 4AD216402A69AC1E00C9F2F2 /* MyPageResponse.swift in Sources */, @@ -1703,8 +1667,10 @@ C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */, B59892EE2A5B9AF300CE1FEB /* NavigationBarLayoutManager.swift in Sources */, C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */, + C0856B832ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift in Sources */, C0DF03372A5A93680037F740 /* CALayer+.swift in Sources */, C0DF03A12A5CAC220037F740 /* GetFetalNicknameViewController.swift in Sources */, + C0856B852ABFD0F50026D9F8 /* CurriculumManagerImpl.swift in Sources */, C0F029EA2A5FD32900E0D185 /* LHRoundButton.swift in Sources */, C0DF03812A5AF51C0037F740 /* Constant.swift in Sources */, B59892942A57A93300CE1FEB /* Config.swift in Sources */, @@ -1722,7 +1688,6 @@ C0F029D12A5FA87900E0D185 /* Float+.swift in Sources */, C0DF036B2A5A9C930037F740 /* BookMarkView.swift in Sources */, B532E86C2A5564DD00F0DB19 /* Encodable+.swift in Sources */, - C0DF03612A5A9C400037F740 /* ArticleListByWeekView.swift in Sources */, C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */, B51220642A6039AA006CBE2D /* HttpMethod.swift in Sources */, B532E8322A5525C600F0DB19 /* AppDelegate.swift in Sources */, @@ -1771,7 +1736,6 @@ C0DF037B2A5A9CF30037F740 /* OnboardingViewController.swift in Sources */, C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */, C0F62FCA2A67CDCE0003ADFA /* BookmarkDetailCollectionViewCell.swift in Sources */, - C0DF035D2A5A9C260037F740 /* ArticleListByWeekTableViewCell.swift in Sources */, C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */, C00780BA2A60149D0043EB36 /* LHTodayArticleTitle.swift in Sources */, B51220602A60111C006CBE2D /* Token.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumManagerImpl.swift new file mode 100644 index 00000000..7041210a --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumManagerImpl.swift @@ -0,0 +1,22 @@ +// +// CurriculumManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class CurriculumManagerImpl: CurriculumManager { + + private let curriculumService: CurriculumService + + init(curriculumService: CurriculumService) { + self.curriculumService = curriculumService + } + + func getCurriculumServiceInfo() async throws -> UserInfoData { + guard let model = try await curriculumService.getCurriculumServiceInfo() else { throw NetworkError.badCasting } + return UserInfoData(userWeekInfo: model.week, userDayInfo: model.day, progress: model.progress + 1, remainingDay: model.remainingDay) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/CurriculumServiceImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/CurriculumServiceImpl.swift new file mode 100644 index 00000000..cd9148e1 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/CurriculumServiceImpl.swift @@ -0,0 +1,32 @@ +// +// CurriculumServiceImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +protocol CurriculumService { + func getArticleListByWeekInfo(week: Int) async throws -> CurriculumListByWeekResponse? + func getCurriculumServiceInfo() async throws -> CurriculumResponse? +} + +final class CurriculumServiceImpl: CurriculumService { + + private let apiService: Requestable + + init(apiService: Requestable) { + self.apiService = apiService + } + + func getArticleListByWeekInfo(week: Int) async throws -> CurriculumListByWeekResponse? { + let urlRequest = try NetworkRequest(path: "v1/article/week/\(week)", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } + + func getCurriculumServiceInfo() async throws -> CurriculumResponse? { + let urlRequest = try NetworkRequest(path: "/v1/curriculum/progress", httpMethod: .get).makeURLRequest(isLogined: true) + return try await apiService.request(urlRequest) + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift index 718c5fad..e006dcf3 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift @@ -7,29 +7,29 @@ import UIKit -final class CurriculumService: Serviceable { - - static let shared = CurriculumService() - - private init() {} - - func getCurriculumServiceInfo() async throws -> UserInfoData { - let urlRequest = try NetworkRequest(path: "/v1/curriculum/progress", httpMethod: .get).makeURLRequest(isLogined: true) - - let (data, _) = try await URLSession.shared.data(for: urlRequest) - guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CurriculumResponse.self) else { return UserInfoData.emptyUserInfoData } - - return UserInfoData(userWeekInfo: model.week, userDayInfo: model.day, progress: model.progress + 1, remainingDay: model.remainingDay) - } - - func getArticleListByWeekInfo(week: Int) async throws -> CurriculumWeekData { - let urlRequest = try NetworkRequest(path: "v1/article/week/\(week)", httpMethod: .get).makeURLRequest(isLogined: true) - - let (data, _) = try await URLSession.shared.data(for: urlRequest) - guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CurriculumListByWeekResponse.self) else { - return .init(articleData: [], week: 0) - } - - return model.toAppData() - } -} +//final class CurriculumService: Serviceable { +// +// static let shared = CurriculumService() +// +// private init() {} +// +// func getCurriculumServiceInfo() async throws -> CurriculumResponse? { +// let urlRequest = try NetworkRequest(path: "/v1/curriculum/progress", httpMethod: .get).makeURLRequest(isLogined: true) +// +// let (data, _) = try await URLSession.shared.data(for: urlRequest) +// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CurriculumResponse.self) else { return UserInfoData.emptyUserInfoData } +// +// return UserInfoData(userWeekInfo: model.week, userDayInfo: model.day, progress: model.progress + 1, remainingDay: model.remainingDay) +// } +// +// func getArticleListByWeekInfo(week: Int) async throws -> CurriculumListByWeekResponse? { +// let urlRequest = try NetworkRequest(path: "v1/article/week/\(week)", httpMethod: .get).makeURLRequest(isLogined: true) +// +// let (data, _) = try await URLSession.shared.data(for: urlRequest) +// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CurriculumListByWeekResponse.self) else { +// return .init(articleData: [], week: 0) +// } +// +// return model.toAppData() +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift index 8b1a1627..c868c771 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift @@ -11,6 +11,10 @@ import UIKit import SnapKit import Lottie +protocol CurriculumManager { + func getCurriculumServiceInfo() async throws -> UserInfoData +} + final class CurriculumViewController: UIViewController, CurriculumTableViewToggleButtonTappedProtocol{ private lazy var navigationBar = LHNavigationBarView(type: .curriculumMain, viewController: self) @@ -21,6 +25,17 @@ final class CurriculumViewController: UIViewController, CurriculumTableViewToggl } } + private let manager: CurriculumManager + + init(manager: CurriculumManager) { + self.manager = manager + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + private let progressBar = LottieAnimationView() private let dDayLabel: UILabel = { @@ -305,7 +320,7 @@ extension CurriculumViewController { func getCurriculumData() { Task { do { - let responseCurriculum = try await CurriculumService.shared.getCurriculumServiceInfo() + let responseCurriculum = try await manager.getCurriculumServiceInfo() userInfoData = responseCurriculum hideLoading() From 1a8dfcc3a34c3293385041e21a324df4a26fb55a Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:08:22 +0900 Subject: [PATCH 14/39] =?UTF-8?q?=F0=9F=94=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArticleListByWeekTableViewCell.swift | 65 ------------------- .../ArticleListByWeekViewController.swift | 56 ---------------- .../Views/ArticleListByWeekView.swift | 60 ----------------- 3 files changed, 181 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Cells/ArticleListByWeekTableViewCell.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/ViewControllers/ArticleListByWeekViewController.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Views/ArticleListByWeekView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Cells/ArticleListByWeekTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Cells/ArticleListByWeekTableViewCell.swift deleted file mode 100644 index b2d5a4f7..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Cells/ArticleListByWeekTableViewCell.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// ArticleListByWeekTableViewCell.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleListByWeek. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleListByWeekTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - - var inputData: DummyModel? { - didSet { - /// action - } - } - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } -} - -private extension ArticleListByWeekTableViewCell { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/ViewControllers/ArticleListByWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/ViewControllers/ArticleListByWeekViewController.swift deleted file mode 100644 index 64723c9d..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/ViewControllers/ArticleListByWeekViewController.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// ArticleListByWeekViewController.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleListByWeek. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleListByWeekViewController: UIViewController { - - - public override func viewDidLoad() { - super.viewDidLoad() - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - - } -} - -private extension ArticleListByWeekViewController { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Views/ArticleListByWeekView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Views/ArticleListByWeekView.swift deleted file mode 100644 index 1c7c8fe5..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByWeek/Views/ArticleListByWeekView.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// ArticleListByWeekView.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleListByWeek. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleListByWeekView: UIView { - - override init(frame: CGRect) { - super.init(frame: frame) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - -} - -private extension ArticleListByWeekView { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} From df5adb982f28f58995c92d6b8c5563a8fcc9f464 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:16:44 +0900 Subject: [PATCH 15/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BB=A4=EB=A6=AC?= =?UTF-8?q?=ED=81=98=EB=9F=BC=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=B7=B0=20DI=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 +++ .../Manager/CurriculumListManagerImpl.swift | 29 +++++++++++++++++++ .../CurriculumListByWeekViewController.swift | 16 ++++++---- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumListManagerImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index e7fbc3d8..db9c22b2 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */; }; C0856B832ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */; }; C0856B852ABFD0F50026D9F8 /* CurriculumManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */; }; + C0856B872ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -351,6 +352,7 @@ C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingManagerImpl.swift; sourceTree = ""; }; C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumServiceImpl.swift; sourceTree = ""; }; C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumManagerImpl.swift; sourceTree = ""; }; + C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListManagerImpl.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1256,6 +1258,7 @@ C0856B7E2ABFCBF20026D9F8 /* ArticleListByCategoryMangerImpl.swift */, C0856B802ABFCD830026D9F8 /* OnboardingManagerImpl.swift */, C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */, + C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */, ); path = Manager; sourceTree = ""; @@ -1691,6 +1694,7 @@ C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */, B51220642A6039AA006CBE2D /* HttpMethod.swift in Sources */, B532E8322A5525C600F0DB19 /* AppDelegate.swift in Sources */, + C0856B872ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift in Sources */, C0F029DE2A5FAC6100E0D185 /* LHOnboardingTitleLabel.swift in Sources */, C0856B7D2ABFCA330026D9F8 /* LoginMangerImpl.swift in Sources */, F435E04C2A5DA6A40098E691 /* CurriculumUserInfoView.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumListManagerImpl.swift b/LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumListManagerImpl.swift new file mode 100644 index 00000000..589e084c --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Manager/CurriculumListManagerImpl.swift @@ -0,0 +1,29 @@ +// +// CurriculumListManagerImpl.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation + +final class CurriculumListManagerImpl: CurriculumListManager { + + private let bookmarkService: BookmarkOutService + private let curriculumService: CurriculumService + + init(bookmarkService: BookmarkOutService, curriculumService: CurriculumService) { + self.bookmarkService = bookmarkService + self.curriculumService = curriculumService + } + + func postBookmark(model: BookmarkRequest) async throws { + guard let data = try await bookmarkService.postBookmark(model: model) else { throw NetworkError.badCasting } + print(data) + } + + func getArticleListByWeekInfo(week: Int) async throws -> CurriculumWeekData { + guard let model = try await curriculumService.getArticleListByWeekInfo(week: week) else { throw NetworkError.badCasting } + return model.toAppData() + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift index 14ecdb85..b1bc4771 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift @@ -10,13 +10,17 @@ import UIKit import SnapKit +protocol CurriculumListManager { + func postBookmark(model: BookmarkRequest) async throws + func getArticleListByWeekInfo(week: Int) async throws -> CurriculumWeekData +} + final class CurriculumListByWeekViewController: UIViewController { - private let serviceProtocol: BookmarkOutProtocol + private let manager: CurriculumListManager - init(serviceProtocol: BookmarkOutProtocol) { - self.serviceProtocol = serviceProtocol - /// 이 코드는 왜 있어야 하지? + init(manager: CurriculumListManager) { + self.manager = manager super.init(nibName: nil, bundle: nil) } @@ -52,7 +56,7 @@ final class CurriculumListByWeekViewController: UIViewController { if oldValue == currentPage { return } Task { showLoading() - let articlesByWeek = try await CurriculumService.shared.getArticleListByWeekInfo(week: week) + let articlesByWeek = try await manager.getArticleListByWeekInfo(week: week) print("✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨") print(currentPage + 4) self.listByWeekDatas = articlesByWeek @@ -180,7 +184,7 @@ private extension CurriculumListByWeekViewController { print(buttonSelected) try await - serviceProtocol.postBookmark(model: BookmarkRequest(articleId: listByWeekDatas.articleData[indexPath].articleId, + manager.postBookmark(model: BookmarkRequest(articleId: listByWeekDatas.articleData[indexPath].articleId, bookmarkRequestStatus: buttonSelected)) hideLoading() buttonSelected ? LHToast.show(message: "북마크가 추가되었습니다", isTabBar: true) : LHToast.show(message: "북마크가 해제되었습니다", isTabBar: true) From 435ad954f0544ca9070c2ead95246dbc4e169123 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:17:20 +0900 Subject: [PATCH 16/39] =?UTF-8?q?=F0=9F=94=A5=20=EA=B8=B0=EC=A1=B4=20?= =?UTF-8?q?=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=EB=A0=88=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=20=EC=A3=BC=EC=84=9D=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 추후, 새 코드가 문제 없으면 삭제 --- .../LionHeart-iOS/Network/API/AuthAPI.swift | 178 +++++++++--------- .../Network/API/ChallengeAPI.swift | 38 ++-- .../LionHeart-iOS/Network/API/MyPageAPI.swift | 34 ++-- .../Services/AuthMyPageServiceWrapper.swift | 74 ++++---- 4 files changed, 162 insertions(+), 162 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift index 7f04ebb9..7e807b72 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift @@ -5,92 +5,92 @@ // Created by uiskim on 2023/09/08. // -import Foundation - -protocol AuthAPIProtocol { - func reissueToken(token: Token) async throws -> Token? - func login(type: LoginType, kakaoToken: String) async throws - func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws - @discardableResult func logout(token: UserDefaultToken) async throws -> String? - func resignUser() async throws -} - -final class AuthAPI: AuthAPIProtocol { - - private let apiService: Requestable - - init(apiService: Requestable) { - self.apiService = apiService - } - - func reissueToken(token: Token) async throws -> Token? { - let urlRequest = try makeReissueTokenUrlRequest(token: token) - return try await apiService.request(urlRequest) - } - - func login(type: LoginType, kakaoToken: String) async throws { - let urlRequest = try makeLoginUrlRequest(type: type, kakaoToken: kakaoToken) - userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) - } - - func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { - let urlRequest = try makeSignUpUrlRequest(type: type, onboardingModel: onboardingModel) - userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) - } - - func logout(token: UserDefaultToken) async throws -> String? { - let urlRequest = try makeLogoutUrlRequest() - return try await apiService.request(urlRequest) - } - - func resignUser() async throws { - let urlRequest = try makeResignUserUrlRequest() - _ = try await URLSession.shared.data(for: urlRequest) - UserDefaultsManager.tokenKey?.refreshToken = nil - } -} - -extension AuthAPI { - private func userdefaultsSettingWhenUserIn(model: Token?) { - UserDefaultsManager.tokenKey?.accessToken = model?.accessToken - UserDefaultsManager.tokenKey?.refreshToken = model?.refreshToken - } -} - -extension AuthAPI { - func makeResignUserUrlRequest() throws -> URLRequest { - return try NetworkRequest(path: "/v1/member", httpMethod: .delete).makeURLRequest(isLogined: true) - } - - func makeLogoutUrlRequest() throws -> URLRequest { - return try NetworkRequest(path: "/v1/auth/logout", httpMethod: .post).makeURLRequest(isLogined: true) - } - - func makeSignUpUrlRequest(type: LoginType, onboardingModel: UserOnboardingModel) throws -> URLRequest { - guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken, - let kakaoToken = onboardingModel.kakaoAccessToken, - let pregnantWeeks = onboardingModel.pregnacny, - let babyNickname = onboardingModel.fetalNickname else { throw NetworkError.badCasting } - let requestModel = SignUpRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken, pregnantWeeks: pregnantWeeks, babyNickname: babyNickname) - let param = requestModel.toDictionary() - let body = try JSONSerialization.data(withJSONObject: param) - return try NetworkRequest(path: "/v1/auth/signup", httpMethod: .post, body: body).makeURLRequest(isLogined: false) - } - - func makeReissueTokenUrlRequest(token: Token) throws -> URLRequest { - let params = token.toDictionary() - let body = try JSONSerialization.data(withJSONObject: params, options: []) - return try NetworkRequest(path: "/v1/auth/reissue", httpMethod: .post, body: body) - .makeURLRequest(isLogined: false) - } - - func makeLoginUrlRequest(type: LoginType, kakaoToken: String) throws -> URLRequest { - guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken else { - throw NetworkError.clientError(code: "", message: "\(String(describing: UserDefaultsManager.tokenKey))") - } - let loginRequest = LoginRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken) - let param = loginRequest.toDictionary() - let body = try JSONSerialization.data(withJSONObject: param) - return try NetworkRequest(path: "/v1/auth/login", httpMethod: .post, body: body).makeURLRequest(isLogined: false) - } -} +//import Foundation +// +//protocol AuthAPIProtocol { +// func reissueToken(token: Token) async throws -> Token? +// func login(type: LoginType, kakaoToken: String) async throws +// func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws +// @discardableResult func logout(token: UserDefaultToken) async throws -> String? +// func resignUser() async throws +//} +// +//final class AuthAPI: AuthAPIProtocol { +// +// private let apiService: Requestable +// +// init(apiService: Requestable) { +// self.apiService = apiService +// } +// +// func reissueToken(token: Token) async throws -> Token? { +// let urlRequest = try makeReissueTokenUrlRequest(token: token) +// return try await apiService.request(urlRequest) +// } +// +// func login(type: LoginType, kakaoToken: String) async throws { +// let urlRequest = try makeLoginUrlRequest(type: type, kakaoToken: kakaoToken) +// userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) +// } +// +// func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { +// let urlRequest = try makeSignUpUrlRequest(type: type, onboardingModel: onboardingModel) +// userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) +// } +// +// func logout(token: UserDefaultToken) async throws -> String? { +// let urlRequest = try makeLogoutUrlRequest() +// return try await apiService.request(urlRequest) +// } +// +// func resignUser() async throws { +// let urlRequest = try makeResignUserUrlRequest() +// _ = try await URLSession.shared.data(for: urlRequest) +// UserDefaultsManager.tokenKey?.refreshToken = nil +// } +//} +// +//extension AuthAPI { +// private func userdefaultsSettingWhenUserIn(model: Token?) { +// UserDefaultsManager.tokenKey?.accessToken = model?.accessToken +// UserDefaultsManager.tokenKey?.refreshToken = model?.refreshToken +// } +//} +// +//extension AuthAPI { +// func makeResignUserUrlRequest() throws -> URLRequest { +// return try NetworkRequest(path: "/v1/member", httpMethod: .delete).makeURLRequest(isLogined: true) +// } +// +// func makeLogoutUrlRequest() throws -> URLRequest { +// return try NetworkRequest(path: "/v1/auth/logout", httpMethod: .post).makeURLRequest(isLogined: true) +// } +// +// func makeSignUpUrlRequest(type: LoginType, onboardingModel: UserOnboardingModel) throws -> URLRequest { +// guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken, +// let kakaoToken = onboardingModel.kakaoAccessToken, +// let pregnantWeeks = onboardingModel.pregnacny, +// let babyNickname = onboardingModel.fetalNickname else { throw NetworkError.badCasting } +// let requestModel = SignUpRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken, pregnantWeeks: pregnantWeeks, babyNickname: babyNickname) +// let param = requestModel.toDictionary() +// let body = try JSONSerialization.data(withJSONObject: param) +// return try NetworkRequest(path: "/v1/auth/signup", httpMethod: .post, body: body).makeURLRequest(isLogined: false) +// } +// +// func makeReissueTokenUrlRequest(token: Token) throws -> URLRequest { +// let params = token.toDictionary() +// let body = try JSONSerialization.data(withJSONObject: params, options: []) +// return try NetworkRequest(path: "/v1/auth/reissue", httpMethod: .post, body: body) +// .makeURLRequest(isLogined: false) +// } +// +// func makeLoginUrlRequest(type: LoginType, kakaoToken: String) throws -> URLRequest { +// guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken else { +// throw NetworkError.clientError(code: "", message: "\(String(describing: UserDefaultsManager.tokenKey))") +// } +// let loginRequest = LoginRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken) +// let param = loginRequest.toDictionary() +// let body = try JSONSerialization.data(withJSONObject: param) +// return try NetworkRequest(path: "/v1/auth/login", httpMethod: .post, body: body).makeURLRequest(isLogined: false) +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift index 3cd6a980..4a970203 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift @@ -5,22 +5,22 @@ // Created by uiskim on 2023/09/23. // -import Foundation - -protocol ChallengeServiceAPIProtocol { - func inquireChallengeInfo() async throws -> ChallengeDataResponse? -} - -final class ChallengeAPI: ChallengeServiceAPIProtocol { - - private let apiService: Requestable - - init(apiService: Requestable) { - self.apiService = apiService - } - - func inquireChallengeInfo() async throws -> ChallengeDataResponse? { - let urlRequest = try NetworkRequest(path: "/v1/challenge/progress", httpMethod: .get).makeURLRequest(isLogined: true) - return try await apiService.request(urlRequest) - } -} +//import Foundation +// +//protocol ChallengeServiceAPIProtocol { +// func inquireChallengeInfo() async throws -> ChallengeDataResponse? +//} +// +//final class ChallengeAPI: ChallengeServiceAPIProtocol { +// +// private let apiService: Requestable +// +// init(apiService: Requestable) { +// self.apiService = apiService +// } +// +// func inquireChallengeInfo() async throws -> ChallengeDataResponse? { +// let urlRequest = try NetworkRequest(path: "/v1/challenge/progress", httpMethod: .get).makeURLRequest(isLogined: true) +// return try await apiService.request(urlRequest) +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift index a59ee194..2ff1331a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift @@ -7,20 +7,20 @@ import Foundation -protocol MyPageAPIProtocol { - func getMyPage() async throws -> MyPageResponse? -} - -final class MyPageAPI: MyPageAPIProtocol { - - private let apiService: Requestable - - init(apiService: Requestable) { - self.apiService = apiService - } - - func getMyPage() async throws -> MyPageResponse? { - let urlRequest = try NetworkRequest(path: "/v1/member/profile", httpMethod: .get).makeURLRequest(isLogined: true) - return try await apiService.request(urlRequest) - } -} +//protocol MyPageAPIProtocol { +// func getMyPage() async throws -> MyPageResponse? +//} +// +//final class MyPageAPI: MyPageAPIProtocol { +// +// private let apiService: Requestable +// +// init(apiService: Requestable) { +// self.apiService = apiService +// } +// +// func getMyPage() async throws -> MyPageResponse? { +// let urlRequest = try NetworkRequest(path: "/v1/member/profile", httpMethod: .get).makeURLRequest(isLogined: true) +// return try await apiService.request(urlRequest) +// } +//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift index 65cac04f..7ba2c36a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift @@ -7,40 +7,40 @@ import Foundation -final class AuthMyPageServiceWrapper: AuthServiceProtocol, MyPageServiceProtocol { - - private let authAPIService: AuthAPIProtocol - private let mypageAPIService: MyPageAPIProtocol - - init(authAPIService: AuthAPIProtocol, mypageAPIService: MyPageAPIProtocol) { - self.authAPIService = authAPIService - self.mypageAPIService = mypageAPIService - } - - func getMyPage() async throws -> MyPageAppData { - guard let model = try await mypageAPIService.getMyPage() - else { return MyPageAppData.empty } - return MyPageAppData(badgeImage: model.level, nickname: model.babyNickname, isAlarm: model.notificationStatus) - } - - func reissueToken(token: Token) async throws -> Token? { - return try await authAPIService.reissueToken(token: token) - } - - func login(type: LoginType, kakaoToken: String) async throws { - try await authAPIService.login(type: type, kakaoToken: kakaoToken) - } - - func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { - try await authAPIService.signUp(type: type, onboardingModel: onboardingModel) - } - - func resignUser() async throws { - try await authAPIService.resignUser() - } - - func logout(token: UserDefaultToken) async throws { - try await authAPIService.logout(token: token) - } - -} +//final class AuthMyPageServiceWrapper: AuthServiceProtocol, MyPageServiceProtocol { +// +// private let authAPIService: AuthAPIProtocol +// private let mypageAPIService: MyPageAPIProtocol +// +// init(authAPIService: AuthAPIProtocol, mypageAPIService: MyPageAPIProtocol) { +// self.authAPIService = authAPIService +// self.mypageAPIService = mypageAPIService +// } +// +// func getMyPage() async throws -> MyPageAppData { +// guard let model = try await mypageAPIService.getMyPage() +// else { return MyPageAppData.empty } +// return MyPageAppData(badgeImage: model.level, nickname: model.babyNickname, isAlarm: model.notificationStatus) +// } +// +// func reissueToken(token: Token) async throws -> Token? { +// return try await authAPIService.reissueToken(token: token) +// } +// +// func login(type: LoginType, kakaoToken: String) async throws { +// try await authAPIService.login(type: type, kakaoToken: kakaoToken) +// } +// +// func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { +// try await authAPIService.signUp(type: type, onboardingModel: onboardingModel) +// } +// +// func resignUser() async throws { +// try await authAPIService.resignUser() +// } +// +// func logout(token: UserDefaultToken) async throws { +// try await authAPIService.logout(token: token) +// } +// +//} From 54b049746abed32d3c81230fab2add291f9f6acd Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:22:52 +0900 Subject: [PATCH 17/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArticleCategoryViewController.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift index 0e23f331..52c0bfa5 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift @@ -97,14 +97,13 @@ private extension ArticleCategoryViewController { func setAddTarget() { navigationBar.rightFirstBarItemAction { - let bookmarkViewController = BookmarkViewController(serviceProtocol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) + let bookmarkViewController = BookmarkViewController(manager: BookmarkMangerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(bookmarkViewController, animated: true) } navigationBar.rightSecondBarItemAction { - let wrapper = AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())) - let myPageViewController = MyPageViewController(service: wrapper) - self.navigationController?.pushViewController(myPageViewController, animated: true) + let mypageViewController = MyPageViewController(manager: MyPageManagerImpl(mypageService: MyPageServiceImpl(apiService: APIService()), authService: AuthServiceImpl(apiService: APIService()))) + self.navigationController?.pushViewController(mypageViewController, animated: true) } } @@ -134,9 +133,9 @@ extension ArticleCategoryViewController: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let ArticleListByCategoryVC = ArticleListByCategoryViewController(serviceProcotol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) - ArticleListByCategoryVC.categoryString = dummyCase[indexPath.item].categoryString - self.navigationController?.pushViewController(ArticleListByCategoryVC, animated: true) + let articleListbyCategoryViewController = ArticleListByCategoryViewController(manager: ArticleListByCategoryMangerImpl(articleService: ArticleServiceImpl(apiService: APIService()), bookmarkService: BookmarkServiceImpl(apiService: APIService()))) + articleListbyCategoryViewController.categoryString = dummyCase[indexPath.item].categoryString + self.navigationController?.pushViewController(articleListbyCategoryViewController, animated: true) } } From 0954a871340453b937730dbb4927613950c4dbc8 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:45:45 +0900 Subject: [PATCH 18/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=95=B1=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20navigation=20DI=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 ++ .../Application/SceneDelegate.swift | 3 +- .../Global/Extensions/UIViewController+.swift | 2 +- .../Network/Base/APIService.swift | 2 +- .../ArticleDetailViewController.swift | 3 +- .../ArticleListByCategoryViewController.swift | 3 +- .../BookmarkViewController.swift | 3 +- .../ChallengeViewController.swift | 43 +------------------ .../CurriculumListByWeekViewController.swift | 6 +-- .../CurriculumViewController.swift | 17 +++----- .../Scenes/Login/LoginViewController.swift | 2 +- .../MyPageViewController.swift | 6 ++- .../OnboardingViewController.swift | 3 +- .../Scenes/Splash/SplashViewController.swift | 6 +-- .../Scenes/TabBar/TabBarViewController.swift | 6 +-- .../ViewControllers/TodayViewController.swift | 8 ++-- 16 files changed, 42 insertions(+), 75 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index db9c22b2..a37d9070 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -127,6 +127,7 @@ C0856B832ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */; }; C0856B852ABFD0F50026D9F8 /* CurriculumManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */; }; C0856B872ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */; }; + C0856B892ABFDA240026D9F8 /* Bedge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B882ABFDA240026D9F8 /* Bedge.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -353,6 +354,7 @@ C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumServiceImpl.swift; sourceTree = ""; }; C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumManagerImpl.swift; sourceTree = ""; }; C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListManagerImpl.swift; sourceTree = ""; }; + C0856B882ABFDA240026D9F8 /* Bedge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bedge.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1110,6 +1112,7 @@ children = ( B59892E72A5B14FE00CE1FEB /* NavigationBarType.swift */, C06E38222A65353F00B00600 /* LoginType.swift */, + C0856B882ABFDA240026D9F8 /* Bedge.swift */, ); path = Enums; sourceTree = ""; @@ -1625,6 +1628,7 @@ B57BEB6E2A6275D600D1727C /* Serviceable.swift in Sources */, D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */, B57BEB652A6134B800D1727C /* setRootViewController.swift in Sources */, + C0856B892ABFDA240026D9F8 /* Bedge.swift in Sources */, B5C6A2C22A5DEA1B0021BE5E /* CopyRightTableViewCell.swift in Sources */, C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */, B59892E52A5B109900CE1FEB /* ScreenUtils.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Application/SceneDelegate.swift b/LionHeart-iOS/LionHeart-iOS/Application/SceneDelegate.swift index 9fcd8bef..50df2174 100644 --- a/LionHeart-iOS/LionHeart-iOS/Application/SceneDelegate.swift +++ b/LionHeart-iOS/LionHeart-iOS/Application/SceneDelegate.swift @@ -31,7 +31,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { self.window = UIWindow(windowScene: windowScene) /// 폰트등록 Font.registerFonts() - let navigationController = UINavigationController(rootViewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())))) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + let navigationController = UINavigationController(rootViewController: splashViewController) self.window?.rootViewController = navigationController self.window?.makeKeyAndVisible() } diff --git a/LionHeart-iOS/LionHeart-iOS/Global/Extensions/UIViewController+.swift b/LionHeart-iOS/LionHeart-iOS/Global/Extensions/UIViewController+.swift index 68dc9806..cd5e089c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/Extensions/UIViewController+.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/Extensions/UIViewController+.swift @@ -89,7 +89,7 @@ extension UIViewController { extension UIViewController { func presentArticleDetailFullScreen(articleID: Int) { - let articleDetailViewController = ArticleDetailViewController(serviceProtocol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) + let articleDetailViewController = ArticleDetailViewController(manager: ArticleDetailManagerImpl(articleService: ArticleServiceImpl(apiService: APIService()), bookmarkService: BookmarkServiceImpl(apiService: APIService()))) articleDetailViewController.setArticleId(id: articleID) articleDetailViewController.isModalInPresentation = true articleDetailViewController.modalPresentationStyle = .fullScreen diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift index 970d53bf..92092d86 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift @@ -28,7 +28,7 @@ final class APIService: Requestable { throw NetworkError.serverError } - print("✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅APIService성공✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅") + print("✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅API호출성공✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅") return decodedData.data } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift index de6272a2..41409318 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/ViewControllers/ArticleDetailViewController.swift @@ -126,7 +126,8 @@ extension ArticleDetailViewController: ViewControllerServiceable { switch error { case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: "\(message)") default: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift index 51735a0b..04a93f50 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift @@ -122,7 +122,8 @@ extension ArticleListByCategoryViewController: ViewControllerServiceable { LHToast.show(message: "Image Error") case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: message) case .serverError: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift index a14b8ec9..080bdbc3 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/ViewControllers/BookmarkViewController.swift @@ -122,7 +122,8 @@ extension BookmarkViewController: ViewControllerServiceable { LHToast.show(message: "Image Error") case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: message) case .serverError: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index 9d0a87f8..f98acba4 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -11,44 +11,6 @@ import UIKit import SnapKit import Lottie -enum BadgeLevel: String { - case level01 = "LEVEL_ONE" - case level02 = "LEVEL_TWO" - case level03 = "LEVEL_THREE" - case level04 = "LEVEL_FOUR" - case level05 = "LEVEL_FIVE" - - var badgeLevel: Int { - switch self { - case .level01: return 1 - case .level02: return 2 - case .level03: return 3 - case .level04: return 4 - case .level05: return 5 - } - } - - var badgeImage: UIImage { - switch self { - case .level01: return ImageLiterals.ChallengeBadge.level01 - case .level02: return ImageLiterals.ChallengeBadge.level02 - case .level03: return ImageLiterals.ChallengeBadge.level03 - case .level04: return ImageLiterals.ChallengeBadge.level04 - case .level05: return ImageLiterals.ChallengeBadge.level05 - } - } - - var progreddbarLottie: String { - switch self { - case .level01: return "Level1" - case .level02: return "Level2" - case .level03: return "Level3" - case .level04: return "Level4" - case .level05: return "Level5" - } - } -} - protocol ChallengeManager { func inquireChallengeInfo() async throws -> ChallengeData } @@ -249,13 +211,12 @@ private extension ChallengeViewController { func setAddTarget() { navigationBar.rightFirstBarItemAction { - let bookmarkViewController = BookmarkViewController(serviceProtocol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) + let bookmarkViewController = BookmarkViewController(manager: BookmarkMangerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(bookmarkViewController, animated: true) } navigationBar.rightSecondBarItemAction { - let wrapper = AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())) - let myPageViewController = MyPageViewController(service: wrapper) + let myPageViewController = MyPageViewController(manager: MyPageManagerImpl(mypageService: MyPageServiceImpl(apiService: APIService()), authService: AuthServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(myPageViewController, animated: true) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift index b1bc4771..af3d9e7b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift @@ -265,7 +265,8 @@ extension CurriculumListByWeekViewController: ViewControllerServiceable { switch error { case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(code: _, message: let message): LHToast.show(message: "\(message)") default: @@ -278,8 +279,7 @@ extension CurriculumListByWeekViewController { func getListByWeekData() { Task { do { - let responseListByWeek = try await CurriculumService.shared.getArticleListByWeekInfo(week: weekToIndexPathItem + 4) - + let responseListByWeek = try await manager.getArticleListByWeekInfo(week: weekToIndexPathItem + 4) listByWeekDatas = responseListByWeek hideLoading() } catch { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift index c868c771..d36be9f9 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift @@ -181,13 +181,12 @@ private extension CurriculumViewController { func setAddTarget() { navigationBar.rightFirstBarItemAction { - let bookmarkViewController = BookmarkViewController(serviceProtocol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) + let bookmarkViewController = BookmarkViewController(manager: BookmarkMangerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(bookmarkViewController, animated: true) } navigationBar.rightSecondBarItemAction { - let wrapper = AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())) - let myPageViewController = MyPageViewController(service: wrapper) + let myPageViewController = MyPageViewController(manager: MyPageManagerImpl(mypageService: MyPageServiceImpl(apiService: APIService()), authService: AuthServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(myPageViewController, animated: true) } } @@ -283,7 +282,7 @@ extension CurriculumViewController: UITableViewDataSource { } - let listByWeekVC = CurriculumListByWeekViewController(serviceProtocol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) + let listByWeekVC = CurriculumListByWeekViewController(manager: CurriculumListManagerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()), curriculumService: CurriculumServiceImpl(apiService: APIService()))) listByWeekVC.weekToIndexPathItem = (indexPath.section * 4) + indexPath.row self.navigationController?.pushViewController(listByWeekVC, animated: true) @@ -292,12 +291,7 @@ extension CurriculumViewController: UITableViewDataSource { } -extension CurriculumViewController: UITableViewDelegate{ -// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { -// let curriculumListByWeekViewController = CurriculumListByWeekViewController() -// self.navigationController?.pushViewController(curriculumListByWeekViewController, animated: true) -// } -} +extension CurriculumViewController: UITableViewDelegate{} extension CurriculumViewController: ViewControllerServiceable { @@ -305,7 +299,8 @@ extension CurriculumViewController: ViewControllerServiceable { switch error { case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: "\(message)") default: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift index de813329..eef5fad4 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift @@ -121,7 +121,7 @@ extension LoginViewController { } func moveUserToOnboardingViewController() { - let onboardingViewController = OnboardingViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))) + let onboardingViewController = OnboardingViewController(manager: OnboardingManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) onboardingViewController.setKakaoAccessToken(kakaoAccessToken) self.navigationController?.pushViewController(onboardingViewController, animated: true) } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift index da4323e1..bac9f595 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift @@ -126,7 +126,8 @@ private extension MyPageViewController { guard let window = self.view.window else { return } self.resignButton.isUserInteractionEnabled = false try await self.manager.resignUser() - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) } catch { print(error) } @@ -168,7 +169,8 @@ extension MyPageViewController: ViewControllerServiceable { LHToast.show(message: "Image Error") case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: message) case .serverError: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift index b8f8666f..bfb772b5 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift @@ -252,7 +252,8 @@ extension OnboardingViewController: ViewControllerServiceable { LHToast.show(message: "이미지패치에러") case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: message) case .serverError: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift index d0d16b6e..60285493 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift @@ -51,7 +51,7 @@ final class SplashViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { lottieImageView.play { _ in guard let accessToken = UserDefaultsManager.tokenKey?.accessToken, let refreshToken = UserDefaultsManager.tokenKey?.refreshToken else { - let loginViewController = UINavigationController(rootViewController: LoginViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())))) + let loginViewController = UINavigationController(rootViewController: LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService())))) guard let window = self.view.window else { return } ViewControllerUtil.setRootViewController(window: window, viewController: loginViewController, withAnimation: true) return @@ -130,10 +130,10 @@ private extension SplashViewController { guard let token = UserDefaultsManager.tokenKey else { return } await logout(token: token) // LoginVC로 이동하기 - let loginVC = UINavigationController(rootViewController: LoginViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())))) + let loginVC = UINavigationController(rootViewController: LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService())))) setRootViewController(to: loginVC, animation: true) } else if code == NetworkErrorCode.unfoundUserErrorCode { - let loginVC = UINavigationController(rootViewController: LoginViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())))) + let loginVC = UINavigationController(rootViewController: LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService())))) setRootViewController(to: loginVC, animation: true) } default: diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift index 7beb4ae5..176d7fb1 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/TabBar/TabBarViewController.swift @@ -14,16 +14,16 @@ final class TabBarViewController: UITabBarController { public override func viewDidLoad() { super.viewDidLoad() - let todayViewController = UINavigationController(rootViewController: TodayViewController()) + let todayViewController = UINavigationController(rootViewController: TodayViewController(manager: TodayManagerImpl(articleService: ArticleServiceImpl(apiService: APIService())))) todayViewController.tabBarItem = UITabBarItem(title: "투데이", image: .assetImage(.home), tag: 0) let articleCategoryViewController = UINavigationController(rootViewController: ArticleCategoryViewController()) articleCategoryViewController.tabBarItem = UITabBarItem(title: "탐색", image: .assetImage(.search), tag: 1) - let curriculumViewController = UINavigationController(rootViewController: CurriculumViewController()) + let curriculumViewController = UINavigationController(rootViewController: CurriculumViewController(manager: CurriculumManagerImpl(curriculumService: CurriculumServiceImpl(apiService: APIService())))) curriculumViewController.tabBarItem = UITabBarItem(title: "커리큘럼", image: .assetImage(.curriculum), tag: 2) - let challengeViewController = UINavigationController(rootViewController: ChallengeViewController(challengeService: ChallengeService(challengeAPIService: ChallengeAPI(apiService: APIService())))) + let challengeViewController = UINavigationController(rootViewController: ChallengeViewController(manager: ChallengeManagerImpl(challengeService: ChallengeServiceImpl(apiService: APIService())))) challengeViewController.tabBarItem = UITabBarItem(title: "챌린지", image: .assetImage(.challenge), tag: 3) self.viewControllers = [todayViewController, articleCategoryViewController, curriculumViewController, challengeViewController] diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift index c17a2a1e..05c925e9 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift @@ -140,13 +140,12 @@ private extension TodayViewController { func setButtonAction() { todayNavigationBar.rightFirstBarItemAction { - let bookmarkViewController = BookmarkViewController(serviceProtocol: BookmarkService(bookmarkAPIProtocol: BookmarkAPI(apiService: APIService()))) + let bookmarkViewController = BookmarkViewController(manager: BookmarkMangerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(bookmarkViewController, animated: true) } todayNavigationBar.rightSecondBarItemAction { - let wrapperClass = AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService())) - let myPageViewController = MyPageViewController(service: wrapperClass) + let myPageViewController = MyPageViewController(manager: MyPageManagerImpl(mypageService: MyPageServiceImpl(apiService: APIService()), authService: AuthServiceImpl(apiService: APIService()))) self.navigationController?.pushViewController(myPageViewController, animated: true) } } @@ -171,7 +170,8 @@ extension TodayViewController: ViewControllerServiceable { LHToast.show(message: "이미지패치실패", isTabBar: true) case .unAuthorizedError: guard let window = self.view.window else { return } - ViewControllerUtil.setRootViewController(window: window, viewController: SplashViewController(authService: AuthMyPageServiceWrapper(authAPIService: AuthAPI(apiService: APIService()), mypageAPIService: MyPageAPI(apiService: APIService()))), withAnimation: false) + let splashViewController = SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + ViewControllerUtil.setRootViewController(window: window, viewController: splashViewController, withAnimation: false) case .clientError(_, let message): LHToast.show(message: message, isTabBar: true) case .serverError: From 2450b9ca11f5dc7f8e7f513dff19052f15ad725e Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:46:48 +0900 Subject: [PATCH 19/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20global=20enum?= =?UTF-8?q?=EC=97=90=20badge=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 8 ++-- .../LionHeart-iOS/Global/Enums/Badge.swift | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/Enums/Badge.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index a37d9070..1411efb6 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -127,7 +127,7 @@ C0856B832ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */; }; C0856B852ABFD0F50026D9F8 /* CurriculumManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */; }; C0856B872ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */; }; - C0856B892ABFDA240026D9F8 /* Bedge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B882ABFDA240026D9F8 /* Bedge.swift */; }; + C0856B892ABFDA240026D9F8 /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B882ABFDA240026D9F8 /* Badge.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; @@ -354,7 +354,7 @@ C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumServiceImpl.swift; sourceTree = ""; }; C0856B842ABFD0F50026D9F8 /* CurriculumManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumManagerImpl.swift; sourceTree = ""; }; C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListManagerImpl.swift; sourceTree = ""; }; - C0856B882ABFDA240026D9F8 /* Bedge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bedge.swift; sourceTree = ""; }; + C0856B882ABFDA240026D9F8 /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; @@ -1112,7 +1112,7 @@ children = ( B59892E72A5B14FE00CE1FEB /* NavigationBarType.swift */, C06E38222A65353F00B00600 /* LoginType.swift */, - C0856B882ABFDA240026D9F8 /* Bedge.swift */, + C0856B882ABFDA240026D9F8 /* Badge.swift */, ); path = Enums; sourceTree = ""; @@ -1628,7 +1628,7 @@ B57BEB6E2A6275D600D1727C /* Serviceable.swift in Sources */, D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */, B57BEB652A6134B800D1727C /* setRootViewController.swift in Sources */, - C0856B892ABFDA240026D9F8 /* Bedge.swift in Sources */, + C0856B892ABFDA240026D9F8 /* Badge.swift in Sources */, B5C6A2C22A5DEA1B0021BE5E /* CopyRightTableViewCell.swift in Sources */, C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */, B59892E52A5B109900CE1FEB /* ScreenUtils.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/Enums/Badge.swift b/LionHeart-iOS/LionHeart-iOS/Global/Enums/Badge.swift new file mode 100644 index 00000000..5be6a3c4 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/Enums/Badge.swift @@ -0,0 +1,46 @@ +// +// Badge.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import UIKit + +enum BadgeLevel: String { + case level01 = "LEVEL_ONE" + case level02 = "LEVEL_TWO" + case level03 = "LEVEL_THREE" + case level04 = "LEVEL_FOUR" + case level05 = "LEVEL_FIVE" + + var badgeLevel: Int { + switch self { + case .level01: return 1 + case .level02: return 2 + case .level03: return 3 + case .level04: return 4 + case .level05: return 5 + } + } + + var badgeImage: UIImage { + switch self { + case .level01: return ImageLiterals.ChallengeBadge.level01 + case .level02: return ImageLiterals.ChallengeBadge.level02 + case .level03: return ImageLiterals.ChallengeBadge.level03 + case .level04: return ImageLiterals.ChallengeBadge.level04 + case .level05: return ImageLiterals.ChallengeBadge.level05 + } + } + + var progreddbarLottie: String { + switch self { + case .level01: return "Level1" + case .level02: return "Level2" + case .level03: return "Level3" + case .level04: return "Level4" + case .level05: return "Level5" + } + } +} From c58dfc0cf1aa4c2b68003b6f8c57ab84cdc89c22 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 11:47:44 +0900 Subject: [PATCH 20/39] =?UTF-8?q?=F0=9F=94=A5=20=EA=B8=B0=EC=A1=B4?= =?UTF-8?q?=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=96=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 변경후 레이어가 문제없어서 기존 레이어 삭제합니다 --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 56 ----------- .../LionHeart-iOS/Network/API/AuthAPI.swift | 96 ------------------- .../Network/API/BookmarkAPI.swift | 47 --------- .../Network/API/ChallengeAPI.swift | 26 ----- .../LionHeart-iOS/Network/API/MyPageAPI.swift | 26 ----- .../Network/Services/ArticleService.swift | 53 ---------- .../Services/AuthMyPageServiceWrapper.swift | 46 --------- .../Network/Services/BookmarkService.swift | 38 -------- .../Network/Services/ChallengeService.swift | 28 ------ .../Services/CurriculumViewService.swift | 35 ------- .../Network/Services/KingfisherService.swift | 52 ---------- 11 files changed, 503 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Services/KingfisherService.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 1411efb6..e3b9f558 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -17,9 +17,7 @@ 4A8980CE2A617F7100746C58 /* CollectionHeaderViewRegisterDequeueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980CD2A617F7100746C58 /* CollectionHeaderViewRegisterDequeueProtocol.swift */; }; 4A8980D02A61850500746C58 /* MyPageAppSettingCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980CF2A61850500746C58 /* MyPageAppSettingCollectionViewCell.swift */; }; 4AD216402A69AC1E00C9F2F2 /* MyPageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD2163F2A69AC1E00C9F2F2 /* MyPageResponse.swift */; }; - 4AD6A34C2AB1AB6700977224 /* BookmarkAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD6A34B2AB1AB6700977224 /* BookmarkAPI.swift */; }; 4AD6AE1A2A68436B00A3D745 /* ArticleListByCategoryResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD6AE192A68436B00A3D745 /* ArticleListByCategoryResponse.swift */; }; - 4AE19A172A65864F00C1DB7E /* BookmarkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AE19A162A65864F00C1DB7E /* BookmarkService.swift */; }; 4AE19A1A2A65886100C1DB7E /* BookmarkReponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AE19A192A65886100C1DB7E /* BookmarkReponse.swift */; }; 4AE19A1E2A6597E700C1DB7E /* BookmarkRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AE19A1D2A6597E700C1DB7E /* BookmarkRequest.swift */; }; 4AE19A1F2A66F2E200C1DB7E /* BookmarkDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980C12A5FD6AF00746C58 /* BookmarkDetailCollectionViewCell.swift */; }; @@ -53,7 +51,6 @@ B57BEB6C2A6149AD00D1727C /* NetworkRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B57BEB6B2A6149AD00D1727C /* NetworkRequest.swift */; }; B57BEB6E2A6275D600D1727C /* Serviceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B57BEB6D2A6275D600D1727C /* Serviceable.swift */; }; B57BEB702A6275F500D1727C /* ViewControllerServiceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B57BEB6F2A6275F500D1727C /* ViewControllerServiceable.swift */; }; - B57FEE2C2AA904D800ED6299 /* AuthMyPageServiceWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B57FEE2B2AA904D800ED6299 /* AuthMyPageServiceWrapper.swift */; }; B598926F2A56C21800CE1FEB /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = B598926E2A56C21800CE1FEB /* FirebaseAnalytics */; }; B59892712A56C21800CE1FEB /* FirebaseAnalyticsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B59892702A56C21800CE1FEB /* FirebaseAnalyticsSwift */; }; B59892732A56C21800CE1FEB /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = B59892722A56C21800CE1FEB /* FirebaseCrashlytics */; }; @@ -87,7 +84,6 @@ B59893112A5D039B00CE1FEB /* ArticleBlockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59893102A5D039B00CE1FEB /* ArticleBlockType.swift */; }; B59893132A5D3A4D00CE1FEB /* NetworkError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59893122A5D3A4D00CE1FEB /* NetworkError.swift */; }; B59893162A5D40FC00CE1FEB /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = B59893152A5D40FC00CE1FEB /* Kingfisher */; }; - B59893192A5D41F600CE1FEB /* KingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59893182A5D41F600CE1FEB /* KingfisherService.swift */; }; B5C6A2B22A5DB0B10021BE5E /* ArticleDetailTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6A2B12A5DB0B10021BE5E /* ArticleDetailTableView.swift */; }; B5C6A2B42A5DB11A0021BE5E /* ThumnailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6A2B32A5DB11A0021BE5E /* ThumnailTableViewCell.swift */; }; B5C6A2B62A5DD5FE0021BE5E /* TitleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6A2B52A5DD5FE0021BE5E /* TitleTableViewCell.swift */; }; @@ -98,7 +94,6 @@ B5C6A2C22A5DEA1B0021BE5E /* CopyRightTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6A2C12A5DEA1B0021BE5E /* CopyRightTableViewCell.swift */; }; B5C6A2C82A5EF4EB0021BE5E /* ArticleDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6A2C72A5EF4EB0021BE5E /* ArticleDetail.swift */; }; B5F323E92A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F323E82A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift */; }; - C004D4992AAD8F880087F044 /* MyPageAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C004D4982AAD8F880087F044 /* MyPageAPI.swift */; }; C00780B72A5FFE0E0043EB36 /* UILabel+.swift in Sources */ = {isa = PBXBuildFile; fileRef = C00780B62A5FFE0E0043EB36 /* UILabel+.swift */; }; C00780BA2A60149D0043EB36 /* LHTodayArticleTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C00780B92A60149D0043EB36 /* LHTodayArticleTitle.swift */; }; C06E381B2A65346700B00600 /* UserDefaultToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E381A2A65346700B00600 /* UserDefaultToken.swift */; }; @@ -106,10 +101,8 @@ C06E38212A65351600B00600 /* SignUpRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E38202A65351600B00600 /* SignUpRequest.swift */; }; C06E38232A65353F00B00600 /* LoginType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E38222A65353F00B00600 /* LoginType.swift */; }; C06E38282A662D8700B00600 /* TodayArticleResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E38272A662D8700B00600 /* TodayArticleResponse.swift */; }; - C06E382A2A662E3700B00600 /* ArticleService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E38292A662E3700B00600 /* ArticleService.swift */; }; C07CB81A2A62C54D000198CC /* TodayModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07CB8192A62C54D000198CC /* TodayModel.swift */; }; C07CB81E2A62C5B1000198CC /* TodayArticleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07CB81D2A62C5B1000198CC /* TodayArticleView.swift */; }; - C0856B602ABE840A0026D9F8 /* ChallengeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */; }; C0856B652ABFB8640026D9F8 /* TodayManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */; }; C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */; }; C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */; }; @@ -129,7 +122,6 @@ C0856B872ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */; }; C0856B892ABFDA240026D9F8 /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0856B882ABFDA240026D9F8 /* Badge.swift */; }; C0903CFF2AAAD7E00014786F /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903CFE2AAAD7E00014786F /* APIService.swift */; }; - C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0903D012AAAD86A0014786F /* AuthAPI.swift */; }; C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */; }; C09217692A605DEE00231C66 /* OnboardingPregnancyTextFieldResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217672A605DEE00231C66 /* OnboardingPregnancyTextFieldResultType.swift */; }; C09217732A61895A00231C66 /* UIWindow+.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09217722A61895A00231C66 /* UIWindow+.swift */; }; @@ -194,7 +186,6 @@ C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */; }; D34280772A66B90C00DA1499 /* UILabelPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280762A66B90C00DA1499 /* UILabelPadding.swift */; }; D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */; }; - D342807C2A67FE4700DA1499 /* ChallengeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D342807B2A67FE4700DA1499 /* ChallengeService.swift */; }; D35272D12A681E13002D7FCB /* ChallengeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D35272D02A681E13002D7FCB /* ChallengeData.swift */; }; D3AB54B62A625A7B0017BF53 /* ArticleListByCategoryHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3AB54B52A625A7B0017BF53 /* ArticleListByCategoryHeaderView.swift */; }; D3AB54C12A62CE3F0017BF53 /* ChallengeDayCheckCollectionViewCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3AB54C02A62CE3F0017BF53 /* ChallengeDayCheckCollectionViewCollectionViewCell.swift */; }; @@ -211,7 +202,6 @@ F4490C072A5CEEA300A6D9D7 /* CurriculumDummyData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4490C062A5CEEA300A6D9D7 /* CurriculumDummyData.swift */; }; F46522FD2A6048660083FBB2 /* CurriculumImagesByWeek.swift in Sources */ = {isa = PBXBuildFile; fileRef = F46522FC2A6048650083FBB2 /* CurriculumImagesByWeek.swift */; }; F47329E12A66F5D0001605D4 /* CurriculumResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47329E02A66F5D0001605D4 /* CurriculumResponse.swift */; }; - F4C60E1D2A66B4CE006BBADE /* CurriculumViewService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4C60E1C2A66B4CE006BBADE /* CurriculumViewService.swift */; }; F4DB30AE2A611C7C00413EB9 /* CurriculumListByWeekViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30AD2A611C7B00413EB9 /* CurriculumListByWeekViewController.swift */; }; F4DB30B02A611C9700413EB9 /* CurriculumListByWeekData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30AF2A611C9700413EB9 /* CurriculumListByWeekData.swift */; }; F4DB30B42A61250500413EB9 /* CurriculumListByWeekCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30B32A61250500413EB9 /* CurriculumListByWeekCollectionViewCell.swift */; }; @@ -248,7 +238,6 @@ 4A8980CD2A617F7100746C58 /* CollectionHeaderViewRegisterDequeueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionHeaderViewRegisterDequeueProtocol.swift; sourceTree = ""; }; 4A8980CF2A61850500746C58 /* MyPageAppSettingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageAppSettingCollectionViewCell.swift; sourceTree = ""; }; 4AD2163F2A69AC1E00C9F2F2 /* MyPageResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageResponse.swift; sourceTree = ""; }; - 4AD6A34B2AB1AB6700977224 /* BookmarkAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkAPI.swift; sourceTree = ""; }; 4AD6AE032A66F83E00A3D745 /* progressbar_2m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_2m.json; sourceTree = ""; }; 4AD6AE052A66F84300A3D745 /* progressbar_3m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_3m.json; sourceTree = ""; }; 4AD6AE072A66F84C00A3D745 /* progressbar_4m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_4m.json; sourceTree = ""; }; @@ -259,7 +248,6 @@ 4AD6AE112A66F87400A3D745 /* progressbar_9m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_9m.json; sourceTree = ""; }; 4AD6AE132A66F87C00A3D745 /* progressbar_10m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_10m.json; sourceTree = ""; }; 4AD6AE192A68436B00A3D745 /* ArticleListByCategoryResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryResponse.swift; sourceTree = ""; }; - 4AE19A162A65864F00C1DB7E /* BookmarkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkService.swift; sourceTree = ""; }; 4AE19A192A65886100C1DB7E /* BookmarkReponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkReponse.swift; sourceTree = ""; }; 4AE19A1D2A6597E700C1DB7E /* BookmarkRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkRequest.swift; sourceTree = ""; }; B51220592A5FAA47006CBE2D /* ImageLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLiterals.swift; sourceTree = ""; }; @@ -297,7 +285,6 @@ B57BEB6B2A6149AD00D1727C /* NetworkRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkRequest.swift; sourceTree = ""; }; B57BEB6D2A6275D600D1727C /* Serviceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Serviceable.swift; sourceTree = ""; }; B57BEB6F2A6275F500D1727C /* ViewControllerServiceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerServiceable.swift; sourceTree = ""; }; - B57FEE2B2AA904D800ED6299 /* AuthMyPageServiceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthMyPageServiceWrapper.swift; sourceTree = ""; }; B58E8CBD2A6AE0F200FF5202 /* LionHeart-iOSRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "LionHeart-iOSRelease.entitlements"; sourceTree = ""; }; B59892802A56C3F900CE1FEB /* LionHeart-iOSDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "LionHeart-iOSDebug.entitlements"; sourceTree = ""; }; B59892822A56C93400CE1FEB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; @@ -314,7 +301,6 @@ B598930A2A5BED0E00CE1FEB /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = ""; }; B59893102A5D039B00CE1FEB /* ArticleBlockType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleBlockType.swift; sourceTree = ""; }; B59893122A5D3A4D00CE1FEB /* NetworkError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkError.swift; sourceTree = ""; }; - B59893182A5D41F600CE1FEB /* KingfisherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KingfisherService.swift; sourceTree = ""; }; B5C6A2B12A5DB0B10021BE5E /* ArticleDetailTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailTableView.swift; sourceTree = ""; }; B5C6A2B32A5DB11A0021BE5E /* ThumnailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumnailTableViewCell.swift; sourceTree = ""; }; B5C6A2B52A5DD5FE0021BE5E /* TitleTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleTableViewCell.swift; sourceTree = ""; }; @@ -325,7 +311,6 @@ B5C6A2C12A5DEA1B0021BE5E /* CopyRightTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyRightTableViewCell.swift; sourceTree = ""; }; B5C6A2C72A5EF4EB0021BE5E /* ArticleDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetail.swift; sourceTree = ""; }; B5F323E82A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumWeekBackgroundDummy.swift; sourceTree = ""; }; - C004D4982AAD8F880087F044 /* MyPageAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageAPI.swift; sourceTree = ""; }; C00780B62A5FFE0E0043EB36 /* UILabel+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+.swift"; sourceTree = ""; }; C00780B92A60149D0043EB36 /* LHTodayArticleTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHTodayArticleTitle.swift; sourceTree = ""; }; C06E381A2A65346700B00600 /* UserDefaultToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultToken.swift; sourceTree = ""; }; @@ -333,10 +318,8 @@ C06E38202A65351600B00600 /* SignUpRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpRequest.swift; sourceTree = ""; }; C06E38222A65353F00B00600 /* LoginType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginType.swift; sourceTree = ""; }; C06E38272A662D8700B00600 /* TodayArticleResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayArticleResponse.swift; sourceTree = ""; }; - C06E38292A662E3700B00600 /* ArticleService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleService.swift; sourceTree = ""; }; C07CB8192A62C54D000198CC /* TodayModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayModel.swift; sourceTree = ""; }; C07CB81D2A62C5B1000198CC /* TodayArticleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayArticleView.swift; sourceTree = ""; }; - C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeAPI.swift; sourceTree = ""; }; C0856B642ABFB8640026D9F8 /* TodayManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayManagerImpl.swift; sourceTree = ""; }; C0856B682ABFB9140026D9F8 /* ArticleServiceImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleServiceImpl.swift; sourceTree = ""; }; C0856B6A2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailManagerImpl.swift; sourceTree = ""; }; @@ -356,7 +339,6 @@ C0856B862ABFD24E0026D9F8 /* CurriculumListManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListManagerImpl.swift; sourceTree = ""; }; C0856B882ABFDA240026D9F8 /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; C0903CFE2AAAD7E00014786F /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; - C0903D012AAAD86A0014786F /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; C09217662A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingFetalNicknameTextFieldResultType.swift; sourceTree = ""; }; C09217672A605DEE00231C66 /* OnboardingPregnancyTextFieldResultType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingPregnancyTextFieldResultType.swift; sourceTree = ""; }; C09217722A61895A00231C66 /* UIWindow+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIWindow+.swift"; sourceTree = ""; }; @@ -424,7 +406,6 @@ C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLoadingView.swift; sourceTree = ""; }; D34280762A66B90C00DA1499 /* UILabelPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILabelPadding.swift; sourceTree = ""; }; D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeDataResponse.swift; sourceTree = ""; }; - D342807B2A67FE4700DA1499 /* ChallengeService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeService.swift; sourceTree = ""; }; D35272D02A681E13002D7FCB /* ChallengeData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChallengeData.swift; sourceTree = ""; }; D3AB54B52A625A7B0017BF53 /* ArticleListByCategoryHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryHeaderView.swift; sourceTree = ""; }; D3AB54C02A62CE3F0017BF53 /* ChallengeDayCheckCollectionViewCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChallengeDayCheckCollectionViewCollectionViewCell.swift; sourceTree = ""; }; @@ -446,7 +427,6 @@ F4490C062A5CEEA300A6D9D7 /* CurriculumDummyData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumDummyData.swift; sourceTree = ""; }; F46522FC2A6048650083FBB2 /* CurriculumImagesByWeek.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumImagesByWeek.swift; sourceTree = ""; }; F47329E02A66F5D0001605D4 /* CurriculumResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumResponse.swift; sourceTree = ""; }; - F4C60E1C2A66B4CE006BBADE /* CurriculumViewService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumViewService.swift; sourceTree = ""; }; F4DB30AD2A611C7B00413EB9 /* CurriculumListByWeekViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListByWeekViewController.swift; sourceTree = ""; }; F4DB30AF2A611C9700413EB9 /* CurriculumListByWeekData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListByWeekData.swift; sourceTree = ""; }; F4DB30B32A61250500413EB9 /* CurriculumListByWeekCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListByWeekCollectionViewCell.swift; sourceTree = ""; }; @@ -632,9 +612,7 @@ children = ( C0856B662ABFB8DB0026D9F8 /* Service */, C0856B632ABFB84E0026D9F8 /* Manager */, - C0903D002AAAD8600014786F /* API */, B5C6A2C32A5EF4AC0021BE5E /* DTO */, - B59893172A5D41E300CE1FEB /* Services */, B532E8662A5529F700F0DB19 /* Base */, ); path = Network; @@ -1129,19 +1107,6 @@ path = Font; sourceTree = ""; }; - B59893172A5D41E300CE1FEB /* Services */ = { - isa = PBXGroup; - children = ( - B59893182A5D41F600CE1FEB /* KingfisherService.swift */, - D342807B2A67FE4700DA1499 /* ChallengeService.swift */, - F4C60E1C2A66B4CE006BBADE /* CurriculumViewService.swift */, - 4AE19A162A65864F00C1DB7E /* BookmarkService.swift */, - C06E38292A662E3700B00600 /* ArticleService.swift */, - B57FEE2B2AA904D800ED6299 /* AuthMyPageServiceWrapper.swift */, - ); - path = Services; - sourceTree = ""; - }; B5C6A2C32A5EF4AC0021BE5E /* DTO */ = { isa = PBXGroup; children = ( @@ -1279,17 +1244,6 @@ path = Service; sourceTree = ""; }; - C0903D002AAAD8600014786F /* API */ = { - isa = PBXGroup; - children = ( - C0903D012AAAD86A0014786F /* AuthAPI.swift */, - C004D4982AAD8F880087F044 /* MyPageAPI.swift */, - 4AD6A34B2AB1AB6700977224 /* BookmarkAPI.swift */, - C0856B5F2ABE840A0026D9F8 /* ChallengeAPI.swift */, - ); - path = API; - sourceTree = ""; - }; C09217652A605DEE00231C66 /* OnboardingTextFieldResultType */ = { isa = PBXGroup; children = ( @@ -1617,13 +1571,10 @@ C0DF03852A5AF7B70037F740 /* ChallengeViewController.swift in Sources */, C09217692A605DEE00231C66 /* OnboardingPregnancyTextFieldResultType.swift in Sources */, C0DF03A62A5CB8610037F740 /* CompleteOnbardingViewController.swift in Sources */, - D342807C2A67FE4700DA1499 /* ChallengeService.swift in Sources */, C0DF034B2A5A9B6A0037F740 /* CurriculumViewController.swift in Sources */, - C0856B602ABE840A0026D9F8 /* ChallengeAPI.swift in Sources */, F435E0542A5E67BF0098E691 /* NSObject+.swift in Sources */, 4AE19A1F2A66F2E200C1DB7E /* BookmarkDetailCollectionViewCell.swift in Sources */, D3AB54B62A625A7B0017BF53 /* ArticleListByCategoryHeaderView.swift in Sources */, - B57FEE2C2AA904D800ED6299 /* AuthMyPageServiceWrapper.swift in Sources */, B59892E82A5B14FE00CE1FEB /* NavigationBarType.swift in Sources */, B57BEB6E2A6275D600D1727C /* Serviceable.swift in Sources */, D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */, @@ -1638,10 +1589,8 @@ C0DF03452A5A9A910037F740 /* CurriculumTableViewCell.swift in Sources */, C07CB81E2A62C5B1000198CC /* TodayArticleView.swift in Sources */, F4490C072A5CEEA300A6D9D7 /* CurriculumDummyData.swift in Sources */, - C004D4992AAD8F880087F044 /* MyPageAPI.swift in Sources */, F4DB30AE2A611C7C00413EB9 /* CurriculumListByWeekViewController.swift in Sources */, B59892EC2A5B94E100CE1FEB /* UIApplication+.swift in Sources */, - 4AE19A172A65864F00C1DB7E /* BookmarkService.swift in Sources */, C0856B652ABFB8640026D9F8 /* TodayManagerImpl.swift in Sources */, 4AE19A1A2A65886100C1DB7E /* BookmarkReponse.swift in Sources */, B5F323E92A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift in Sources */, @@ -1655,7 +1604,6 @@ B512205A2A5FAA47006CBE2D /* ImageLiterals.swift in Sources */, B57BEB612A60E97100D1727C /* NetworkErrorCode.swift in Sources */, C07CB81A2A62C54D000198CC /* TodayModel.swift in Sources */, - C0903D022AAAD86A0014786F /* AuthAPI.swift in Sources */, C06E38212A65351600B00600 /* SignUpRequest.swift in Sources */, C09A33232A62D46300B40770 /* LHToastView.swift in Sources */, B532E8632A5529B000F0DB19 /* HTTPHeaderField.swift in Sources */, @@ -1664,13 +1612,10 @@ C0DF037D2A5A9CFD0037F740 /* LoginViewController.swift in Sources */, C0DF03A42A5CACF00037F740 /* OnboardingPageType.swift in Sources */, C09A33242A630A6400B40770 /* BookmarkViewController.swift in Sources */, - C06E382A2A662E3700B00600 /* ArticleService.swift in Sources */, C0DF03352A5A93530037F740 /* UIControl+.swift in Sources */, C0F029E22A5FAE2700E0D185 /* LHOnboardingErrorLabel.swift in Sources */, B57BEB702A6275F500D1727C /* ViewControllerServiceable.swift in Sources */, - 4AD6A34C2AB1AB6700977224 /* BookmarkAPI.swift in Sources */, C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */, - B59893192A5D41F600CE1FEB /* KingfisherService.swift in Sources */, C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */, B59892EE2A5B9AF300CE1FEB /* NavigationBarLayoutManager.swift in Sources */, C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */, @@ -1749,7 +1694,6 @@ B51220602A60111C006CBE2D /* Token.swift in Sources */, B5C6A2C82A5EF4EB0021BE5E /* ArticleDetail.swift in Sources */, C0DF03312A5A92730037F740 /* CollectionViewCellRegisterDequeueProtocol.swift in Sources */, - F4C60E1D2A66B4CE006BBADE /* CurriculumViewService.swift in Sources */, C06E381D2A65348A00B00600 /* LoginRequest.swift in Sources */, C0DF033D2A5A95420037F740 /* UIStackView+.swift in Sources */, 4A8980CC2A61795500746C58 /* MyPageHeaderView.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift deleted file mode 100644 index 7e807b72..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/AuthAPI.swift +++ /dev/null @@ -1,96 +0,0 @@ -// -// AuthAPI.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/09/08. -// - -//import Foundation -// -//protocol AuthAPIProtocol { -// func reissueToken(token: Token) async throws -> Token? -// func login(type: LoginType, kakaoToken: String) async throws -// func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws -// @discardableResult func logout(token: UserDefaultToken) async throws -> String? -// func resignUser() async throws -//} -// -//final class AuthAPI: AuthAPIProtocol { -// -// private let apiService: Requestable -// -// init(apiService: Requestable) { -// self.apiService = apiService -// } -// -// func reissueToken(token: Token) async throws -> Token? { -// let urlRequest = try makeReissueTokenUrlRequest(token: token) -// return try await apiService.request(urlRequest) -// } -// -// func login(type: LoginType, kakaoToken: String) async throws { -// let urlRequest = try makeLoginUrlRequest(type: type, kakaoToken: kakaoToken) -// userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) -// } -// -// func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { -// let urlRequest = try makeSignUpUrlRequest(type: type, onboardingModel: onboardingModel) -// userdefaultsSettingWhenUserIn(model: try await apiService.request(urlRequest)) -// } -// -// func logout(token: UserDefaultToken) async throws -> String? { -// let urlRequest = try makeLogoutUrlRequest() -// return try await apiService.request(urlRequest) -// } -// -// func resignUser() async throws { -// let urlRequest = try makeResignUserUrlRequest() -// _ = try await URLSession.shared.data(for: urlRequest) -// UserDefaultsManager.tokenKey?.refreshToken = nil -// } -//} -// -//extension AuthAPI { -// private func userdefaultsSettingWhenUserIn(model: Token?) { -// UserDefaultsManager.tokenKey?.accessToken = model?.accessToken -// UserDefaultsManager.tokenKey?.refreshToken = model?.refreshToken -// } -//} -// -//extension AuthAPI { -// func makeResignUserUrlRequest() throws -> URLRequest { -// return try NetworkRequest(path: "/v1/member", httpMethod: .delete).makeURLRequest(isLogined: true) -// } -// -// func makeLogoutUrlRequest() throws -> URLRequest { -// return try NetworkRequest(path: "/v1/auth/logout", httpMethod: .post).makeURLRequest(isLogined: true) -// } -// -// func makeSignUpUrlRequest(type: LoginType, onboardingModel: UserOnboardingModel) throws -> URLRequest { -// guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken, -// let kakaoToken = onboardingModel.kakaoAccessToken, -// let pregnantWeeks = onboardingModel.pregnacny, -// let babyNickname = onboardingModel.fetalNickname else { throw NetworkError.badCasting } -// let requestModel = SignUpRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken, pregnantWeeks: pregnantWeeks, babyNickname: babyNickname) -// let param = requestModel.toDictionary() -// let body = try JSONSerialization.data(withJSONObject: param) -// return try NetworkRequest(path: "/v1/auth/signup", httpMethod: .post, body: body).makeURLRequest(isLogined: false) -// } -// -// func makeReissueTokenUrlRequest(token: Token) throws -> URLRequest { -// let params = token.toDictionary() -// let body = try JSONSerialization.data(withJSONObject: params, options: []) -// return try NetworkRequest(path: "/v1/auth/reissue", httpMethod: .post, body: body) -// .makeURLRequest(isLogined: false) -// } -// -// func makeLoginUrlRequest(type: LoginType, kakaoToken: String) throws -> URLRequest { -// guard let fcmToken = UserDefaultsManager.tokenKey?.fcmToken else { -// throw NetworkError.clientError(code: "", message: "\(String(describing: UserDefaultsManager.tokenKey))") -// } -// let loginRequest = LoginRequest(socialType: type.raw, token: kakaoToken, fcmToken: fcmToken) -// let param = loginRequest.toDictionary() -// let body = try JSONSerialization.data(withJSONObject: param) -// return try NetworkRequest(path: "/v1/auth/login", httpMethod: .post, body: body).makeURLRequest(isLogined: false) -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift deleted file mode 100644 index ca8abe51..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/BookmarkAPI.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// BookmarkAPI.swift -// LionHeart-iOS -// -// Created by 황찬미 on 2023/09/13. -// - -//import Foundation -// -//protocol BookmarkAPIProtocol { -// func getBookmark() async throws -> BookmarkResponse? -// func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? -//} -// -//final class BookmarkAPI: BookmarkAPIProtocol { -// -// private let apiService: Requestable -// -// init(apiService: Requestable) { -// self.apiService = apiService -// } -// -// func getBookmark() async throws -> BookmarkResponse? { -// let request = try makeGetBookmarkUrlRequest() -// return try await apiService.request(request) -// } -// -// func postBookmark(model: BookmarkRequest) async throws -> BookmarkResponse? { -// let request = try makePostBookmakrUrlRequest(model: model) -// return try await apiService.request(request) -// } -//} -// -// -///// url request method -//extension BookmarkAPI { -// func makeGetBookmarkUrlRequest() throws -> URLRequest { -// return try NetworkRequest(path: "/v1/article/bookmarks", httpMethod: .get).makeURLRequest(isLogined: true) -// } -// -// func makePostBookmakrUrlRequest(model: BookmarkRequest) throws -> URLRequest { -// let param = model.toDictionary() -// let body = try JSONSerialization.data(withJSONObject: param) -// -// return try NetworkRequest(path: "/v1/article/bookmark", httpMethod: .post, body: body).makeURLRequest(isLogined: true) -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift deleted file mode 100644 index 4a970203..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/ChallengeAPI.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// ChallengeAPI.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/09/23. -// - -//import Foundation -// -//protocol ChallengeServiceAPIProtocol { -// func inquireChallengeInfo() async throws -> ChallengeDataResponse? -//} -// -//final class ChallengeAPI: ChallengeServiceAPIProtocol { -// -// private let apiService: Requestable -// -// init(apiService: Requestable) { -// self.apiService = apiService -// } -// -// func inquireChallengeInfo() async throws -> ChallengeDataResponse? { -// let urlRequest = try NetworkRequest(path: "/v1/challenge/progress", httpMethod: .get).makeURLRequest(isLogined: true) -// return try await apiService.request(urlRequest) -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift b/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift deleted file mode 100644 index 2ff1331a..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/API/MyPageAPI.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// MyPageAPI.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/09/10. -// - -import Foundation - -//protocol MyPageAPIProtocol { -// func getMyPage() async throws -> MyPageResponse? -//} -// -//final class MyPageAPI: MyPageAPIProtocol { -// -// private let apiService: Requestable -// -// init(apiService: Requestable) { -// self.apiService = apiService -// } -// -// func getMyPage() async throws -> MyPageResponse? { -// let urlRequest = try NetworkRequest(path: "/v1/member/profile", httpMethod: .get).makeURLRequest(isLogined: true) -// return try await apiService.request(urlRequest) -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift deleted file mode 100644 index d4cbe79c..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/ArticleService.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// ArticleService.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/18. -// - -import UIKit - -//struct Query: Request { -// let category: String -//} -// -//final class ArticleService: Serviceable { -// static let shared = ArticleService() -// private init() {} -// -// func inquiryTodayArticle() async throws -> TodayArticle { -// let urlRequest = try NetworkRequest(path: "/v1/article/today", httpMethod: .get).makeURLRequest(isLogined: true) -// let (data, _) = try await URLSession.shared.data(for: urlRequest) -// -// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: TodayArticleResponse.self) -// else { return TodayArticle.emptyArticle } -// -// return .init(fetalNickname: model.babyNickname, articleTitle: model.title, articleDescription: model.editorNoteContent, currentWeek: model.week, currentDay: model.day, mainImageURL: model.mainImageUrl, aticleID: model.articleId) -// } -// -// func getArticleDetail(articleId: Int) async throws -> [BlockTypeAppData] { -// let urlRequest = try NetworkRequest(path: "/v1/article/\(articleId)", httpMethod: .get).makeURLRequest(isLogined: true) -// -// let (data, _) = try await URLSession.shared.data(for: urlRequest) -// -// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: ArticleDetail.self) else { -// return [] -// } -// -// return model.toAppData() -// } -// -// func getArticleListByCategory(categoryString: String) async throws -> CurriculumWeekData { -// let query = Query(category: categoryString) -// -// let urlRequest = try NetworkRequest(path: "/v1/article", httpMethod: .get, query: query).makeURLRequest(isLogined: true) -// -// let (data, _) = try await URLSession.shared.data(for: urlRequest) -// -// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CategoryList.self) else { -// return .init(articleData: [], week: nil) -// } -// -// return model.toAppData() -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift deleted file mode 100644 index 7ba2c36a..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/AuthMyPageServiceWrapper.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// AuthMyPageServiceWrapper.swift -// LionHeart-iOS -// -// Created by 김민재 on 2023/09/07. -// - -import Foundation - -//final class AuthMyPageServiceWrapper: AuthServiceProtocol, MyPageServiceProtocol { -// -// private let authAPIService: AuthAPIProtocol -// private let mypageAPIService: MyPageAPIProtocol -// -// init(authAPIService: AuthAPIProtocol, mypageAPIService: MyPageAPIProtocol) { -// self.authAPIService = authAPIService -// self.mypageAPIService = mypageAPIService -// } -// -// func getMyPage() async throws -> MyPageAppData { -// guard let model = try await mypageAPIService.getMyPage() -// else { return MyPageAppData.empty } -// return MyPageAppData(badgeImage: model.level, nickname: model.babyNickname, isAlarm: model.notificationStatus) -// } -// -// func reissueToken(token: Token) async throws -> Token? { -// return try await authAPIService.reissueToken(token: token) -// } -// -// func login(type: LoginType, kakaoToken: String) async throws { -// try await authAPIService.login(type: type, kakaoToken: kakaoToken) -// } -// -// func signUp(type: LoginType, onboardingModel: UserOnboardingModel) async throws { -// try await authAPIService.signUp(type: type, onboardingModel: onboardingModel) -// } -// -// func resignUser() async throws { -// try await authAPIService.resignUser() -// } -// -// func logout(token: UserDefaultToken) async throws { -// try await authAPIService.logout(token: token) -// } -// -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift deleted file mode 100644 index 8067cd82..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/BookmarkService.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// BookmarkService.swift -// LionHeart-iOS -// -// Created by 황찬미 on 2023/07/17. -// - -import Foundation - -///// 내 북마크 -//protocol BookmarkInOutServiceProtocol { -// func postBookmark(model: BookmarkRequest) async throws -// func getBookmark() async throws -> BookmarkAppData -//} -// -//// 동뷰, 성뷰 -//protocol BookmarkOutProtocol { -// func postBookmark(model: BookmarkRequest) async throws -//} -// -//final class BookmarkService: BookmarkInOutServiceProtocol, BookmarkOutProtocol { -// -// private let bookmarkAPIProtocol: BookmarkAPIProtocol -// -// init(bookmarkAPIProtocol: BookmarkAPIProtocol) { -// self.bookmarkAPIProtocol = bookmarkAPIProtocol -// } -// -// func postBookmark(model: BookmarkRequest) async throws { -// guard let data = try await bookmarkAPIProtocol.postBookmark(model: model) else { return } -// print(data) -// } -// -// func getBookmark() async throws -> BookmarkAppData { -// guard let data = try await bookmarkAPIProtocol.getBookmark() else { return BookmarkAppData(nickName: "", articleSummaries: [])} -// return data.toAppData() -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift deleted file mode 100644 index 58da2089..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/ChallengeService.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// ChallengeService.swift -// LionHeart-iOS -// -// Created by 김동현 on 2023/07/19. -// - -import Foundation - -//final class ChallengeService: ChallengeServiceProtocol { -// -// private let challengeAPIService: ChallengeServiceAPIProtocol -// -// init(challengeAPIService: ChallengeServiceAPIProtocol) { -// self.challengeAPIService = challengeAPIService -// } -// -// func inquireChallengeInfo() async throws -> ChallengeData { -// guard let model = try await challengeAPIService.inquireChallengeInfo() else { return ChallengeData.empty } -// return toAppData(from: model) -// } -//} -// -//extension ChallengeService { -// func toAppData(from input: ChallengeDataResponse) -> ChallengeData { -// return .init(babyDaddyName: input.babyNickname, howLongDay: input.day, daddyLevel: input.level, daddyAttendances: input.attendances) -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift deleted file mode 100644 index e006dcf3..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/CurriculumViewService.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// CurriculumViewService.swift -// LionHeart-iOS -// -// Created by 곽성준 on 2023/07/18. -// - -import UIKit - -//final class CurriculumService: Serviceable { -// -// static let shared = CurriculumService() -// -// private init() {} -// -// func getCurriculumServiceInfo() async throws -> CurriculumResponse? { -// let urlRequest = try NetworkRequest(path: "/v1/curriculum/progress", httpMethod: .get).makeURLRequest(isLogined: true) -// -// let (data, _) = try await URLSession.shared.data(for: urlRequest) -// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CurriculumResponse.self) else { return UserInfoData.emptyUserInfoData } -// -// return UserInfoData(userWeekInfo: model.week, userDayInfo: model.day, progress: model.progress + 1, remainingDay: model.remainingDay) -// } -// -// func getArticleListByWeekInfo(week: Int) async throws -> CurriculumListByWeekResponse? { -// let urlRequest = try NetworkRequest(path: "v1/article/week/\(week)", httpMethod: .get).makeURLRequest(isLogined: true) -// -// let (data, _) = try await URLSession.shared.data(for: urlRequest) -// guard let model = try dataDecodeAndhandleErrorCode(data: data, decodeType: CurriculumListByWeekResponse.self) else { -// return .init(articleData: [], week: 0) -// } -// -// return model.toAppData() -// } -//} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Services/KingfisherService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Services/KingfisherService.swift deleted file mode 100644 index dc889e6e..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Network/Services/KingfisherService.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// KingfisherService.swift -// LionHeart-iOS -// -// Created by 김민재 on 2023/07/11. -// - -import UIKit - -import Kingfisher - - -final class LHKingFisherService { - - static func fetchImage(with urlString: String) async throws -> UIImage? { - typealias ImageContinuation = CheckedContinuation - - return try await withCheckedThrowingContinuation { ImageContinuation in - - guard let url = URL(string: urlString) else { - return ImageContinuation.resume(throwing: NetworkError.urlEncodingError) - } - - let resource = KF.ImageResource(downloadURL: url, cacheKey: urlString) - KingfisherManager.shared.retrieveImage(with: resource) { result in - switch result { - case .success(let imageResult): - let image = imageResult.image - return ImageContinuation.resume(returning: image) - case .failure(_): - return ImageContinuation.resume(throwing: NetworkError.fetchImageError) - } - } - } - - } - - func unwrapTaskArray(dataTasks: [Task], type: T.Type) async -> [T] { - let tasks = dataTasks.map { task in - Task { - return try await task.result.get() - } - } - - var result: [T?] = [] - for task in tasks { - result.append(try? await task.result.get()) - } - return result.compactMap { $0 } - } - -} From dd26163c8ac4b5c0355246f9e53b341173617ffe Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 15:55:55 +0900 Subject: [PATCH 21/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20LHLabel=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/UIComponents/LHLabel.swift | 22 +++++++ .../Network/Service/LHKingfisherService.swift | 52 ++++++++++++++++ .../ChallengeViewController.swift | 61 +++++-------------- .../GetFetalNicknameViewController.swift | 2 +- .../OnboardingViewController.swift | 4 +- 5 files changed, 91 insertions(+), 50 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Network/Service/LHKingfisherService.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift new file mode 100644 index 00000000..e58c30ec --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift @@ -0,0 +1,22 @@ +// +// LHLabel.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import UIKit + +final class LHLabel: UILabel { + + init(type: Font.PretendardType, color: Palette, alignment: NSTextAlignment = .center) { + super.init(frame: .zero) + self.font = .pretendard(type) + self.textColor = .designSystem(color) + self.textAlignment = alignment + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Service/LHKingfisherService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Service/LHKingfisherService.swift new file mode 100644 index 00000000..dc889e6e --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Network/Service/LHKingfisherService.swift @@ -0,0 +1,52 @@ +// +// KingfisherService.swift +// LionHeart-iOS +// +// Created by 김민재 on 2023/07/11. +// + +import UIKit + +import Kingfisher + + +final class LHKingFisherService { + + static func fetchImage(with urlString: String) async throws -> UIImage? { + typealias ImageContinuation = CheckedContinuation + + return try await withCheckedThrowingContinuation { ImageContinuation in + + guard let url = URL(string: urlString) else { + return ImageContinuation.resume(throwing: NetworkError.urlEncodingError) + } + + let resource = KF.ImageResource(downloadURL: url, cacheKey: urlString) + KingfisherManager.shared.retrieveImage(with: resource) { result in + switch result { + case .success(let imageResult): + let image = imageResult.image + return ImageContinuation.resume(returning: image) + case .failure(_): + return ImageContinuation.resume(throwing: NetworkError.fetchImageError) + } + } + } + + } + + func unwrapTaskArray(dataTasks: [Task], type: T.Type) async -> [T] { + let tasks = dataTasks.map { task in + Task { + return try await task.result.get() + } + } + + var result: [T?] = [] + for task in tasks { + result.append(try? await task.result.get()) + } + return result.compactMap { $0 } + } + +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index f98acba4..17953a82 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -28,64 +28,24 @@ final class ChallengeViewController: UIViewController { didSet { guard let babyNickname = inputData?.babyDaddyName else { return } configureData(babyNickname) - } } - init(manager: ChallengeManager) { - self.manager = manager - super.init(nibName: nil, bundle: nil) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private let leftSeperateLine: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.background) - return view - }() - - private let rightSeperateLine: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.background) - return view - }() - + private let leftSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) + private let rightSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) private var tags: [String] = [] - private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) - private let nicknameLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2R) - label.textColor = .designSystem(.gray200) - label.textAlignment = .center - return label - }() - - private let challengeDayLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head3) - label.textColor = .designSystem(.white) - label.textAlignment = .center - return label - }() + private let nicknameLabel = LHLabel(type: .body2R, color: .gray200) + private let challengeDayLabel = LHLabel(type: .head3, color: .white) private let levelBadge: UIImageView = { let imageView = UIImageView() imageView.image = ImageLiterals.ChallengeBadge.level05 return imageView }() - - private let challengelevelLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body4) - label.textColor = .designSystem(.gray500) - label.textAlignment = .center - return label - }() + + private let challengelevelLabel = LHLabel(type: .body4, color: .gray500) private lazy var lottieImageView: LottieAnimationView = { let view = LottieAnimationView() @@ -101,6 +61,15 @@ final class ChallengeViewController: UIViewController { return collectionView }() + init(manager: ChallengeManager) { + self.manager = manager + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) Task { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift index 77efe532..46d8e77c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift @@ -22,7 +22,7 @@ final class GetFetalNicknameViewController: UIViewController { private let descriptionLabel = LHOnboardingDescriptionLabel("아직이라면, 닉네임을 적어주세요.") private let fetalNickNameErrorLabel = LHOnboardingErrorLabel() private let fetalNickNameTextfield = NHOnboardingTextfield(textFieldType: .fetalNickname) - private let textFieldUnderLine = NHUnderLine(lineColor: .designSystem(.lionRed)) + private let textFieldUnderLine = LHUnderLine(lineColor: .designSystem(.lionRed)) public override func viewDidLoad() { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift index bfb772b5..8e2f17d1 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift @@ -15,17 +15,15 @@ protocol OnboardingManager { } final class OnboardingViewController: UIViewController { - + typealias OnboardingViews = [UIViewController] private let manager: OnboardingManager - /// passing data property private var fetalNickName: String? private var pregnancy: Int? private var kakaoAccessToken: String? - /// component property private let nextButton = LHOnboardingButton() private let onboardingProgressView = LHProgressView() private let onboardingViewController = LHOnboardingPageViewController() From a6d54ece75d20e1ceefc434e636e83e5dc40883b Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 15:56:12 +0900 Subject: [PATCH 22/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20UnderLine=EA=B3=B5?= =?UTF-8?q?=EC=9A=A9=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 16 ++++++++++++---- .../{NHUnderLine.swift => LHUnderLine.swift} | 4 ++-- .../Cells/CurriculumTableViewCell.swift | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) rename LionHeart-iOS/LionHeart-iOS/Global/UIComponents/{NHUnderLine.swift => LHUnderLine.swift} (88%) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index e3b9f558..848516bb 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -128,6 +128,8 @@ C09A33222A62D46300B40770 /* LHToast.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A33202A62D46300B40770 /* LHToast.swift */; }; C09A33232A62D46300B40770 /* LHToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A33212A62D46300B40770 /* LHToastView.swift */; }; C09A33242A630A6400B40770 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */; }; + C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */; }; + C0B15E152AC011840058D56B /* LHLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E142AC011840058D56B /* LHLabel.swift */; }; C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */; }; C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */; }; C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032E2A5A92170037F740 /* NameSpace.swift */; }; @@ -178,7 +180,7 @@ C0F029DE2A5FAC6100E0D185 /* LHOnboardingTitleLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029DD2A5FAC6100E0D185 /* LHOnboardingTitleLabel.swift */; }; C0F029E02A5FAD1200E0D185 /* LHOnboardingDescriptionLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029DF2A5FAD1200E0D185 /* LHOnboardingDescriptionLabel.swift */; }; C0F029E22A5FAE2700E0D185 /* LHOnboardingErrorLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E12A5FAE2700E0D185 /* LHOnboardingErrorLabel.swift */; }; - C0F029E42A5FB08700E0D185 /* NHUnderLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E32A5FB08700E0D185 /* NHUnderLine.swift */; }; + C0F029E42A5FB08700E0D185 /* LHUnderLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E32A5FB08700E0D185 /* LHUnderLine.swift */; }; C0F029E62A5FB9E000E0D185 /* ContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E52A5FB9DF00E0D185 /* ContainerView.swift */; }; C0F029E82A5FB9EF00E0D185 /* RoundContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E72A5FB9EF00E0D185 /* RoundContainerView.swift */; }; C0F029EA2A5FD32900E0D185 /* LHRoundButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E92A5FD32900E0D185 /* LHRoundButton.swift */; }; @@ -344,6 +346,8 @@ C09217722A61895A00231C66 /* UIWindow+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIWindow+.swift"; sourceTree = ""; }; C09A33202A62D46300B40770 /* LHToast.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LHToast.swift; sourceTree = ""; }; C09A33212A62D46300B40770 /* LHToastView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LHToastView.swift; sourceTree = ""; }; + C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHKingfisherService.swift; sourceTree = ""; }; + C0B15E142AC011840058D56B /* LHLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLabel.swift; sourceTree = ""; }; C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellRegisterDequeueProtocol.swift; sourceTree = ""; }; C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTypeProtocol.swift; sourceTree = ""; }; C0DF032E2A5A92170037F740 /* NameSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameSpace.swift; sourceTree = ""; }; @@ -395,7 +399,7 @@ C0F029DD2A5FAC6100E0D185 /* LHOnboardingTitleLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHOnboardingTitleLabel.swift; sourceTree = ""; }; C0F029DF2A5FAD1200E0D185 /* LHOnboardingDescriptionLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHOnboardingDescriptionLabel.swift; sourceTree = ""; }; C0F029E12A5FAE2700E0D185 /* LHOnboardingErrorLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHOnboardingErrorLabel.swift; sourceTree = ""; }; - C0F029E32A5FB08700E0D185 /* NHUnderLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NHUnderLine.swift; sourceTree = ""; }; + C0F029E32A5FB08700E0D185 /* LHUnderLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHUnderLine.swift; sourceTree = ""; }; C0F029E52A5FB9DF00E0D185 /* ContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerView.swift; sourceTree = ""; }; C0F029E72A5FB9EF00E0D185 /* RoundContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundContainerView.swift; sourceTree = ""; }; C0F029E92A5FD32900E0D185 /* LHRoundButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHRoundButton.swift; sourceTree = ""; }; @@ -733,7 +737,8 @@ children = ( C09A331F2A62D46300B40770 /* LHToast */, B59892E02A5AF39300CE1FEB /* LHNavigationBarView.swift */, - C0F029E32A5FB08700E0D185 /* NHUnderLine.swift */, + C0F029E32A5FB08700E0D185 /* LHUnderLine.swift */, + C0B15E142AC011840058D56B /* LHLabel.swift */, ); path = UIComponents; sourceTree = ""; @@ -1240,6 +1245,7 @@ C0856B762ABFC4EA0026D9F8 /* MyPageServiceImpl.swift */, C0856B782ABFC56E0026D9F8 /* AuthServiceImpl.swift */, C0856B822ABFCFBE0026D9F8 /* CurriculumServiceImpl.swift */, + C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */, ); path = Service; sourceTree = ""; @@ -1556,7 +1562,7 @@ buildActionMask = 2147483647; files = ( F47329E12A66F5D0001605D4 /* CurriculumResponse.swift in Sources */, - C0F029E42A5FB08700E0D185 /* NHUnderLine.swift in Sources */, + C0F029E42A5FB08700E0D185 /* LHUnderLine.swift in Sources */, C06E38282A662D8700B00600 /* TodayArticleResponse.swift in Sources */, C0DF03732A5A9CB50037F740 /* TodayViewController.swift in Sources */, C00780B72A5FFE0E0043EB36 /* UILabel+.swift in Sources */, @@ -1664,6 +1670,7 @@ 4A8980C52A611EE200746C58 /* MyPageProfileCollectionViewCell.swift in Sources */, D3BA0B742A5CFA7B00B6361F /* ArticleCategoryModel.swift in Sources */, C0DF033F2A5A959A0037F740 /* UIButton+.swift in Sources */, + C0B15E152AC011840058D56B /* LHLabel.swift in Sources */, F4DB30B02A611C9700413EB9 /* CurriculumListByWeekData.swift in Sources */, C0DF034D2A5A9B8D0037F740 /* (null) in Sources */, C09A33222A62D46300B40770 /* LHToast.swift in Sources */, @@ -1702,6 +1709,7 @@ C0F029C92A5EFC1F00E0D185 /* LHOnboardingPageViewController.swift in Sources */, C0DF03412A5A95E40037F740 /* UIImage+.swift in Sources */, C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */, + C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */, 4A8980CE2A617F7100746C58 /* CollectionHeaderViewRegisterDequeueProtocol.swift in Sources */, 4A860AD62A6265B2002BA428 /* BookmarkModel.swift in Sources */, B5C6A2BE2A5DE6590021BE5E /* GeneralTitleTableViewCell.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/NHUnderLine.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift similarity index 88% rename from LionHeart-iOS/LionHeart-iOS/Global/UIComponents/NHUnderLine.swift rename to LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift index 6269e02a..5d8dfc82 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/NHUnderLine.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift @@ -1,5 +1,5 @@ // -// NHUnderLine.swift +// LHUnderLine.swift // LionHeart-iOS // // Created by uiskim on 2023/07/13. @@ -7,7 +7,7 @@ import UIKit -final class NHUnderLine: UIView { +final class LHUnderLine: UIView { private let lineColor: UIColor? diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift index 2db23f4f..5c63cf80 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift @@ -60,7 +60,6 @@ final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDeque private let contentImageView: UIImageView = { let imageView = UIImageView() - imageView.backgroundColor = .designSystem(.lionRed) imageView.isUserInteractionEnabled = true return imageView }() From aadf3b849896785540fca4466014fefbbf54c529 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 16:17:34 +0900 Subject: [PATCH 23/39] =?UTF-8?q?=F0=9F=92=84=20LHLottie,=20LHImageView=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 12 +++++++++++ .../Global/UIComponents/LHImageView.swift | 20 +++++++++++++++++++ .../Global/UIComponents/LHLottie.swift | 20 +++++++++++++++++++ .../ChallengeViewController.swift | 16 ++------------- .../Cells/CurriculumTableViewCell.swift | 1 + .../CurriculumListByWeekViewController.swift | 1 - 6 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 848516bb..79ecf75e 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -130,6 +130,9 @@ C09A33242A630A6400B40770 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */; }; C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */; }; C0B15E152AC011840058D56B /* LHLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E142AC011840058D56B /* LHLabel.swift */; }; + C0B15E172AC015360058D56B /* LHImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E162AC015360058D56B /* LHImageView.swift */; }; + C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E182AC015FE0058D56B /* LHLottie.swift */; }; + C0B15E1B2AC0169D0058D56B /* LHCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */; }; C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */; }; C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */; }; C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032E2A5A92170037F740 /* NameSpace.swift */; }; @@ -348,6 +351,9 @@ C09A33212A62D46300B40770 /* LHToastView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LHToastView.swift; sourceTree = ""; }; C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHKingfisherService.swift; sourceTree = ""; }; C0B15E142AC011840058D56B /* LHLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLabel.swift; sourceTree = ""; }; + C0B15E162AC015360058D56B /* LHImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHImageView.swift; sourceTree = ""; }; + C0B15E182AC015FE0058D56B /* LHLottie.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLottie.swift; sourceTree = ""; }; + C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHCollectionView.swift; sourceTree = ""; }; C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellRegisterDequeueProtocol.swift; sourceTree = ""; }; C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTypeProtocol.swift; sourceTree = ""; }; C0DF032E2A5A92170037F740 /* NameSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameSpace.swift; sourceTree = ""; }; @@ -739,6 +745,9 @@ B59892E02A5AF39300CE1FEB /* LHNavigationBarView.swift */, C0F029E32A5FB08700E0D185 /* LHUnderLine.swift */, C0B15E142AC011840058D56B /* LHLabel.swift */, + C0B15E162AC015360058D56B /* LHImageView.swift */, + C0B15E182AC015FE0058D56B /* LHLottie.swift */, + C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */, ); path = UIComponents; sourceTree = ""; @@ -1567,6 +1576,7 @@ C0DF03732A5A9CB50037F740 /* TodayViewController.swift in Sources */, C00780B72A5FFE0E0043EB36 /* UILabel+.swift in Sources */, C0DF03942A5B8C610037F740 /* UIFont+.swift in Sources */, + C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */, C0DF034F2A5A9B9C0037F740 /* MyPageViewController.swift in Sources */, C0DF03A92A5CF0460037F740 /* UserOnboardingModel.swift in Sources */, B5C6A2B42A5DB11A0021BE5E /* ThumnailTableViewCell.swift in Sources */, @@ -1594,6 +1604,7 @@ F4DB30B82A612D2800413EB9 /* CurriculumArticleByWeekTableViewCell.swift in Sources */, C0DF03452A5A9A910037F740 /* CurriculumTableViewCell.swift in Sources */, C07CB81E2A62C5B1000198CC /* TodayArticleView.swift in Sources */, + C0B15E1B2AC0169D0058D56B /* LHCollectionView.swift in Sources */, F4490C072A5CEEA300A6D9D7 /* CurriculumDummyData.swift in Sources */, F4DB30AE2A611C7C00413EB9 /* CurriculumListByWeekViewController.swift in Sources */, B59892EC2A5B94E100CE1FEB /* UIApplication+.swift in Sources */, @@ -1687,6 +1698,7 @@ C0F029E02A5FAD1200E0D185 /* LHOnboardingDescriptionLabel.swift in Sources */, C0DF03492A5A9ACB0037F740 /* DummyModel.swift in Sources */, C0856B792ABFC56E0026D9F8 /* AuthServiceImpl.swift in Sources */, + C0B15E172AC015360058D56B /* LHImageView.swift in Sources */, C09217732A61895A00231C66 /* UIWindow+.swift in Sources */, D3BA0B712A5CFA2300B6361F /* ArticleCategoryCollectionViewCell.swift in Sources */, B532E8342A5525C600F0DB19 /* SceneDelegate.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift new file mode 100644 index 00000000..33099851 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift @@ -0,0 +1,20 @@ +// +// LHImageView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import UIKit + +final class LHImageView: UIImageView { + + init(in image: UIImage? = nil) { + super.init(frame: .zero) + self.image = image + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift new file mode 100644 index 00000000..04c41e90 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift @@ -0,0 +1,20 @@ +// +// LHLottie.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import Foundation +import Lottie + +final class LHLottie: LottieAnimationView { + init() { + super.init(frame: .zero) + self.contentMode = .scaleToFill + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index 17953a82..806509a7 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -35,23 +35,11 @@ final class ChallengeViewController: UIViewController { private let rightSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) private var tags: [String] = [] private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) - private let nicknameLabel = LHLabel(type: .body2R, color: .gray200) private let challengeDayLabel = LHLabel(type: .head3, color: .white) - - private let levelBadge: UIImageView = { - let imageView = UIImageView() - imageView.image = ImageLiterals.ChallengeBadge.level05 - return imageView - }() - + private let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05) private let challengelevelLabel = LHLabel(type: .body4, color: .gray500) - - private lazy var lottieImageView: LottieAnimationView = { - let view = LottieAnimationView() - view.contentMode = .scaleToFill - return view - }() + private lazy var lottieImageView = LHLottie() private let challengeDayCheckCollectionView: UICollectionView = { let layout = UICollectionViewFlowLayout() diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift index 5c63cf80..f2a19d3f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift @@ -63,6 +63,7 @@ final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDeque imageView.isUserInteractionEnabled = true return imageView }() + private let contentTextLabel: UILabel = { let label = UILabel() label.font = .pretendard(.body3R) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift index af3d9e7b..65b030f8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift @@ -77,7 +77,6 @@ final class CurriculumListByWeekViewController: UIViewController { layout.scrollDirection = .horizontal let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.showsHorizontalScrollIndicator = false - collectionView.isPagingEnabled = false collectionView.isScrollEnabled = false collectionView.backgroundColor = .designSystem(.background) return collectionView From 931d936ff25368174878544105d5cc684885919b Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 16:17:49 +0900 Subject: [PATCH 24/39] =?UTF-8?q?=F0=9F=92=84=20LHCollectionView=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/LHCollectionView.swift | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift new file mode 100644 index 00000000..8d16c95e --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift @@ -0,0 +1,23 @@ +// +// LHCollectionView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import UIKit + +final class LHCollection: UICollectionView { + + init(color: UIColor? = .designSystem(.background), scroll: Bool = true) { + super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + self.backgroundColor = color + self.showsVerticalScrollIndicator = false + self.showsHorizontalScrollIndicator = false + self.isScrollEnabled = scroll + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From 7ea6db2374e1f6b43e0ff2f1a8faf421ef247009 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 16:37:38 +0900 Subject: [PATCH 25/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=EB=B7=B0=20UI=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20=EB=A1=9C=EC=A7=81=EC=A0=95?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/LHCollectionView.swift | 2 +- .../ChallengeViewController.swift | 105 ++++++++---------- 2 files changed, 47 insertions(+), 60 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift index 8d16c95e..fb734f8a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift @@ -7,7 +7,7 @@ import UIKit -final class LHCollection: UICollectionView { +final class LHCollectionView: UICollectionView { init(color: UIColor? = .designSystem(.background), scroll: Bool = true) { super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index 806509a7..ff982e5f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -2,7 +2,7 @@ // ChallengeViewController.swift // LionHeart-iOS // -// Created by 김동현 on 2023/07/13. +// Created by 김의성 on 2023/09/24. // Copyright (c) 2023 Challenge. All rights reserved. // @@ -17,37 +17,24 @@ protocol ChallengeManager { final class ChallengeViewController: UIViewController { - private enum Size { - static let cellOffset: CGFloat = 40 - static let numberOfCellsinRow: CGFloat = 0 - } - private var manager: ChallengeManager - var inputData: ChallengeData? { + private var inputData: ChallengeData? { didSet { - guard let babyNickname = inputData?.babyDaddyName else { return } - configureData(babyNickname) + guard let inputData else { return } + configureData(inputData) } } private let leftSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) private let rightSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) - private var tags: [String] = [] private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) private let nicknameLabel = LHLabel(type: .body2R, color: .gray200) private let challengeDayLabel = LHLabel(type: .head3, color: .white) - private let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05) private let challengelevelLabel = LHLabel(type: .body4, color: .gray500) + private let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05) private lazy var lottieImageView = LHLottie() - - private let challengeDayCheckCollectionView: UICollectionView = { - let layout = UICollectionViewFlowLayout() - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.backgroundColor = .designSystem(.background) - collectionView.showsVerticalScrollIndicator = false - return collectionView - }() + private let challengeDayCheckCollectionView = LHCollectionView() init(manager: ChallengeManager) { self.manager = manager @@ -60,19 +47,7 @@ final class ChallengeViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - Task { - do { - self.showLoading() - let model = try await manager.inquireChallengeInfo() - self.inputData = model - self.tags = model.daddyAttendances - self.challengeDayCheckCollectionView.reloadData() - self.hideLoading() - } catch { - guard let error = error as? NetworkError else { return } - handleError(error) - } - } + setUIFromNetworking() } override func viewDidLoad() { @@ -93,14 +68,47 @@ final class ChallengeViewController: UIViewController { } private extension ChallengeViewController { + func configureData(_ input: ChallengeData) { + self.nicknameLabel.text = "\(input.babyDaddyName)아빠 님," + self.challengeDayLabel.text = "\(input.howLongDay)일째 도전 중" + self.levelBadge.image = BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeImage + self.lottieImageView.animation = .named(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.progreddbarLottie ?? "") + self.lottieImageView.play() + let fullText = "사자력 Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1) + let attributtedString = NSMutableAttributedString(string: fullText) + attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.designSystem(.white) ?? .white, range: (fullText as NSString).range(of: "Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1))) + self.challengelevelLabel.attributedText = attributtedString + } + + func setUIFromNetworking() { + Task { + do { + self.showLoading() + self.inputData = try await manager.inquireChallengeInfo() + self.challengeDayCheckCollectionView.reloadData() + self.hideLoading() + } catch { + guard let error = error as? NetworkError else { return } + handleError(error) + } + } + } +} + +private extension ChallengeViewController { + + enum Size { + static let cellOffset: CGFloat = 40 + static let numberOfCellsinRow: CGFloat = 0 + } + func setUI() { view.backgroundColor = .designSystem(.background) ChallengeDayCheckCollectionViewCollectionViewCell.register(to: challengeDayCheckCollectionView) } func setHierarchy() { - view.addSubviews(navigationBar, - nicknameLabel, leftSeperateLine, rightSeperateLine, levelBadge, challengeDayLabel, lottieImageView, challengeDayCheckCollectionView) + view.addSubviews(navigationBar, nicknameLabel, leftSeperateLine, rightSeperateLine, levelBadge, challengeDayLabel, lottieImageView, challengeDayCheckCollectionView) levelBadge.addSubview(challengelevelLabel) } @@ -177,30 +185,9 @@ private extension ChallengeViewController { self.navigationController?.pushViewController(myPageViewController, animated: true) } } - - func configureData(_ babyNickname: String) { - self.nicknameLabel.text = "\(babyNickname)아빠 님," - - if let howLongDay = inputData?.howLongDay { - self.challengeDayLabel.text = "\(howLongDay)일째 도전 중" - } - - self.levelBadge.image = BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeImage - - self.lottieImageView.animation = .named(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.progreddbarLottie ?? "") - self.lottieImageView.play() - - let fullText = "사자력 Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1) - - let attributtedString = NSMutableAttributedString(string: fullText) - attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.designSystem(.white) ?? .white, range: (fullText as NSString).range(of: "Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1))) - - self.challengelevelLabel.attributedText = attributtedString - } } -extension ChallengeViewController: - UICollectionViewDelegateFlowLayout { +extension ChallengeViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let width = collectionView.frame.width / 5 @@ -225,9 +212,9 @@ extension ChallengeViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = ChallengeDayCheckCollectionViewCollectionViewCell.dequeueReusableCell(to: collectionView, indexPath: indexPath) - - if indexPath.item < tags.count { - cell.inputString = tags[indexPath.item] + guard let inputData else { return cell } + if indexPath.item < inputData.daddyAttendances.count { + cell.inputString = inputData.daddyAttendances[indexPath.item] cell.backgroundColor = .designSystem(.background) cell.whiteTextColor = .designSystem(.white) } else { From 537403ccf0403bffe9d4b200fc08263ec0b04cef Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 16:47:21 +0900 Subject: [PATCH 26/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=EB=B7=B0=20=EC=98=B5=EC=85=94=EB=84=90=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift | 3 ++- .../ViewController/ChallengeViewController.swift | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift b/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift index 92092d86..62d8b340 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Base/APIService.swift @@ -28,7 +28,8 @@ final class APIService: Requestable { throw NetworkError.serverError } - print("✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅API호출성공✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅") + print("✨✨✨✨✨✨✨✨✨✨✨✨✨API호출성공✨✨✨✨✨✨✨✨✨✨✨✨✨") + print(decodedData) return decodedData.data } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index ff982e5f..7ab8ef4a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -71,12 +71,12 @@ private extension ChallengeViewController { func configureData(_ input: ChallengeData) { self.nicknameLabel.text = "\(input.babyDaddyName)아빠 님," self.challengeDayLabel.text = "\(input.howLongDay)일째 도전 중" - self.levelBadge.image = BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeImage - self.lottieImageView.animation = .named(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.progreddbarLottie ?? "") + self.levelBadge.image = BadgeLevel(rawValue: input.daddyLevel)!.badgeImage + self.lottieImageView.animation = .named(BadgeLevel(rawValue: input.daddyLevel)!.progreddbarLottie) self.lottieImageView.play() - let fullText = "사자력 Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1) + let fullText = "사자력 Lv." + String(BadgeLevel(rawValue: input.daddyLevel)!.badgeLevel) let attributtedString = NSMutableAttributedString(string: fullText) - attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.designSystem(.white) ?? .white, range: (fullText as NSString).range(of: "Lv." + String(BadgeLevel(rawValue: inputData?.daddyLevel ?? "")?.badgeLevel ?? 1))) + attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.designSystem(.white)!, range: (fullText as NSString).range(of: "Lv." + String(BadgeLevel(rawValue: input.daddyLevel)!.badgeLevel))) self.challengelevelLabel.attributedText = attributtedString } From 31a07ce5cdb9e7b93f9bab6dfcb4b63c2e4af0d0 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 24 Sep 2023 19:18:34 +0900 Subject: [PATCH 27/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BB=A4=EB=A6=AC?= =?UTF-8?q?=ED=81=98=EB=9F=BC=EA=B4=80=EB=A0=A8=EB=B7=B0=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 + .../UIComponents/LHCollectionView.swift | 4 +- .../Global/UIComponents/LHLabel.swift | 3 +- .../CurriculumListByWeekViewController.swift | 143 ++++++------------ .../CurriculumViewController.swift | 135 ++++------------- .../Views/CurriculumTableView.swift | 26 ++++ .../Views/CurriculumTableViewHeaderView.swift | 32 +--- .../Views/CurriculumUserInfoView.swift | 76 +++------- 8 files changed, 122 insertions(+), 301 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 79ecf75e..732511b7 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -133,6 +133,7 @@ C0B15E172AC015360058D56B /* LHImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E162AC015360058D56B /* LHImageView.swift */; }; C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E182AC015FE0058D56B /* LHLottie.swift */; }; C0B15E1B2AC0169D0058D56B /* LHCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */; }; + C0B15E1F2AC024F20058D56B /* CurriculumTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E1E2AC024F20058D56B /* CurriculumTableView.swift */; }; C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */; }; C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */; }; C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032E2A5A92170037F740 /* NameSpace.swift */; }; @@ -354,6 +355,7 @@ C0B15E162AC015360058D56B /* LHImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHImageView.swift; sourceTree = ""; }; C0B15E182AC015FE0058D56B /* LHLottie.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLottie.swift; sourceTree = ""; }; C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHCollectionView.swift; sourceTree = ""; }; + C0B15E1E2AC024F20058D56B /* CurriculumTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumTableView.swift; sourceTree = ""; }; C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellRegisterDequeueProtocol.swift; sourceTree = ""; }; C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTypeProtocol.swift; sourceTree = ""; }; C0DF032E2A5A92170037F740 /* NameSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameSpace.swift; sourceTree = ""; }; @@ -1068,6 +1070,7 @@ children = ( F41A97A02A5D4F2500DFF9F3 /* CurriculumTableViewHeaderView.swift */, F435E04B2A5DA6A40098E691 /* CurriculumUserInfoView.swift */, + C0B15E1E2AC024F20058D56B /* CurriculumTableView.swift */, ); path = Views; sourceTree = ""; @@ -1716,6 +1719,7 @@ C06E381D2A65348A00B00600 /* LoginRequest.swift in Sources */, C0DF033D2A5A95420037F740 /* UIStackView+.swift in Sources */, 4A8980CC2A61795500746C58 /* MyPageHeaderView.swift in Sources */, + C0B15E1F2AC024F20058D56B /* CurriculumTableView.swift in Sources */, C0DF03AB2A5D73C80037F740 /* NHOnboardingTextfield.swift in Sources */, C0DF033B2A5A94BA0037F740 /* UITextField+.swift in Sources */, C0F029C92A5EFC1F00E0D185 /* LHOnboardingPageViewController.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift index fb734f8a..f5af3b89 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHCollectionView.swift @@ -9,9 +9,9 @@ import UIKit final class LHCollectionView: UICollectionView { - init(color: UIColor? = .designSystem(.background), scroll: Bool = true) { + init(color: Palette? = .background, scroll: Bool = true) { super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) - self.backgroundColor = color + self.backgroundColor = .designSystem(color!) self.showsVerticalScrollIndicator = false self.showsHorizontalScrollIndicator = false self.isScrollEnabled = scroll diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift index e58c30ec..cb230e54 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift @@ -9,11 +9,12 @@ import UIKit final class LHLabel: UILabel { - init(type: Font.PretendardType, color: Palette, alignment: NSTextAlignment = .center) { + init(type: Font.PretendardType, color: Palette, alignment: NSTextAlignment = .left, basicText: String? = nil) { super.init(frame: .zero) self.font = .pretendard(type) self.textColor = .designSystem(color) self.textAlignment = alignment + self.text = basicText } required init?(coder: NSCoder) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift index 65b030f8..df97063c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift @@ -18,25 +18,10 @@ protocol CurriculumListManager { final class CurriculumListByWeekViewController: UIViewController { private let manager: CurriculumListManager + private let curriculumListByWeekCollectionView = LHCollectionView(color: .background, scroll: false) + private lazy var navigationBar = LHNavigationBarView(type: .curriculumByWeek, viewController: self) - init(manager: CurriculumListManager) { - self.manager = manager - super.init(nibName: nil, bundle: nil) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private let pregnancy = 37 - - var weekToIndexPathItem: Int = 0 { - didSet { - self.curriculumListByWeekCollectionView.reloadData() - } - } - - + var weekToIndexPathItem: Int = 0 var listByWeekDatas: CurriculumWeekData? { didSet { self.curriculumListByWeekCollectionView.reloadData() @@ -45,65 +30,28 @@ final class CurriculumListByWeekViewController: UIViewController { var currentPage: Int = -1 { didSet { - let indexPath = IndexPath(item: currentPage, section: 0) - self.curriculumListByWeekCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) - - let week = currentPage + 4 - - self.navigationBar.setCurriculumWeek(week: week) - - // TODO: Network 주차별 아티클 조회 - if oldValue == currentPage { return } - Task { - showLoading() - let articlesByWeek = try await manager.getArticleListByWeekInfo(week: week) - print("✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨") - print(currentPage + 4) - self.listByWeekDatas = articlesByWeek - hideLoading() - } - + setCurriculumList(oldValue: oldValue, by: currentPage) } } - private lazy var navigationBar: LHNavigationBarView = { - let nav = LHNavigationBarView(type: .curriculumByWeek, viewController: self) - nav.setCurriculumWeek(week: self.weekToIndexPathItem + 4) - return nav - }() - - private let curriculumListByWeekCollectionView: UICollectionView = { - let layout = UICollectionViewFlowLayout() - layout.scrollDirection = .horizontal - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.showsHorizontalScrollIndicator = false - collectionView.isScrollEnabled = false - collectionView.backgroundColor = .designSystem(.background) - return collectionView - }() + init(manager: CurriculumListManager) { + self.manager = manager + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } public override func viewDidLoad() { super.viewDidLoad() - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView + setNavigationBar() setHierarchy() - - // MARK: - autolayout설정 setLayout() - - // MARK: - delegate설정 setDelegate() - - // MARK: - collectionView Register 설정 setCollectionView() - - // MARK: - notificationCenter 설정 setNotificationCenter() - - //api 연결할 때 구현 -// setDataBind() } override func viewWillAppear(_ animated: Bool) { @@ -118,6 +66,7 @@ final class CurriculumListByWeekViewController: UIViewController { let indexPath = IndexPath(item: self.weekToIndexPathItem, section: 0) self.curriculumListByWeekCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: false) } + deinit { removeNotificationCenter() } @@ -129,9 +78,12 @@ private extension CurriculumListByWeekViewController { } func setHierarchy() { - self.navigationController?.isNavigationBarHidden = true view.addSubviews(navigationBar, curriculumListByWeekCollectionView) - + } + + func setNavigationBar() { + self.navigationController?.isNavigationBarHidden = true + navigationBar.setCurriculumWeek(week: self.weekToIndexPathItem + 4) } func setLayout() { @@ -144,7 +96,6 @@ private extension CurriculumListByWeekViewController { $0.top.equalTo(navigationBar.snp.bottom) $0.trailing.leading.equalToSuperview() $0.bottom.equalTo(view.safeAreaLayoutGuide) - } } @@ -173,17 +124,11 @@ private extension CurriculumListByWeekViewController { @objc func bookmarkButtonTapped(notification: NSNotification) { Task { do { - guard let indexPath = notification.userInfo?["bookmarkCellIndexPath"] as? Int else { return } guard let buttonSelected = notification.userInfo?["bookmarkButtonSelected"] as? Bool else { return } guard let listByWeekDatas else { return } self.listByWeekDatas?.articleData[indexPath].isArticleBookmarked.toggle() - - print(indexPath) - print(buttonSelected) - - try await - manager.postBookmark(model: BookmarkRequest(articleId: listByWeekDatas.articleData[indexPath].articleId, + try await manager.postBookmark(model: BookmarkRequest(articleId: listByWeekDatas.articleData[indexPath].articleId, bookmarkRequestStatus: buttonSelected)) hideLoading() buttonSelected ? LHToast.show(message: "북마크가 추가되었습니다", isTabBar: true) : LHToast.show(message: "북마크가 해제되었습니다", isTabBar: true) @@ -194,60 +139,60 @@ private extension CurriculumListByWeekViewController { } } - @objc - func leftButtonTapped(notification: NSNotification) { - let nextIndexPathItem = self.currentPage == -1 - ? weekToIndexPathItem - 1 - : currentPage - 1 - + @objc func leftButtonTapped(notification: NSNotification) { + let nextIndexPathItem = self.currentPage == -1 ? weekToIndexPathItem - 1 : currentPage - 1 let nextPage: Int = max(0, nextIndexPathItem) self.currentPage = nextPage } - @objc - func rightButtonTapped(notification: NSNotification) { - let nextIndexPathItem = self.currentPage == -1 - ? weekToIndexPathItem + 1 - : currentPage + 1 - -// guard let listByWeekDatas else { return } - let nextPage = min(pregnancy - 1, nextIndexPathItem) + @objc func rightButtonTapped(notification: NSNotification) { + let nextIndexPathItem = self.currentPage == -1 ? weekToIndexPathItem + 1 : currentPage + 1 + let nextPage = min(36, nextIndexPathItem) self.currentPage = nextPage } - @objc - func didSelectTableVIewCell(notification: NSNotification) { + @objc func didSelectTableVIewCell(notification: NSNotification) { guard let articleId = notification.object as? Int else { return } presentArticleDetailFullScreen(articleID: articleId) - } func setDelegate() { - curriculumListByWeekCollectionView.delegate = self curriculumListByWeekCollectionView.dataSource = self - } func setCollectionView() { CurriculumListByWeekCollectionViewCell.register(to: curriculumListByWeekCollectionView) } - +} + +extension CurriculumListByWeekViewController { + func setCurriculumList(oldValue: Int, by indexPath: Int) { + let indexPath = IndexPath(item: currentPage, section: 0) + self.curriculumListByWeekCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) + let week = currentPage + 4 + self.navigationBar.setCurriculumWeek(week: week) + if oldValue == currentPage { return } + Task { + showLoading() + let articlesByWeek = try await manager.getArticleListByWeekInfo(week: week) + self.listByWeekDatas = articlesByWeek + hideLoading() + } + } } extension CurriculumListByWeekViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return pregnancy + return 37 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = CurriculumListByWeekCollectionViewCell.dequeueReusableCell(to: curriculumListByWeekCollectionView, indexPath: indexPath) - cell.weekCount = listByWeekDatas?.week cell.inputData = listByWeekDatas cell.selectedIndexPath = indexPath - return cell } } @@ -259,7 +204,6 @@ extension CurriculumListByWeekViewController: UICollectionViewDelegateFlowLayout } extension CurriculumListByWeekViewController: ViewControllerServiceable { - func handleError(_ error: NetworkError) { switch error { case .unAuthorizedError: @@ -286,6 +230,5 @@ extension CurriculumListByWeekViewController { handleError(error) } } - } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift index d36be9f9..a3951dd7 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift @@ -17,15 +17,24 @@ protocol CurriculumManager { final class CurriculumViewController: UIViewController, CurriculumTableViewToggleButtonTappedProtocol{ - private lazy var navigationBar = LHNavigationBarView(type: .curriculumMain, viewController: self) - + private let manager: CurriculumManager + private var curriculumViewDatas = CurriculumMonthData.dummy() private var userInfoData: UserInfoData? { didSet { configureUserInfoData() } } - private let manager: CurriculumManager + private lazy var navigationBar = LHNavigationBarView(type: .curriculumMain, viewController: self) + private let progressBar = LHLottie() + private let dDayLabel = LHLabel(type: .body3R, color: .gray400) + private let dDayView = UIView() + private lazy var curriculumUserInfoView = CurriculumUserInfoView() + private let gradientImage = LHImageView(in: ImageLiterals.Curriculum.gradient) + private let curriculumTableView = CurriculumTableView() + + private let headerHeight: CGFloat = 40.0 + private var isFirstPresented: Bool = true init(manager: CurriculumManager) { self.manager = manager @@ -36,85 +45,34 @@ final class CurriculumViewController: UIViewController, CurriculumTableViewToggl fatalError("init(coder:) has not been implemented") } - private let progressBar = LottieAnimationView() - - private let dDayLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body3R) - label.textColor = .designSystem(.gray400) - return label - }() - - private let dDayView = UIView() - - private let headerHeight: CGFloat = 40.0 - - private lazy var curriculumUserInfoView: CurriculumUserInfoView = { - let view = CurriculumUserInfoView() - view.backgroundColor = .designSystem(.background) - return view - }() - - private enum Size { - static let userInfoView: CGFloat = 70 / 375 - } - - private var isFirstPresented: Bool = true - - private let gradientImage: UIImageView = { - let image = UIImageView(image: ImageLiterals.Curriculum.gradient) - return image - }() - - private let curriculumTableView: UITableView = { - let tableView = UITableView(frame: .zero, style: .insetGrouped) - tableView.rowHeight = UITableView.automaticDimension - tableView.estimatedRowHeight = 200 - tableView.backgroundColor = .clear - tableView.sectionFooterHeight = 40 - tableView.separatorStyle = .none - tableView.showsVerticalScrollIndicator = false - return tableView - }() - - private var curriculumViewDatas = CurriculumMonthData.dummy() - public override func viewDidLoad() { super.viewDidLoad() - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - - // MARK: - delegate설정 setDelegate() - - // MARK: - tableView Register설정 setTableView() - setAddTarget() - } override func viewDidLayoutSubviews() { if isFirstPresented { self.scrollToUserWeek() - } } override func viewWillAppear(_ animated: Bool) { showLoading() getCurriculumData() - } } private extension CurriculumViewController { + + enum Size { + static let userInfoView: CGFloat = 70 / 375 + } + func setUI() { view.backgroundColor = .designSystem(.background) } @@ -170,13 +128,11 @@ private extension CurriculumViewController { func setDelegate() { curriculumTableView.dataSource = self - curriculumTableView.delegate = self } func setTableView(){ CurriculumTableViewCell.register(to: curriculumTableView) curriculumTableView.register(CurriculumTableViewHeaderView.self, forHeaderFooterViewReuseIdentifier: CurriculumTableViewHeaderView.className) - } func setAddTarget() { @@ -191,42 +147,24 @@ private extension CurriculumViewController { } } - /// 더미데이터에서는 더미데이터를가지고 tableview를 그리고 아래함수를 호출했었음 - /// 근데 데이터를 api로 받아오려고보니 해당함수를 호출할때는 api로 데이터가 받아와지기전임(데이터를 받아오는데 시간이 오래 걸리때문) - /// 시간이 걸려서 데이터를 받아오니 expand가 안됨 - // viewDidLayoutSubviews func scrollToUserWeek() { - guard let userInfoData else { return } - let userWeek = userInfoData.userWeekInfo + let weekPerMonth = 4 + let desireSection = userWeek == 40 ? (userWeek/weekPerMonth)-2 : (userWeek/weekPerMonth)-1 + let desireRow = (userWeek % weekPerMonth) + let indexPath = IndexPath(row: desireRow, section: desireSection) + let weekDataRow = userWeek == 40 ? desireRow + 4 : desireRow + curriculumViewDatas[desireSection].weekDatas[weekDataRow].isExpanded = true + self.curriculumTableView.reloadData() + self.curriculumTableView.scrollToRow(at: indexPath, at: .top, animated: false) - if userWeek == 40 { - let weekPerMonth = 4 - let desireSection = (userWeek / weekPerMonth) - 2 - let desireRow = (userWeek % weekPerMonth) - let indexPath = IndexPath(row: desireRow, section: desireSection) - - curriculumViewDatas[desireSection].weekDatas[desireRow+4].isExpanded = true - self.curriculumTableView.reloadData() - self.curriculumTableView.scrollToRow(at: indexPath, at: .top, animated: false) - } else { - let weekPerMonth = 4 - let desireSection = (userWeek / weekPerMonth) - 1 - let desireRow = (userWeek % weekPerMonth) - let indexPath = IndexPath(row: desireRow, section: desireSection) - - curriculumViewDatas[desireSection].weekDatas[desireRow].isExpanded = true - self.curriculumTableView.reloadData() - self.curriculumTableView.scrollToRow(at: indexPath, at: .top, animated: false) - } } func configureUserInfoData() { guard let userInfoData else { return } dDayLabel.text = "D-\(userInfoData.remainingDay)" let progressName: String = "progressbar_\(userInfoData.progress)m" - progressBar.animation = .named(progressName) progressBar.play() curriculumUserInfoView.userInfo = userInfoData @@ -245,7 +183,6 @@ extension CurriculumViewController: UITableViewDataSource { cell.selectionStyle = .none cell.delegate = self cell.cellIndexPath = indexPath - cell.curriculumToggleDirectionButton.isSelected = data.isExpanded return cell } @@ -268,33 +205,20 @@ extension CurriculumViewController: UITableViewDataSource { func toggleButtonTapped(indexPath: IndexPath?) { self.isFirstPresented = false guard let indexPath else { return } - let previousWeekDatas = curriculumViewDatas[indexPath.section].weekDatas[indexPath.row] - curriculumViewDatas[indexPath.section].weekDatas[indexPath.row].isExpanded = !previousWeekDatas.isExpanded curriculumTableView.reloadRows(at: [indexPath], with: .automatic) } func moveToListByWeekButtonTapped(indexPath: IndexPath?) { - - guard let indexPath else { - return - - } - + guard let indexPath else { return } let listByWeekVC = CurriculumListByWeekViewController(manager: CurriculumListManagerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()), curriculumService: CurriculumServiceImpl(apiService: APIService()))) listByWeekVC.weekToIndexPathItem = (indexPath.section * 4) + indexPath.row self.navigationController?.pushViewController(listByWeekVC, animated: true) - } - - } -extension CurriculumViewController: UITableViewDelegate{} - extension CurriculumViewController: ViewControllerServiceable { - func handleError(_ error: NetworkError) { switch error { case .unAuthorizedError: @@ -305,19 +229,15 @@ extension CurriculumViewController: ViewControllerServiceable { LHToast.show(message: "\(message)") default: LHToast.show(message: error.description) - } } - } extension CurriculumViewController { func getCurriculumData() { Task { do { - let responseCurriculum = try await manager.getCurriculumServiceInfo() - - userInfoData = responseCurriculum + userInfoData = try await manager.getCurriculumServiceInfo() hideLoading() } catch { guard let error = error as? NetworkError else { return } @@ -325,5 +245,4 @@ extension CurriculumViewController { } } } - } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift new file mode 100644 index 00000000..d70b6e72 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift @@ -0,0 +1,26 @@ +// +// CurriculumTableView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import UIKit + +final class CurriculumTableView: UITableView { + + init() { + super.init(frame: .zero, style: .insetGrouped) + self.rowHeight = UITableView.automaticDimension + self.estimatedRowHeight = 200 + self.backgroundColor = .clear + self.sectionFooterHeight = 40 + self.separatorStyle = .none + self.showsVerticalScrollIndicator = false + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableViewHeaderView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableViewHeaderView.swift index ec44ae5b..ba6114b4 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableViewHeaderView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableViewHeaderView.swift @@ -12,30 +12,12 @@ import SnapKit final class CurriculumTableViewHeaderView: UITableViewHeaderFooterView { - var headerNameLabel: UILabel = { - let header = UILabel() - header.font = .pretendard(.head2) - header.textColor = .designSystem(.white) - return header - }() + private var headerNameLabel = LHLabel(type: .head2, color: .white) override init(reuseIdentifier: String?) { super.init(reuseIdentifier: reuseIdentifier) - - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() } @available(*, unavailable) @@ -49,8 +31,6 @@ final class CurriculumTableViewHeaderView: UITableViewHeaderFooterView { } private extension CurriculumTableViewHeaderView { - func setUI() { - } func setHierarchy() { contentView.addSubview(headerNameLabel) @@ -62,14 +42,4 @@ private extension CurriculumTableViewHeaderView { $0.top.equalToSuperview() } } - - func setAddTarget() { - - } - - func setDelegate() { - - } - - } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift index 70d8793f..253b13fa 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift @@ -18,53 +18,16 @@ final class CurriculumUserInfoView: UIView { } } - private let weekImageView: UIImageView = { - let imageView = UIImageView() - return imageView - }() - - private let userWeekLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head3) - label.textColor = .designSystem(.gray100) - return label - }() - - private let weekLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head3) - label.textColor = .designSystem(.white) - label.text = "주" - return label - }() - - private let dayImageView: UIImageView = { - let imageView = UIImageView(image: ImageLiterals.Curriculum.dayBackground) - return imageView - }() - - private let userDayLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head3) - label.textColor = .designSystem(.gray100) - label.textAlignment = .center - return label - }() - - private let dayLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head3) - label.textColor = .designSystem(.white) - label.text = "일차" - return label - }() - - private let userWeekDayInfoView = UIView() + private let weekImageView = LHImageView() + private let userWeekLabel = LHLabel(type: .head3, color: .gray100) + private let weekLabel = LHLabel(type: .head3, color: .white, basicText: "주") + private let dayImageView = LHImageView(in: ImageLiterals.Curriculum.dayBackground) + private let userDayLabel = LHLabel(type: .head3, color: .gray100, alignment: .center) + private let dayLabel = LHLabel(type: .head3, color: .white, basicText: "일차") + private let userWeekDayInfoView = LHImageView() override init(frame: CGRect) { - super.init(frame: frame) - - + super.init(frame: .zero) } override func layoutSubviews() { @@ -78,11 +41,19 @@ final class CurriculumUserInfoView: UIView { fatalError("init(coder:) has not been implemented") } + func configureUserInfo(data: UserInfoData?) { + guard let data else { return } + self.userWeekLabel.text = "\(data.userWeekInfo)" + self.userDayLabel.text = "\(data.userDayInfo)" + weekImageView.image = data.userWeekInfo.description.count >= 2 ? ImageLiterals.Curriculum.weekBackground : ImageLiterals.Curriculum.dayBackground + } + } extension CurriculumUserInfoView { + func setUI() { - + self.backgroundColor = .designSystem(.background) } func setHierarchy() { @@ -122,17 +93,4 @@ extension CurriculumUserInfoView { } } - - func configureUserInfo(data: UserInfoData?) { - guard let data else { return } - self.userWeekLabel.text = "\(data.userWeekInfo)" - self.userDayLabel.text = "\(data.userDayInfo)" - if data.userWeekInfo.description.count >= 2 { - weekImageView.image = ImageLiterals.Curriculum.weekBackground - } else { - weekImageView.image = ImageLiterals.Curriculum.dayBackground - } - - } - } From 58e99d4968a94bf1c2ad2894cd615403e92dd062 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 08:43:00 +0900 Subject: [PATCH 28/39] =?UTF-8?q?=F0=9F=92=84=20LHStackView=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/UIComponents/LHStackView.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift new file mode 100644 index 00000000..4cc7a816 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift @@ -0,0 +1,21 @@ +// +// LHStackView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/25. +// + +import UIKit + +final class LHStackView: UIStackView { + + init(axis: NSLayoutConstraint.Axis, spacing: CGFloat) { + super.init(frame: .zero) + self.axis = axis + self.spacing = spacing + } + + required init(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From bb07b22cd611689336eefbd6355fa43265d5332e Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 09:37:06 +0900 Subject: [PATCH 29/39] =?UTF-8?q?=F0=9F=92=84=20LHImageButton=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이미지버튼 컴포넌트 --- .../Global/UIComponents/LHImageButton.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageButton.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageButton.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageButton.swift new file mode 100644 index 00000000..8d7b4482 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageButton.swift @@ -0,0 +1,19 @@ +// +// LHImageButton.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/25. +// + +import UIKit + +final class LHImageButton: UIButton { + init(setImage: UIImage?) { + super.init(frame: .zero) + self.setImage(setImage, for: .normal) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From 40b442e4780d5c36625e237545bffa04eaa9e8f6 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 09:37:28 +0900 Subject: [PATCH 30/39] =?UTF-8?q?=F0=9F=92=84ToggleImageButton=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/LHToggleImageButton.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHToggleImageButton.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHToggleImageButton.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHToggleImageButton.swift new file mode 100644 index 00000000..ef59c19e --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHToggleImageButton.swift @@ -0,0 +1,20 @@ +// +// LHToggleImageButton.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/25. +// + +import UIKit + +final class LHToggleImageButton: UIButton { + init(normal normalImage: UIImage?, select selectImage: UIImage?) { + super.init(frame: .zero) + self.setImage(normalImage, for: .normal) + self.setImage(selectImage, for: .selected) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From f44b909a8f2950a8d9aadf6d3d3f30291f0e5689 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 09:38:19 +0900 Subject: [PATCH 31/39] =?UTF-8?q?=F0=9F=94=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/ArticleListByCategoryView.swift | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryView.swift deleted file mode 100644 index b275ce5b..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryView.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// ArticleListByCategoryView.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleListByCategory. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleListByCategoryView: UIView { - - override init(frame: CGRect) { - super.init(frame: frame) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - -} - -private extension ArticleListByCategoryView { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} From b6f8eaff5459cb294b2a19c95f245ab69dcd73ab Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 09:38:46 +0900 Subject: [PATCH 32/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BB=A4=EB=A6=AC?= =?UTF-8?q?=ED=81=98=EB=9F=BC=EA=B4=80=EB=A0=A8=EB=B7=B0=20=EB=94=94?= =?UTF-8?q?=EC=9E=90=EC=9D=B8=EC=8B=9C=EC=8A=A4=ED=85=9C=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EB=B0=8F=20=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 24 ++- .../Global/UIComponents/LHLabel.swift | 9 +- .../Global/UIComponents/LHStackView.swift | 3 +- .../Global/UIComponents/LHUnderLine.swift | 7 +- .../LionHeart-iOS/Global/Utils/Palette.swift | 2 +- .../ArticleListByCategoryViewController.swift | 28 +--- .../Views/ArticleListTableView.swift | 30 ++++ .../ChallengeViewController.swift | 4 +- ...lumArticleByWeekRowZeroTableViewCell.swift | 91 +++-------- ...CurriculumArticleByWeekTableViewCell.swift | 123 +++++--------- ...rriculumListByWeekCollectionViewCell.swift | 75 ++------- .../Cells/CurriculumTableViewCell.swift | 154 ++++++------------ .../CurriculumListByWeekViewController.swift | 1 + .../CurriculumViewController.swift | 34 +--- .../CurriculumListByCategoryTableView.swift | 28 ++++ .../Views/CurriculumTableView.swift | 2 + .../Views/CurriculumUserInfoView.swift | 12 +- .../GetFetalNicknameViewController.swift | 2 +- .../OnboardingViewController.swift | 4 +- 19 files changed, 249 insertions(+), 384 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListTableView.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumListByCategoryTableView.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 732511b7..0140a743 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -134,6 +134,11 @@ C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E182AC015FE0058D56B /* LHLottie.swift */; }; C0B15E1B2AC0169D0058D56B /* LHCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */; }; C0B15E1F2AC024F20058D56B /* CurriculumTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E1E2AC024F20058D56B /* CurriculumTableView.swift */; }; + C0B15E212AC0450E0058D56B /* ArticleListTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E202AC0450E0058D56B /* ArticleListTableView.swift */; }; + C0B15E232AC100690058D56B /* LHStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E222AC100690058D56B /* LHStackView.swift */; }; + C0B15E252AC103A50058D56B /* LHToggleImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E242AC103A50058D56B /* LHToggleImageButton.swift */; }; + C0B15E272AC104D50058D56B /* LHImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E262AC104D50058D56B /* LHImageButton.swift */; }; + C0B15E292AC106CA0058D56B /* CurriculumListByCategoryTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E282AC106CA0058D56B /* CurriculumListByCategoryTableView.swift */; }; C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */; }; C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */; }; C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032E2A5A92170037F740 /* NameSpace.swift */; }; @@ -153,7 +158,6 @@ C0DF034F2A5A9B9C0037F740 /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF034E2A5A9B9C0037F740 /* MyPageViewController.swift */; }; C0DF03512A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03502A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift */; }; C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03522A5A9BC80037F740 /* ArticleListByCategoryViewController.swift */; }; - C0DF03552A5A9BD60037F740 /* ArticleListByCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03542A5A9BD60037F740 /* ArticleListByCategoryView.swift */; }; C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */; }; C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */; }; C0DF03652A5A9C610037F740 /* ArticleDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */; }; @@ -356,6 +360,11 @@ C0B15E182AC015FE0058D56B /* LHLottie.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLottie.swift; sourceTree = ""; }; C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHCollectionView.swift; sourceTree = ""; }; C0B15E1E2AC024F20058D56B /* CurriculumTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumTableView.swift; sourceTree = ""; }; + C0B15E202AC0450E0058D56B /* ArticleListTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListTableView.swift; sourceTree = ""; }; + C0B15E222AC100690058D56B /* LHStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHStackView.swift; sourceTree = ""; }; + C0B15E242AC103A50058D56B /* LHToggleImageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHToggleImageButton.swift; sourceTree = ""; }; + C0B15E262AC104D50058D56B /* LHImageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHImageButton.swift; sourceTree = ""; }; + C0B15E282AC106CA0058D56B /* CurriculumListByCategoryTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListByCategoryTableView.swift; sourceTree = ""; }; C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellRegisterDequeueProtocol.swift; sourceTree = ""; }; C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTypeProtocol.swift; sourceTree = ""; }; C0DF032E2A5A92170037F740 /* NameSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameSpace.swift; sourceTree = ""; }; @@ -374,7 +383,6 @@ C0DF034E2A5A9B9C0037F740 /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = ""; }; C0DF03502A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryTableViewCell.swift; sourceTree = ""; }; C0DF03522A5A9BC80037F740 /* ArticleListByCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryViewController.swift; sourceTree = ""; }; - C0DF03542A5A9BD60037F740 /* ArticleListByCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryView.swift; sourceTree = ""; }; C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewController.swift; sourceTree = ""; }; C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryView.swift; sourceTree = ""; }; C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailView.swift; sourceTree = ""; }; @@ -750,6 +758,9 @@ C0B15E162AC015360058D56B /* LHImageView.swift */, C0B15E182AC015FE0058D56B /* LHLottie.swift */, C0B15E1A2AC0169D0058D56B /* LHCollectionView.swift */, + C0B15E222AC100690058D56B /* LHStackView.swift */, + C0B15E242AC103A50058D56B /* LHToggleImageButton.swift */, + C0B15E262AC104D50058D56B /* LHImageButton.swift */, ); path = UIComponents; sourceTree = ""; @@ -917,8 +928,8 @@ B59892112A56B52B00CE1FEB /* Views */ = { isa = PBXGroup; children = ( - C0DF03542A5A9BD60037F740 /* ArticleListByCategoryView.swift */, D3AB54B52A625A7B0017BF53 /* ArticleListByCategoryHeaderView.swift */, + C0B15E202AC0450E0058D56B /* ArticleListTableView.swift */, ); path = Views; sourceTree = ""; @@ -1071,6 +1082,7 @@ F41A97A02A5D4F2500DFF9F3 /* CurriculumTableViewHeaderView.swift */, F435E04B2A5DA6A40098E691 /* CurriculumUserInfoView.swift */, C0B15E1E2AC024F20058D56B /* CurriculumTableView.swift */, + C0B15E282AC106CA0058D56B /* CurriculumListByCategoryTableView.swift */, ); path = Views; sourceTree = ""; @@ -1582,6 +1594,7 @@ C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */, C0DF034F2A5A9B9C0037F740 /* MyPageViewController.swift in Sources */, C0DF03A92A5CF0460037F740 /* UserOnboardingModel.swift in Sources */, + C0B15E212AC0450E0058D56B /* ArticleListTableView.swift in Sources */, B5C6A2B42A5DB11A0021BE5E /* ThumnailTableViewCell.swift in Sources */, C0F029CB2A5F034400E0D185 /* LHOnboardingButton.swift in Sources */, B59893112A5D039B00CE1FEB /* ArticleBlockType.swift in Sources */, @@ -1647,9 +1660,12 @@ C0DF03812A5AF51C0037F740 /* Constant.swift in Sources */, B59892942A57A93300CE1FEB /* Config.swift in Sources */, 4AD6AE1A2A68436B00A3D745 /* ArticleListByCategoryResponse.swift in Sources */, + C0B15E252AC103A50058D56B /* LHToggleImageButton.swift in Sources */, 4A8980D02A61850500746C58 /* MyPageAppSettingCollectionViewCell.swift in Sources */, + C0B15E292AC106CA0058D56B /* CurriculumListByCategoryTableView.swift in Sources */, C06E38232A65353F00B00600 /* LoginType.swift in Sources */, C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */, + C0B15E272AC104D50058D56B /* LHImageButton.swift in Sources */, B5C6A2B62A5DD5FE0021BE5E /* TitleTableViewCell.swift in Sources */, C0DF03962A5B8FB10037F740 /* Palette.swift in Sources */, 4A3D72872A5D405C00A36189 /* BookmarkListCollectionViewCell.swift in Sources */, @@ -1674,7 +1690,6 @@ C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */, C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */, B57BEB6C2A6149AD00D1727C /* NetworkRequest.swift in Sources */, - C0DF03552A5A9BD60037F740 /* ArticleListByCategoryView.swift in Sources */, F4DB30B42A61250500413EB9 /* CurriculumListByWeekCollectionViewCell.swift in Sources */, C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */, F46522FD2A6048660083FBB2 /* CurriculumImagesByWeek.swift in Sources */, @@ -1706,6 +1721,7 @@ D3BA0B712A5CFA2300B6361F /* ArticleCategoryCollectionViewCell.swift in Sources */, B532E8342A5525C600F0DB19 /* SceneDelegate.swift in Sources */, C0F029CD2A5F8D2F00E0D185 /* UIPageViewController+.swift in Sources */, + C0B15E232AC100690058D56B /* LHStackView.swift in Sources */, C0856B732ABFC3070026D9F8 /* BookmarkMangerImpl.swift in Sources */, B57BEB632A612DA100D1727C /* UserDefaultsManager.swift in Sources */, C0DF037B2A5A9CF30037F740 /* OnboardingViewController.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift index cb230e54..61d1803a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLabel.swift @@ -9,12 +9,19 @@ import UIKit final class LHLabel: UILabel { - init(type: Font.PretendardType, color: Palette, alignment: NSTextAlignment = .left, basicText: String? = nil) { + init(type: Font.PretendardType, + color: Palette, + backgroundColor: Palette? = nil, + alignment: NSTextAlignment = .left, + lines: Int = 1, + basicText: String? = nil) { super.init(frame: .zero) self.font = .pretendard(type) self.textColor = .designSystem(color) self.textAlignment = alignment self.text = basicText + self.backgroundColor = .designSystem(.background) + self.numberOfLines = lines } required init?(coder: NSCoder) { diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift index 4cc7a816..2746e037 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHStackView.swift @@ -9,10 +9,11 @@ import UIKit final class LHStackView: UIStackView { - init(axis: NSLayoutConstraint.Axis, spacing: CGFloat) { + init(axis: NSLayoutConstraint.Axis, spacing: CGFloat, distribution: UIStackView.Distribution = .fill) { super.init(frame: .zero) self.axis = axis self.spacing = spacing + self.distribution = distribution } required init(coder: NSCoder) { diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift index 5d8dfc82..3350f71e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHUnderLine.swift @@ -9,12 +9,9 @@ import UIKit final class LHUnderLine: UIView { - private let lineColor: UIColor? - - init(lineColor: UIColor?) { - self.lineColor = lineColor + init(lineColor: Palette) { super.init(frame: .zero) - self.backgroundColor = self.lineColor + self.backgroundColor = .designSystem(lineColor) } @available(*, unavailable) diff --git a/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift b/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift index aaa2d086..32e91407 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift @@ -22,6 +22,6 @@ enum Palette: String { case gray1000 = "Gray1000" case lionRed = "LionRed" case componentLionRed = "ComponentLionRed" - case background = "Background" + case background = "background" case kakao = "KakaoYellow" } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift index 04a93f50..9772f05b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift @@ -19,30 +19,16 @@ protocol ArticleListByCategoryManager { final class ArticleListByCategoryViewController: UIViewController { private let manager: ArticleListByCategoryManager + private lazy var navigationBar = LHNavigationBarView(type: .exploreEachCategory, viewController: self) + private let articleListTableView = ArticleListTableView() - var categoryString = String() + var categoryString: String? var articleListData: [ArticleDataByWeek] = [] { didSet { articleListTableView.reloadData() } } - private lazy var navigationBar = LHNavigationBarView(type: .exploreEachCategory, viewController: self) - - private let articleListTableView: UITableView = { - let tableView = UITableView() - tableView.backgroundColor = .designSystem(.background) - let view = ArticleListByCategoryHeaderView() - view.frame = CGRect(x: 0, y: 0, width: Constant.Screen.width, height: ScreenUtils.getHeight(136)) - tableView.separatorStyle = .none - tableView.tableHeaderView = view - tableView.estimatedRowHeight = 326 - let footerView = UIView() - footerView.frame = .init(x: 0, y: 0, width: Constant.Screen.width, height: 100) - tableView.tableFooterView = footerView - return tableView - }() - init(manager: ArticleListByCategoryManager) { self.manager = manager super.init(nibName: nil, bundle: nil) @@ -66,6 +52,7 @@ final class ArticleListByCategoryViewController: UIViewController { showLoading() Task { do { + guard let categoryString else { return } self.articleListData = try await manager.getArticleListByCategory(categoryString: categoryString).articleData self.articleListTableView.reloadData() hideLoading() @@ -140,24 +127,19 @@ extension ArticleListByCategoryViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = CurriculumArticleByWeekTableViewCell.dequeueReusableCell(to: articleListTableView) cell.inputData = articleListData[indexPath.row] - + cell.selectionStyle = .none cell.bookMarkButtonTapped = { isSelected, indexPath in - - Task { do { try await self.manager.postBookmark(model: BookmarkRequest(articleId: self.articleListData[indexPath.row].articleId, bookmarkRequestStatus: isSelected)) - print(self.articleListData[indexPath.row].articleId) isSelected ? LHToast.show(message: "북마크에 추가되었습니다", isTabBar: true) : LHToast.show(message: "북마크에 해제되었습니다", isTabBar: true) } catch { guard let error = error as? NetworkError else { return } self.handleError(error) } } - } - return cell } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListTableView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListTableView.swift new file mode 100644 index 00000000..506ee2e2 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListTableView.swift @@ -0,0 +1,30 @@ +// +// ArticleListTableView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/24. +// + +import UIKit + +final class ArticleListTableView: UITableView { + init() { + super.init(frame: .zero, style: .plain) + self.backgroundColor = .designSystem(.background) + let view = ArticleListByCategoryHeaderView() + view.frame = CGRect(x: 0, y: 0, width: Constant.Screen.width, height: ScreenUtils.getHeight(136)) + self.separatorStyle = .none + self.tableHeaderView = view + self.estimatedRowHeight = 326 + + let footerView = UIView() + footerView.frame = .init(x: 0, y: 0, width: Constant.Screen.width, height: 100) + self.tableFooterView = footerView + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + + diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index 7ab8ef4a..d2e92d9f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -26,8 +26,8 @@ final class ChallengeViewController: UIViewController { } } - private let leftSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) - private let rightSeperateLine = LHUnderLine(lineColor: .designSystem(.background)) + private let leftSeperateLine = LHUnderLine(lineColor: .background) + private let rightSeperateLine = LHUnderLine(lineColor: .background) private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) private let nicknameLabel = LHLabel(type: .body2R, color: .gray200) private let challengeDayLabel = LHLabel(type: .head3, color: .white) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift index 88236311..a518a357 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift @@ -11,21 +11,12 @@ import UIKit import SnapKit final class CurriculumArticleByWeekRowZeroTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - - var inputData: Int? { - didSet { - guard let inputData else { return } - //inputData는 row가 0부터인데 주차정보는 4주차부터 시작이므로 +4를 해줌 - - weekLabel.text = "\(inputData)주차" - weekBackGroundImageView.image = WeekBackgroundImage.dummy()[inputData-4].weekBackgroundImage - - } - } - private enum Size { - static let weekBackGroundImageSize: CGFloat = 200 / 375 - } + private lazy var leftWeekButton = LHImageButton(setImage: ImageLiterals.Curriculum.arrowLeftWeek) + private lazy var rightWeekButton = LHImageButton(setImage: ImageLiterals.Curriculum.arrowRightWeek) + private let curriculumLabel = LHLabel(type: .body2R, color: .lionRed, alignment: .center, basicText: "Curriculum") + private let weekLabel = LHLabel(type: .head1, color: .white, alignment: .center) + private let curriculumAndWeekStackView = LHStackView(axis: .vertical, spacing: 2) private let weekBackGroundImageView: UIImageView = { let imageView = UIImageView() @@ -41,61 +32,21 @@ final class CurriculumArticleByWeekRowZeroTableViewCell: UITableViewCell, TableV return view }() - private lazy var leftWeekButton: UIButton = { - let button = UIButton(type: .custom) - button.setImage(ImageLiterals.Curriculum.arrowLeftWeek, for: .normal) - button.addButtonAction { _ in - - NotificationCenter.default.post(name: NSNotification.Name("leftButton"), - object: nil) - } - return button - }() - - private lazy var rightWeekButton: UIButton = { - let button = UIButton(type: .custom) - button.setImage(ImageLiterals.Curriculum.arrowRightWeek, for: .normal) - button.addButtonAction { _ in - - NotificationCenter.default.post(name: NSNotification.Name("rightButton"), - object: nil) + var inputData: Int? { + didSet { + guard let inputData else { return } + weekLabel.text = "\(inputData)주차" + weekBackGroundImageView.image = WeekBackgroundImage.dummy()[inputData-4].weekBackgroundImage } - return button - }() - - private let curriculumLabel: UILabel = { - let label = UILabel() - label.textAlignment = .center - label.font = .pretendard(.body2R) - label.textColor = .designSystem(.lionRed) - label.text = "Curriculum" - return label - }() - - private let weekLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head1) - label.textColor = .designSystem(.white) - label.textAlignment = .center - return label - }() - - private let curriculumAndWeekStackView: UIStackView = { - let stackView = UIStackView() - stackView.spacing = 2 - stackView.distribution = .fill - stackView.axis = .vertical - return stackView - }() + } override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - setUI() setHierarchy() setLayout() + setAddTarget() } - @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") @@ -103,19 +54,18 @@ final class CurriculumArticleByWeekRowZeroTableViewCell: UITableViewCell, TableV } private extension CurriculumArticleByWeekRowZeroTableViewCell { - func setUI() { - } + enum Size { + static let weekBackGroundImageSize: CGFloat = 200 / 375 + } + func setHierarchy() { - curriculumAndWeekStackView.addArrangedSubviews(curriculumLabel, weekLabel) weekBackGroundImageView.addSubviews(blurblackView, curriculumAndWeekStackView) contentView.addSubviews(weekBackGroundImageView, leftWeekButton, rightWeekButton) - } func setLayout() { - weekBackGroundImageView.snp.makeConstraints{ $0.edges.equalToSuperview() $0.height.equalTo(weekBackGroundImageView.snp.width).multipliedBy(Size.weekBackGroundImageSize) @@ -141,4 +91,13 @@ private extension CurriculumArticleByWeekRowZeroTableViewCell { } } + func setAddTarget() { + leftWeekButton.addButtonAction { _ in + NotificationCenter.default.post(name: NSNotification.Name("leftButton"), object: nil) + } + + rightWeekButton.addButtonAction { _ in + NotificationCenter.default.post(name: NSNotification.Name("rightButton"), object: nil) + } + } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift index 132390b7..b57d0998 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift @@ -15,62 +15,21 @@ final class CurriculumArticleByWeekTableViewCell: UITableViewCell, TableViewCell var inputData: ArticleDataByWeek? { didSet { - guard let inputData else { - return - } - articleReadTimeLabel.text = "\(inputData.articleReadTime)분 분량" - articleTitleLabel.text = inputData.articleTitle - Task { - let image = try await LHKingFisherService.fetchImage(with: inputData.articleImage) - articleImageView.image = image - } - articleTagLabel.text = inputData.articleTags.joined(separator: " · ") - articleContentLabel.text = inputData.articleContent - articleContentLabel.setTextWithLineHeight(lineHeight: 22) - articleContentLabel.lineBreakStrategy = .pushOut - articleContentLabel.lineBreakMode = .byTruncatingTail - bookMarkButton.isSelected = inputData.isArticleBookmarked + guard let inputData else { return } + configureData(inputData) } } var bookMarkButtonTapped: ((Bool, IndexPath) -> Void)? private let tableViewCellWholeView = UIView() - - private enum Size { - static let readTimeAndBookmarkViewSize: CGFloat = 44 / 335 - static let articleImageSize: CGFloat = 200 / 335 - - } - - private let articleTitleLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head3) - label.textColor = .designSystem(.white) - return label - }() - - private let articleTagLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body4) - label.textColor = .designSystem(.gray400) - return label - }() - - private let articleReadTimeLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body4) - label.textColor = .designSystem(.gray500) - return label - }() - - private let articleContentLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body3R) - label.textColor = .designSystem(.gray300) - label.numberOfLines = 2 - return label - }() + + private let articleTitleLabel = LHLabel(type: .head3, color: .white) + private let articleTagLabel = LHLabel(type: .body4, color: .gray400) + private let articleReadTimeLabel = LHLabel(type: .body4, color: .gray500) + private let articleContentLabel = LHLabel(type: .body3R, color: .gray300, lines: 2) + private lazy var bookMarkButton = LHToggleImageButton(normal: ImageLiterals.BookMark.inactiveBookmarkSmall, + select: ImageLiterals.BookMark.activeBookmarkSmall) private let articleImageView: UIImageView = { let imageView = UIImageView() @@ -89,39 +48,13 @@ final class CurriculumArticleByWeekTableViewCell: UITableViewCell, TableViewCell view.layer.opacity = 0.6 return view }() - - private lazy var bookMarkButton: UIButton = { - var button = UIButton() - button.setImage(ImageLiterals.BookMark.inactiveBookmarkSmall, for: .normal) - button.setImage(ImageLiterals.BookMark.activeBookmarkSmall, for: .selected) - button.addButtonAction { [weak self] _ in - guard let self else { return } - - guard var indexPath = self.getIndexPath() else { return } - button.isSelected.toggle() - self.bookMarkButtonTapped?(button.isSelected, indexPath) - - NotificationCenter.default.post(name: NSNotification.Name("isArticleBookmarked"), - object: nil, userInfo: ["bookmarkCellIndexPath": max(0, indexPath.row - 1), - "bookmarkButtonSelected": button.isSelected]) - } - return button - }() - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - - + setAddTarget() } @available(*, unavailable) @@ -131,8 +64,14 @@ final class CurriculumArticleByWeekTableViewCell: UITableViewCell, TableViewCell } private extension CurriculumArticleByWeekTableViewCell { + + enum Size { + static let readTimeAndBookmarkViewSize: CGFloat = 44 / 335 + static let articleImageSize: CGFloat = 200 / 335 + } + func setUI() { - contentView.backgroundColor = .designSystem(.background) + backgroundColor = .designSystem(.background) } func setHierarchy() { @@ -188,8 +127,36 @@ private extension CurriculumArticleByWeekTableViewCell { } } + func setAddTarget() { + bookMarkButton.addButtonAction { [weak self] _ in + guard let self else { return } + guard var indexPath = self.getIndexPath() else { return } + self.isSelected.toggle() + self.bookMarkButtonTapped?(self.isSelected, indexPath) + NotificationCenter.default.post(name: NSNotification.Name("isArticleBookmarked"), + object: nil, userInfo: ["bookmarkCellIndexPath": max(0, indexPath.row - 1), + "bookmarkButtonSelected": self.isSelected]) + } + } + func getIndexPath() -> IndexPath? { guard let superView = self.superview as? UITableView else { return nil } return superView.indexPath(for: self) } + + func configureData(_ inputData: ArticleDataByWeek) { + Task { + let image = try await LHKingFisherService.fetchImage(with: inputData.articleImage) + articleImageView.image = image + } + articleReadTimeLabel.text = "\(inputData.articleReadTime)분 분량" + articleTitleLabel.text = inputData.articleTitle + articleTagLabel.text = inputData.articleTags.joined(separator: " · ") + articleContentLabel.text = inputData.articleContent + articleContentLabel.setTextWithLineHeight(lineHeight: 22) + articleContentLabel.lineBreakStrategy = .pushOut + articleContentLabel.lineBreakMode = .byTruncatingTail + bookMarkButton.isSelected = inputData.isArticleBookmarked + + } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumListByWeekCollectionViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumListByWeekCollectionViewCell.swift index bbb17490..658e8b64 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumListByWeekCollectionViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumListByWeekCollectionViewCell.swift @@ -12,54 +12,22 @@ import SnapKit final class CurriculumListByWeekCollectionViewCell: UICollectionViewCell, CollectionViewCellRegisterDequeueProtocol { - private enum Size { - static let weekBackGroundImageSize: CGFloat = (60 / 375) * Constant.Screen.width - } - - let curriculumListByWeekTableView: UITableView = { - let tableView = UITableView() - tableView.contentInsetAdjustmentBehavior = .always - tableView.showsVerticalScrollIndicator = false - tableView.backgroundColor = .designSystem(.background) - tableView.separatorStyle = .none - return tableView - }() - - var weekCount: Int? { - didSet { - curriculumListByWeekTableView.reloadData() - } - } + let curriculumListByWeekTableView = CurriculumListByWeekTableView() + var weekCount: Int? + var selectedIndexPath: IndexPath? var inputData: CurriculumWeekData? { - didSet { curriculumListByWeekTableView.reloadData() } } - - - - var selectedIndexPath: IndexPath? - + override init(frame: CGRect) { super.init(frame: frame) - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - - // MARK: - delegate설정 setDelegate() - - // MARK: - tableView Register 설정 - setTableView() - - } @available(*, unavailable) @@ -69,8 +37,13 @@ final class CurriculumListByWeekCollectionViewCell: UICollectionViewCell, Collec } private extension CurriculumListByWeekCollectionViewCell { + + enum Size { + static let weekBackGroundImageSize: CGFloat = (60 / 375) * Constant.Screen.width + } + func setUI() { - + backgroundColor = .designSystem(.background) } func setHierarchy() { @@ -84,37 +57,23 @@ private extension CurriculumListByWeekCollectionViewCell { } func setDelegate() { - curriculumListByWeekTableView.delegate = self curriculumListByWeekTableView.dataSource = self } - - func setTableView() { - CurriculumArticleByWeekTableViewCell.register(to: curriculumListByWeekTableView) - CurriculumArticleByWeekRowZeroTableViewCell.register(to: curriculumListByWeekTableView) - - let footerView = UIView() - footerView.backgroundColor = .designSystem(.background) - footerView.frame.size.height = 76 - self.curriculumListByWeekTableView.tableFooterView = footerView - } } extension CurriculumListByWeekCollectionViewCell: UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { guard let inputData else { return 0 } - return (inputData.articleData.count + 1) + return inputData.articleData.count + 1 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if indexPath.row == 0 { - let cell = CurriculumArticleByWeekRowZeroTableViewCell.dequeueReusableCell(to: curriculumListByWeekTableView) -// guard let weekCount else { return CurriculumTableViewCell() } cell.inputData = inputData?.week return cell } else { - let cell = CurriculumArticleByWeekTableViewCell.dequeueReusableCell(to: curriculumListByWeekTableView) cell.inputData = inputData?.articleData[indexPath.row - 1] cell.selectionStyle = .none @@ -124,17 +83,9 @@ extension CurriculumListByWeekCollectionViewCell: UITableViewDataSource{ } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.row == 0 { - return - } else { + if indexPath.row != 0 { guard let inputData else { return } - NotificationCenter.default.post(name: NSNotification.Name("didSelectTableViewCell"), - object: inputData.articleData[indexPath.row-1].articleId) - + NotificationCenter.default.post(name: NSNotification.Name("didSelectTableViewCell"), object: inputData.articleData[indexPath.row-1].articleId) } } } - -extension CurriculumListByWeekCollectionViewCell: UITableViewDelegate {} - - diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift index f2a19d3f..5cbbb753 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift @@ -18,178 +18,124 @@ protocol CurriculumTableViewToggleButtonTappedProtocol: AnyObject { final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { weak var delegate: CurriculumTableViewToggleButtonTappedProtocol? - + var cellIndexPath: IndexPath? - private enum Size { - static let contentImageView: CGFloat = 120 / 335 - } - private let curriculumWeekLabelView = UIView() - - private let curriculumWholeStackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.spacing = 15 - return stackView - }() - - private let curriculumContentStackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.spacing = 12 - return stackView - }() - - private let weekLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2M) - label.textColor = .designSystem(.gray500) - label.backgroundColor = .designSystem(.background) - return label - }() - - private let weekTitleLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2R) - label.textColor = .designSystem(.gray100) - label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) - label.textAlignment = .left - return label - }() - - private let contentImageView: UIImageView = { - let imageView = UIImageView() - imageView.isUserInteractionEnabled = true - return imageView - }() - - private let contentTextLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body3R) - label.textColor = .designSystem(.gray500) - label.numberOfLines = 0 - return label - }() - - private let divider: UIView = { - let line = UIView() - line.backgroundColor = .designSystem(.gray800) - return line - }() - - lazy var curriculumToggleDirectionButton: UIButton = { - var button = UIButton() - button.marginImageWithText(margin: 19) - button.setImage(ImageLiterals.Curriculum.arrowDownSmall, for: .normal) - button.setImage(ImageLiterals.Curriculum.arrowUpSmall, for: .selected) - button.setContentCompressionResistancePriority(.required, for: .horizontal) - button.addButtonAction { _ in - self.delegate?.toggleButtonTapped(indexPath: self.cellIndexPath) - } - return button - }() - - private lazy var moveToArticleListByWeekButton: UIButton = { - let button = UIButton() - button.setImage(ImageLiterals.Curriculum.arrowRightCircle, for: .normal) - button.addButtonAction { _ in - self.delegate?.moveToListByWeekButtonTapped(indexPath: self.cellIndexPath) - } - return button - }() + private let curriculumWholeStackView = LHStackView(axis: .vertical, spacing: 15) + private let curriculumContentStackView = LHStackView(axis: .vertical, spacing: 12) + private let weekLabel = LHLabel(type: .body2M, color: .gray500, backgroundColor: .background) + private let weekTitleLabel = LHLabel(type: .body2R, color: .gray100, alignment: .left) + private let contentTextLabel = LHLabel(type: .body3R, color: .gray500, lines: 0) + private let contentImageView = LHImageView() + private let divider = LHUnderLine(lineColor: .gray800) + lazy var curriculumToggleDirectionButton = LHToggleImageButton(normal: ImageLiterals.Curriculum.arrowDownSmall, + select: ImageLiterals.Curriculum.arrowUpSmall) + private lazy var moveToArticleListByWeekButton = LHImageButton(setImage: ImageLiterals.Curriculum.arrowRightCircle) var inputData: CurriculumDummyData? { didSet { guard let inputData else { return } - self.weekLabel.text = inputData.curriculumWeek - self.weekTitleLabel.text = inputData.curriculumWeekTitle - self.contentImageView.image = inputData.curriculumImage - self.contentTextLabel.text = inputData.curriculumText - self.contentTextLabel.setTextWithLineHeight(lineHeight: 22) - self.curriculumContentStackView.isHidden = !inputData.isExpanded // false -> true -> 안보이게됨 - self.weekLabel.textColor = inputData.isExpanded - ? .designSystem(.componentLionRed) - : .designSystem(.gray500) + configureData(inputData) } } override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - + setAddTarget() } @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - - } private extension CurriculumTableViewCell { + + enum Size { + static let contentImageView: CGFloat = 120 / 335 + } + func setUI() { self.backgroundColor = .designSystem(.background) + weekTitleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + contentImageView.isUserInteractionEnabled = true + curriculumToggleDirectionButton.marginImageWithText(margin: 19) + curriculumToggleDirectionButton.setContentCompressionResistancePriority(.required, for: .horizontal) + } func setHierarchy() { - curriculumWeekLabelView.addSubviews(weekLabel, weekTitleLabel, curriculumToggleDirectionButton) contentImageView.addSubviews(moveToArticleListByWeekButton) curriculumContentStackView.addArrangedSubviews(contentImageView, contentTextLabel) curriculumWholeStackView.addArrangedSubviews(curriculumWeekLabelView, curriculumContentStackView) contentView.addSubviews(curriculumWholeStackView, divider) - } func setLayout() { - - weekLabel.snp.makeConstraints{ + weekLabel.snp.makeConstraints { $0.leading.equalToSuperview() $0.centerY.equalToSuperview() $0.top.equalToSuperview() $0.bottom.equalToSuperview() } - weekTitleLabel.snp.makeConstraints{ + weekTitleLabel.snp.makeConstraints { $0.centerY.equalTo(weekLabel) $0.leading.equalTo(weekLabel.snp.trailing).offset(8).priority(.high) } - curriculumToggleDirectionButton.snp.makeConstraints{ + curriculumToggleDirectionButton.snp.makeConstraints { $0.leading.greaterThanOrEqualTo(weekTitleLabel.snp.trailing).offset(8) $0.centerY.equalTo(weekLabel) $0.trailing.equalToSuperview().offset(12) } - curriculumWholeStackView.snp.makeConstraints{ + curriculumWholeStackView.snp.makeConstraints { $0.top.bottom.equalToSuperview().inset(16) $0.leading.trailing.equalToSuperview().inset(20) } - divider.snp.makeConstraints{ + divider.snp.makeConstraints { $0.leading.trailing.equalToSuperview().inset(20) $0.height.equalTo(1) $0.bottom.equalToSuperview() } - contentImageView.snp.makeConstraints{ + contentImageView.snp.makeConstraints { $0.height.equalTo(contentImageView.snp.width).multipliedBy(Size.contentImageView) } - moveToArticleListByWeekButton.snp.makeConstraints{ + moveToArticleListByWeekButton.snp.makeConstraints { $0.centerY.equalToSuperview() $0.trailing.equalToSuperview().inset(12) } } + + func setAddTarget() { + curriculumToggleDirectionButton.addButtonAction { _ in + self.delegate?.toggleButtonTapped(indexPath: self.cellIndexPath) + } + + moveToArticleListByWeekButton.addButtonAction { _ in + self.delegate?.moveToListByWeekButtonTapped(indexPath: self.cellIndexPath) + } + } + + func configureData(_ inputData: CurriculumDummyData) { + self.weekLabel.text = inputData.curriculumWeek + self.weekTitleLabel.text = inputData.curriculumWeekTitle + self.contentImageView.image = inputData.curriculumImage + self.contentTextLabel.text = inputData.curriculumText + self.contentTextLabel.setTextWithLineHeight(lineHeight: 22) + self.curriculumContentStackView.isHidden = !inputData.isExpanded + self.weekLabel.textColor = inputData.isExpanded ? .designSystem(.componentLionRed) : .designSystem(.gray500) + } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift index df97063c..e527a713 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumListByWeekViewController.swift @@ -18,6 +18,7 @@ protocol CurriculumListManager { final class CurriculumListByWeekViewController: UIViewController { private let manager: CurriculumListManager + private let curriculumListByWeekCollectionView = LHCollectionView(color: .background, scroll: false) private lazy var navigationBar = LHNavigationBarView(type: .curriculumByWeek, viewController: self) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift index a3951dd7..cc0d5c84 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift @@ -18,13 +18,7 @@ protocol CurriculumManager { final class CurriculumViewController: UIViewController, CurriculumTableViewToggleButtonTappedProtocol{ private let manager: CurriculumManager - private var curriculumViewDatas = CurriculumMonthData.dummy() - private var userInfoData: UserInfoData? { - didSet { - configureUserInfoData() - } - } - + private lazy var navigationBar = LHNavigationBarView(type: .curriculumMain, viewController: self) private let progressBar = LHLottie() private let dDayLabel = LHLabel(type: .body3R, color: .gray400) @@ -33,8 +27,13 @@ final class CurriculumViewController: UIViewController, CurriculumTableViewToggl private let gradientImage = LHImageView(in: ImageLiterals.Curriculum.gradient) private let curriculumTableView = CurriculumTableView() - private let headerHeight: CGFloat = 40.0 private var isFirstPresented: Bool = true + private var curriculumViewDatas = CurriculumMonthData.dummy() + private var userInfoData: UserInfoData? { + didSet { + configureUserInfoData() + } + } init(manager: CurriculumManager) { self.manager = manager @@ -51,7 +50,6 @@ final class CurriculumViewController: UIViewController, CurriculumTableViewToggl setHierarchy() setLayout() setDelegate() - setTableView() setAddTarget() } @@ -93,7 +91,6 @@ private extension CurriculumViewController { $0.size.equalTo(100) $0.leading.equalToSuperview().inset(48) $0.centerY.equalTo(progressBar) - } dDayLabel.snp.makeConstraints{ @@ -105,7 +102,6 @@ private extension CurriculumViewController { $0.leading.trailing.equalToSuperview() $0.width.equalTo(Constant.Screen.width) $0.height.equalTo(curriculumUserInfoView.snp.width).multipliedBy(Size.userInfoView) - } progressBar.snp.makeConstraints{ @@ -130,11 +126,6 @@ private extension CurriculumViewController { curriculumTableView.dataSource = self } - func setTableView(){ - CurriculumTableViewCell.register(to: curriculumTableView) - curriculumTableView.register(CurriculumTableViewHeaderView.self, forHeaderFooterViewReuseIdentifier: CurriculumTableViewHeaderView.className) - } - func setAddTarget() { navigationBar.rightFirstBarItemAction { let bookmarkViewController = BookmarkViewController(manager: BookmarkMangerImpl(bookmarkService: BookmarkServiceImpl(apiService: APIService()))) @@ -191,17 +182,6 @@ extension CurriculumViewController: UITableViewDataSource { return curriculumViewDatas.count } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let headerView = CurriculumTableViewHeaderView(reuseIdentifier: CurriculumTableViewHeaderView.className) - let month = curriculumViewDatas[section].month - headerView.configureHeaderView(month: month) - return headerView - } - - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return headerHeight - } - func toggleButtonTapped(indexPath: IndexPath?) { self.isFirstPresented = false guard let indexPath else { return } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumListByCategoryTableView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumListByCategoryTableView.swift new file mode 100644 index 00000000..18d4005e --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumListByCategoryTableView.swift @@ -0,0 +1,28 @@ +// +// CurriculumListByCategoryTableView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/25. +// + +import UIKit + +final class CurriculumListByWeekTableView: UITableView { + init() { + super.init(frame: .zero, style: .plain) + self.contentInsetAdjustmentBehavior = .always + self.showsVerticalScrollIndicator = false + self.backgroundColor = .designSystem(.background) + self.separatorStyle = .none + CurriculumArticleByWeekTableViewCell.register(to: self) + CurriculumArticleByWeekRowZeroTableViewCell.register(to: self) + let footerView = UIView() + footerView.backgroundColor = .designSystem(.background) + footerView.frame.size.height = 76 + self.tableFooterView = footerView + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift index d70b6e72..bcd066f5 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumTableView.swift @@ -17,6 +17,8 @@ final class CurriculumTableView: UITableView { self.sectionFooterHeight = 40 self.separatorStyle = .none self.showsVerticalScrollIndicator = false + CurriculumTableViewCell.register(to: self) + self.register(CurriculumTableViewHeaderView.self, forHeaderFooterViewReuseIdentifier: CurriculumTableViewHeaderView.className) } required init?(coder: NSCoder) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift index 253b13fa..697a5b3e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift @@ -12,12 +12,6 @@ import SnapKit final class CurriculumUserInfoView: UIView { - var userInfo: UserInfoData? { - didSet { - configureUserInfo(data: userInfo) - } - } - private let weekImageView = LHImageView() private let userWeekLabel = LHLabel(type: .head3, color: .gray100) private let weekLabel = LHLabel(type: .head3, color: .white, basicText: "주") @@ -26,6 +20,12 @@ final class CurriculumUserInfoView: UIView { private let dayLabel = LHLabel(type: .head3, color: .white, basicText: "일차") private let userWeekDayInfoView = LHImageView() + var userInfo: UserInfoData? { + didSet { + configureUserInfo(data: userInfo) + } + } + override init(frame: CGRect) { super.init(frame: .zero) } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift index 46d8e77c..879a6435 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/GetFetalNicknameViewController.swift @@ -22,7 +22,7 @@ final class GetFetalNicknameViewController: UIViewController { private let descriptionLabel = LHOnboardingDescriptionLabel("아직이라면, 닉네임을 적어주세요.") private let fetalNickNameErrorLabel = LHOnboardingErrorLabel() private let fetalNickNameTextfield = NHOnboardingTextfield(textFieldType: .fetalNickname) - private let textFieldUnderLine = LHUnderLine(lineColor: .designSystem(.lionRed)) + private let textFieldUnderLine = LHUnderLine(lineColor: .lionRed) public override func viewDidLoad() { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift index 8e2f17d1..92b0da83 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift @@ -41,7 +41,6 @@ final class OnboardingViewController: UIViewController { presentOnboardingView(oldValue: onboardingFlow) case .toCompleteOnboarding: presentCompleteOnboardingView() - } } } @@ -133,7 +132,7 @@ private extension OnboardingViewController { } self.nextOnboaringProcess(nickName: fetalNickName, minCount: 1, maxCount: 10) } - + onboardingNavigationbar.backButtonAction { self.backOnboardingProcess() } @@ -175,7 +174,6 @@ private extension OnboardingViewController { func presentCompleteOnboardingView() { self.view.endEditing(true) - self.nextButton.isUserInteractionEnabled = false let completeViewController = CompleteOnbardingViewController() let passingData = UserOnboardingModel(kakaoAccessToken: self.kakaoAccessToken, pregnacny: self.pregnancy, fetalNickname: self.fetalNickName) From c16982fa0da7bb753ee5edbbf5e3977a4bda5842 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 09:42:27 +0900 Subject: [PATCH 33/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=94=94=EC=9E=90=EC=9D=B8?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPageViewController.swift | 46 ++++++++----------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift index bac9f595..7aff2932 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/ViewControllers/MyPageViewController.swift @@ -17,32 +17,22 @@ protocol MyPageManager { } final class MyPageViewController: UIViewController { - - // MARK: - Properties + + private let manager: MyPageManager + + private lazy var navigtaionBar = LHNavigationBarView(type: .myPage, viewController: self) + private let myPageCollectionView = LHCollectionView(color: .background) private let myPageServiceLabelList = MyPageLocalData.myPageServiceLabelList private let myPageSectionLabelList = MyPageLocalData.myPageSectionLabelList private let myPageAppSettingLabelList = MyPageAppSettinLocalgData.myPageAppSettingDataList - private var myPageAppData: MyPageAppData? { didSet { myPageCollectionView.reloadData() } } - - private let manager: MyPageManager - - // MARK: - UI Components - - private lazy var navigtaionBar = LHNavigationBarView(type: .myPage, viewController: self) - - private let myPageCollectionView = { - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) - collectionView.backgroundColor = .clear - collectionView.showsVerticalScrollIndicator = false - return collectionView - }() + // MARK: - 회원탈퇴를 위한 임시 버튼 private let resignButton: UIButton = { let button = UIButton() button.alpha = 0.1 @@ -60,7 +50,6 @@ final class MyPageViewController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() - setUI() setHierarchy() setLayout() @@ -73,16 +62,7 @@ final class MyPageViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - - Task { - do { - let data = try await manager.getMyPage() - myPageAppData = data - } catch { - guard let error = error as? NetworkError else { return } - handleError(error) - } - } + setUIFromNetworking() } override func viewWillDisappear(_ animated: Bool) { @@ -154,6 +134,18 @@ private extension MyPageViewController { func setTabbar() { self.tabBarController?.tabBar.isHidden = true } + + func setUIFromNetworking() { + Task { + do { + let data = try await manager.getMyPage() + myPageAppData = data + } catch { + guard let error = error as? NetworkError else { return } + handleError(error) + } + } + } } extension MyPageViewController: ViewControllerServiceable { From b2f879df8039471d0c93708cc7c8a129cdff6fe0 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 10:03:46 +0900 Subject: [PATCH 34/39] =?UTF-8?q?=F0=9F=94=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArticleCategoryViewController.swift | 61 ++++++------------- .../Views/ArticleDetailView.swift | 60 ------------------ 2 files changed, 18 insertions(+), 103 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Views/ArticleDetailView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift index 52c0bfa5..e6db917f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift @@ -11,66 +11,36 @@ import UIKit import SnapKit final class ArticleCategoryViewController: UIViewController { - - private enum Size { - static let cellOffset: CGFloat = 51 - static let numberOfCellsinRow: CGFloat = 2 - static let imageWidth: CGFloat = 162 - static let imageHeight: CGFloat = 112 - } - + private lazy var navigationBar = LHNavigationBarView(type: .explore, viewController: self) + private lazy var titleLabel = LHLabel(type: .head2, color: .white, lines: 2, basicText: "카테고리별\n아티클 모아보기") + private lazy var subtitleLabel = LHLabel(type: .body3R, color: .gray400, basicText: "똑똑한 아빠들의 비밀 습관") + private lazy var categoryArticleCollectionView = LHCollectionView(color: .background) private var dummyCase = CategoryImage.dummy() - - private lazy var titleLabel: UILabel = { - let label = UILabel() - label.text = "카테고리별\n아티클 모아보기" - label.numberOfLines = 2 - label.font = .pretendard(.head2) - label.textColor = .designSystem(.white) - return label - }() - - private lazy var subtitleLabel: UILabel = { - let label = UILabel() - label.text = "똑똑한 아빠들의 비밀 습관" - label.font = .pretendard(.body3R) - label.textColor = .designSystem(.gray400) - return label - }() - - private lazy var categoryArticleCollectionView: UICollectionView = { - let layout = UICollectionViewFlowLayout() - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.backgroundColor = .designSystem(.background) - collectionView.showsVerticalScrollIndicator = false - return collectionView - }() public override func viewDidLoad() { super.viewDidLoad() - // MARK: - 컴포넌트 설정 setUI() setHierarchy() setNavigation() - - // MARK: - autolayout설정 setLayout() - - // MARK: - button의 addtarget설정 setAddTarget() - - // MARK: - delegate설정 setDelegate() - + setCollectionView() } } private extension ArticleCategoryViewController { + + enum Size { + static let cellOffset: CGFloat = 51 + static let numberOfCellsinRow: CGFloat = 2 + static let imageWidth: CGFloat = 162 + static let imageHeight: CGFloat = 112 + } + func setUI() { - ArticleCategoryCollectionViewCell.register(to: categoryArticleCollectionView) - self.navigationController?.isNavigationBarHidden = true view.backgroundColor = .designSystem(.background) } @@ -113,11 +83,16 @@ private extension ArticleCategoryViewController { } func setNavigation() { + self.navigationController?.isNavigationBarHidden = true navigationBar.snp.makeConstraints { make in make.top.equalTo(view.safeAreaLayoutGuide.snp.top) make.leading.trailing.equalToSuperview() } } + + func setCollectionView() { + ArticleCategoryCollectionViewCell.register(to: categoryArticleCollectionView) + } } extension ArticleCategoryViewController: UICollectionViewDataSource { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Views/ArticleDetailView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Views/ArticleDetailView.swift deleted file mode 100644 index c10632d4..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Views/ArticleDetailView.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// ArticleDetailView.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleDetail. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleDetailView: UIView { - - override init(frame: CGRect) { - super.init(frame: frame) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - -} - -private extension ArticleDetailView { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} From 55a847b5049e51b9b6c87c5d24968bd14c77ee7b Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 10:04:38 +0900 Subject: [PATCH 35/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=95=84=ED=8B=B0?= =?UTF-8?q?=ED=81=B4=EA=B4=80=EB=A0=A8=20=EB=94=94=EC=9E=90=EC=9D=B8?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @ffalswo2 아티클디테일은 안건드렸습니당 --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 16 ----- .../Color/clear.colorset/Contents.json | 20 ++++++ .../Global/UIComponents/LHImageView.swift | 14 +++- .../LionHeart-iOS/Global/Utils/Palette.swift | 1 + .../ArticleCategoryCollectionViewCell.swift | 40 ++---------- .../ArticleListByCategoryTableViewCell.swift | 65 ------------------- .../ArticleListByCategoryHeaderView.swift | 44 +------------ .../ChallengeViewController.swift | 2 +- ...CurriculumArticleByWeekTableViewCell.swift | 10 +-- .../Cells/CurriculumTableViewCell.swift | 2 +- .../CurriculumViewController.swift | 2 +- .../Views/CurriculumUserInfoView.swift | 6 +- 12 files changed, 48 insertions(+), 174 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/Resources/Assets.xcassets/Color/clear.colorset/Contents.json delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Cells/ArticleListByCategoryTableViewCell.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 0140a743..f224d08d 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -156,11 +156,9 @@ C0DF034B2A5A9B6A0037F740 /* CurriculumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF034A2A5A9B6A0037F740 /* CurriculumViewController.swift */; }; C0DF034D2A5A9B8D0037F740 /* (null) in Sources */ = {isa = PBXBuildFile; }; C0DF034F2A5A9B9C0037F740 /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF034E2A5A9B9C0037F740 /* MyPageViewController.swift */; }; - C0DF03512A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03502A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift */; }; C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03522A5A9BC80037F740 /* ArticleListByCategoryViewController.swift */; }; C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */; }; C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */; }; - C0DF03652A5A9C610037F740 /* ArticleDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */; }; C0DF03672A5A9C680037F740 /* ArticleDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03662A5A9C680037F740 /* ArticleDetailViewController.swift */; }; C0DF036B2A5A9C930037F740 /* BookMarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036A2A5A9C930037F740 /* BookMarkView.swift */; }; C0DF03732A5A9CB50037F740 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03722A5A9CB50037F740 /* TodayViewController.swift */; }; @@ -381,11 +379,9 @@ C0DF03482A5A9ACB0037F740 /* DummyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DummyModel.swift; sourceTree = ""; }; C0DF034A2A5A9B6A0037F740 /* CurriculumViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumViewController.swift; sourceTree = ""; }; C0DF034E2A5A9B9C0037F740 /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = ""; }; - C0DF03502A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryTableViewCell.swift; sourceTree = ""; }; C0DF03522A5A9BC80037F740 /* ArticleListByCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryViewController.swift; sourceTree = ""; }; C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewController.swift; sourceTree = ""; }; C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryView.swift; sourceTree = ""; }; - C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailView.swift; sourceTree = ""; }; C0DF03662A5A9C680037F740 /* ArticleDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailViewController.swift; sourceTree = ""; }; C0DF036A2A5A9C930037F740 /* BookMarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookMarkView.swift; sourceTree = ""; }; C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkViewController.swift; sourceTree = ""; }; @@ -885,7 +881,6 @@ B598920C2A56B3B700CE1FEB /* ArticleListByCategory */ = { isa = PBXGroup; children = ( - B59892132A56B53B00CE1FEB /* Cells */, B59892122A56B52F00CE1FEB /* ViewControllers */, B59892112A56B52B00CE1FEB /* Views */, ); @@ -942,14 +937,6 @@ path = ViewControllers; sourceTree = ""; }; - B59892132A56B53B00CE1FEB /* Cells */ = { - isa = PBXGroup; - children = ( - C0DF03502A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift */, - ); - path = Cells; - sourceTree = ""; - }; B59892242A56B69D00CE1FEB /* Views */ = { isa = PBXGroup; children = ( @@ -977,7 +964,6 @@ B598922A2A56B6BE00CE1FEB /* Views */ = { isa = PBXGroup; children = ( - C0DF03642A5A9C610037F740 /* ArticleDetailView.swift */, B5C6A2B12A5DB0B10021BE5E /* ArticleDetailTableView.swift */, ); path = Views; @@ -1694,8 +1680,6 @@ C0856B692ABFB9140026D9F8 /* ArticleServiceImpl.swift in Sources */, F46522FD2A6048660083FBB2 /* CurriculumImagesByWeek.swift in Sources */, 4A8980CA2A614F8700746C58 /* MyPageModel.swift in Sources */, - C0DF03512A5A9BBE0037F740 /* ArticleListByCategoryTableViewCell.swift in Sources */, - C0DF03652A5A9C610037F740 /* ArticleDetailView.swift in Sources */, 4A8980C52A611EE200746C58 /* MyPageProfileCollectionViewCell.swift in Sources */, D3BA0B742A5CFA7B00B6361F /* ArticleCategoryModel.swift in Sources */, C0DF033F2A5A959A0037F740 /* UIButton+.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/Resources/Assets.xcassets/Color/clear.colorset/Contents.json b/LionHeart-iOS/LionHeart-iOS/Global/Resources/Assets.xcassets/Color/clear.colorset/Contents.json new file mode 100644 index 00000000..2beeb40b --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/Resources/Assets.xcassets/Color/clear.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.000", + "blue" : "0.000", + "green" : "0.000", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift index 33099851..8193c313 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHImageView.swift @@ -9,9 +9,21 @@ import UIKit final class LHImageView: UIImageView { - init(in image: UIImage? = nil) { + init(in image: UIImage? = nil, contentMode: UIView.ContentMode) { super.init(frame: .zero) self.image = image + self.contentMode = contentMode + } + + func makeRound(_ ratio: CGFloat) -> Self { + self.clipsToBounds = true + self.layer.cornerRadius = ratio + return self + } + + func opacity(_ ratio: Float) -> Self { + self.layer.opacity = ratio + return self } required init?(coder: NSCoder) { diff --git a/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift b/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift index 32e91407..89b38bfe 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/Utils/Palette.swift @@ -24,4 +24,5 @@ enum Palette: String { case componentLionRed = "ComponentLionRed" case background = "background" case kakao = "KakaoYellow" + case clear = "clear" } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Cells/ArticleCategoryCollectionViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Cells/ArticleCategoryCollectionViewCell.swift index 5f226cf8..f1d7b870 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Cells/ArticleCategoryCollectionViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Cells/ArticleCategoryCollectionViewCell.swift @@ -11,9 +11,11 @@ import UIKit import SnapKit final class ArticleCategoryCollectionViewCell: UICollectionViewCell, CollectionViewCellRegisterDequeueProtocol { + + private let categoryImageView = LHImageView(contentMode: .scaleToFill).makeRound(10) + private let categoryInfoLabel = LHLabel(type: .title1, color: .white) var categorayClosure: ((String) -> Void)? - var inputData: CategoryImage? { didSet { guard let data = inputData else { return } @@ -21,39 +23,12 @@ final class ArticleCategoryCollectionViewCell: UICollectionViewCell, CollectionV categoryInfoLabel.text = data.infoDdescription } } - - private let categoryImageView: UIImageView = { - let imageview = UIImageView() - imageview.contentMode = .scaleToFill - imageview.clipsToBounds = true - imageview.layer.cornerRadius = 10 - return imageview - }() - - private let categoryInfoLabel: UILabel = { - let label = UILabel() - label.textColor = .designSystem(.white) - label.font = .systemFont(ofSize: 16, weight: .semibold) - return label - }() - override init(frame: CGRect) { super.init(frame: frame) - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() } @available(*, unavailable) @@ -64,6 +39,7 @@ final class ArticleCategoryCollectionViewCell: UICollectionViewCell, CollectionV private extension ArticleCategoryCollectionViewCell { func setUI() { + categoryInfoLabel.backgroundColor = .designSystem(.clear) backgroundColor = .designSystem(.background) } @@ -80,12 +56,4 @@ private extension ArticleCategoryCollectionViewCell { make.bottom.leading.equalToSuperview().inset(8) } } - - func setAddTarget() { - - } - - func setDelegate() { - - } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Cells/ArticleListByCategoryTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Cells/ArticleListByCategoryTableViewCell.swift deleted file mode 100644 index 95ee7253..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Cells/ArticleListByCategoryTableViewCell.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// ArticleListByCategoryTableViewCell.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleListByCategory. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleListByCategoryTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - - var inputData: DummyModel? { - didSet { - /// action - } - } - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } -} - -private extension ArticleListByCategoryTableViewCell { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryHeaderView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryHeaderView.swift index ea284c2c..32b49e4e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryHeaderView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/Views/ArticleListByCategoryHeaderView.swift @@ -13,54 +13,24 @@ import SnapKit final class ArticleListByCategoryHeaderView: UIView { private let categoryTagLabel: UILabelPadding = { - let label = UILabelPadding() + let label = UILabelPadding(padding: .init(top: 4, left: 8, bottom: 4, right: 8)) label.text = "출산 직전" label.font = .pretendard(.body4) label.textColor = .designSystem(.componentLionRed) label.layer.borderColor = .designSystem(.componentLionRed) label.layer.borderWidth = 1 label.layer.cornerRadius = 3 - label.topPadding = 4 - label.bottomPadding = 4 - label.leftPadding = 8 - label.rightPadding = 8 return label }() - private let categorytitleLabel: UILabel = { - let label = UILabel() - label.text = "출산 준비,\n불필요한 지출은 그만!" - label.numberOfLines = 3 - label.font = .pretendard(.head2) - label.textColor = .designSystem(.white) - return label - }() - - private let categorysubtitleLabel: UILabel = { - let label = UILabel() - label.text = "라이온하트가 전하는 예산 절약 노하우 대공개" - label.numberOfLines = 2 - label.font = .pretendard(.body3R) - label.textColor = .designSystem(.gray400) - return label - }() + private let categorytitleLabel = LHLabel(type: .head2, color: .white, lines: 3, basicText: "출산 준비,\n불필요한 지출은 그만!") + private let categorysubtitleLabel = LHLabel(type: .body3R, color: .gray400, lines: 2, basicText: "라이온하트가 전하는 예산 절약 노하우 대공개") override init(frame: CGRect) { super.init(frame: frame) - // MARK: - 컴포넌트 설정 setUI() - - // MARK: - addsubView setHierarchy() - - // MARK: - autolayout설정 setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() } @available(*, unavailable) @@ -93,12 +63,4 @@ private extension ArticleListByCategoryHeaderView { make.leading.trailing.equalToSuperview().inset(20) } } - - func setAddTarget() { - - } - - func setDelegate() { - - } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index d2e92d9f..b3cd195c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -32,7 +32,7 @@ final class ChallengeViewController: UIViewController { private let nicknameLabel = LHLabel(type: .body2R, color: .gray200) private let challengeDayLabel = LHLabel(type: .head3, color: .white) private let challengelevelLabel = LHLabel(type: .body4, color: .gray500) - private let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05) + private let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05, contentMode: .scaleToFill) private lazy var lottieImageView = LHLottie() private let challengeDayCheckCollectionView = LHCollectionView() diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift index b57d0998..e550f954 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift @@ -23,21 +23,13 @@ final class CurriculumArticleByWeekTableViewCell: UITableViewCell, TableViewCell var bookMarkButtonTapped: ((Bool, IndexPath) -> Void)? private let tableViewCellWholeView = UIView() - private let articleTitleLabel = LHLabel(type: .head3, color: .white) private let articleTagLabel = LHLabel(type: .body4, color: .gray400) private let articleReadTimeLabel = LHLabel(type: .body4, color: .gray500) private let articleContentLabel = LHLabel(type: .body3R, color: .gray300, lines: 2) private lazy var bookMarkButton = LHToggleImageButton(normal: ImageLiterals.BookMark.inactiveBookmarkSmall, select: ImageLiterals.BookMark.activeBookmarkSmall) - - private let articleImageView: UIImageView = { - let imageView = UIImageView() - imageView.layer.opacity = 0.4 - imageView.clipsToBounds = true - imageView.layer.cornerRadius = 4 - return imageView - }() + private let articleImageView = LHImageView(contentMode: .scaleToFill).makeRound(4).opacity(0.4) private let readTimeAndBookmarkView: UIView = { let view = UIView() diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift index 5cbbb753..a89b0a0a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumTableViewCell.swift @@ -27,7 +27,7 @@ final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDeque private let weekLabel = LHLabel(type: .body2M, color: .gray500, backgroundColor: .background) private let weekTitleLabel = LHLabel(type: .body2R, color: .gray100, alignment: .left) private let contentTextLabel = LHLabel(type: .body3R, color: .gray500, lines: 0) - private let contentImageView = LHImageView() + private let contentImageView = LHImageView(contentMode: .scaleToFill) private let divider = LHUnderLine(lineColor: .gray800) lazy var curriculumToggleDirectionButton = LHToggleImageButton(normal: ImageLiterals.Curriculum.arrowDownSmall, select: ImageLiterals.Curriculum.arrowUpSmall) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift index cc0d5c84..3e187d36 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/ViewControllers/CurriculumViewController.swift @@ -24,7 +24,7 @@ final class CurriculumViewController: UIViewController, CurriculumTableViewToggl private let dDayLabel = LHLabel(type: .body3R, color: .gray400) private let dDayView = UIView() private lazy var curriculumUserInfoView = CurriculumUserInfoView() - private let gradientImage = LHImageView(in: ImageLiterals.Curriculum.gradient) + private let gradientImage = LHImageView(in: ImageLiterals.Curriculum.gradient, contentMode: .scaleToFill) private let curriculumTableView = CurriculumTableView() private var isFirstPresented: Bool = true diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift index 697a5b3e..dde37ff0 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Views/CurriculumUserInfoView.swift @@ -12,13 +12,13 @@ import SnapKit final class CurriculumUserInfoView: UIView { - private let weekImageView = LHImageView() + private let weekImageView = LHImageView(contentMode: .scaleToFill) private let userWeekLabel = LHLabel(type: .head3, color: .gray100) private let weekLabel = LHLabel(type: .head3, color: .white, basicText: "주") - private let dayImageView = LHImageView(in: ImageLiterals.Curriculum.dayBackground) + private let dayImageView = LHImageView(in: ImageLiterals.Curriculum.dayBackground, contentMode: .scaleToFill) private let userDayLabel = LHLabel(type: .head3, color: .gray100, alignment: .center) private let dayLabel = LHLabel(type: .head3, color: .white, basicText: "일차") - private let userWeekDayInfoView = LHImageView() + private let userWeekDayInfoView = LHImageView(contentMode: .scaleToFill) var userInfo: UserInfoData? { didSet { From 5e3b01bcf61a944c84bed581d10047394473ed25 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 10:39:10 +0900 Subject: [PATCH 36/39] =?UTF-8?q?=F0=9F=94=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/ArticleCategoryView.swift | 60 ------------------- .../Scenes/BookMark/Views/BookMarkView.swift | 60 ------------------- 2 files changed, 120 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Views/ArticleCategoryView.swift delete mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Views/BookMarkView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Views/ArticleCategoryView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Views/ArticleCategoryView.swift deleted file mode 100644 index b35e427e..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/Views/ArticleCategoryView.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// ArticleCategoryView.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 ArticleCategory. All rights reserved. -// - -import UIKit - -import SnapKit - -final class ArticleCategoryView: UIView { - - override init(frame: CGRect) { - super.init(frame: frame) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - -} - -private extension ArticleCategoryView { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Views/BookMarkView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Views/BookMarkView.swift deleted file mode 100644 index 308bd2a6..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/BookMark/Views/BookMarkView.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// BookMarkView.swift -// LionHeart-iOS -// -// Created by uiskim on 2023/07/09. -// Copyright (c) 2023 BookMark. All rights reserved. -// - -import UIKit - -import SnapKit - -final class BookMarkView: UIView { - - override init(frame: CGRect) { - super.init(frame: frame) - // MARK: - 컴포넌트 설정 - setUI() - - // MARK: - addsubView - setHierarchy() - - // MARK: - autolayout설정 - setLayout() - - // MARK: - button의 addtarget설정 - setAddTarget() - - // MARK: - delegate설정 - setDelegate() - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - -} - -private extension BookMarkView { - func setUI() { - - } - - func setHierarchy() { - - } - - func setLayout() { - - } - - func setAddTarget() { - - } - - func setDelegate() { - - } -} From b5fd47457465c4536d20c947208f00d0adccd264 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 10:39:40 +0900 Subject: [PATCH 37/39] =?UTF-8?q?=F0=9F=92=84LHView=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/UIComponents/LHView.swift | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHView.swift diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHView.swift new file mode 100644 index 00000000..5a677f26 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHView.swift @@ -0,0 +1,36 @@ +// +// LHView.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/09/25. +// + +import UIKit + +final class LHView: UIView { + init(color: UIColor?) { + super.init(frame: .zero) + self.backgroundColor = color + } + + func makeRound(_ ratio: CGFloat) -> Self { + self.clipsToBounds = true + self.layer.cornerRadius = ratio + return self + } + + func opacity(_ ratio: Float) -> Self { + self.layer.opacity = ratio + return self + } + + func maskedCorners(corners: CACornerMask) -> Self { + self.layer.maskedCorners = corners + return self + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + From 76878c410ac2548eb80be7b9f950fdca02ede79d Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 10:40:23 +0900 Subject: [PATCH 38/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20cell=EC=9A=94?= =?UTF-8?q?=EC=86=8C=EB=93=A4=EC=97=90=20=EB=94=94=EC=9E=90=EC=9D=B8?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=EC=A0=81=EC=9A=A9(=EC=B0=AC?= =?UTF-8?q?=EB=AF=B8=20=EB=AF=BC=EC=9E=AC=EB=B7=B0=20=EC=A0=9C=EC=99=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 28 ++------ .../UIComponents/LHNavigationBarView.swift | 17 ++--- .../Cells/CopyRightTableViewCell.swift | 27 +++----- .../Cells/EditorTableViewCell.swift | 31 ++------- .../Cells/ThumnailTableViewCell.swift | 55 +++++----------- .../Cells/TitleTableViewCell.swift | 24 +------ ...heckCollectionViewCollectionViewCell.swift | 30 ++------- .../ChallengeViewController.swift | 14 ++-- ...lumArticleByWeekRowZeroTableViewCell.swift | 21 +++--- ...CurriculumArticleByWeekTableViewCell.swift | 13 +--- ...ageCustomerServiceCollectionViewCell.swift | 35 ++-------- .../ViewControllers/TodayViewController.swift | 34 ++++------ .../Scenes/Today/Views/TodayArticleView.swift | 66 +++---------------- 13 files changed, 91 insertions(+), 304 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index f224d08d..6d3681cd 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -139,6 +139,7 @@ C0B15E252AC103A50058D56B /* LHToggleImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E242AC103A50058D56B /* LHToggleImageButton.swift */; }; C0B15E272AC104D50058D56B /* LHImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E262AC104D50058D56B /* LHImageButton.swift */; }; C0B15E292AC106CA0058D56B /* CurriculumListByCategoryTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E282AC106CA0058D56B /* CurriculumListByCategoryTableView.swift */; }; + C0B15E2B2AC115F90058D56B /* LHView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E2A2AC115F90058D56B /* LHView.swift */; }; C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */; }; C0DF032D2A5A91D90037F740 /* DataTypeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */; }; C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF032E2A5A92170037F740 /* NameSpace.swift */; }; @@ -158,9 +159,7 @@ C0DF034F2A5A9B9C0037F740 /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF034E2A5A9B9C0037F740 /* MyPageViewController.swift */; }; C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03522A5A9BC80037F740 /* ArticleListByCategoryViewController.swift */; }; C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */; }; - C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */; }; C0DF03672A5A9C680037F740 /* ArticleDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03662A5A9C680037F740 /* ArticleDetailViewController.swift */; }; - C0DF036B2A5A9C930037F740 /* BookMarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036A2A5A9C930037F740 /* BookMarkView.swift */; }; C0DF03732A5A9CB50037F740 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03722A5A9CB50037F740 /* TodayViewController.swift */; }; C0DF03752A5A9CD00037F740 /* TabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF03742A5A9CD00037F740 /* TabBarViewController.swift */; }; C0DF037B2A5A9CF30037F740 /* OnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF037A2A5A9CF30037F740 /* OnboardingViewController.swift */; }; @@ -363,6 +362,7 @@ C0B15E242AC103A50058D56B /* LHToggleImageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHToggleImageButton.swift; sourceTree = ""; }; C0B15E262AC104D50058D56B /* LHImageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHImageButton.swift; sourceTree = ""; }; C0B15E282AC106CA0058D56B /* CurriculumListByCategoryTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListByCategoryTableView.swift; sourceTree = ""; }; + C0B15E2A2AC115F90058D56B /* LHView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHView.swift; sourceTree = ""; }; C0DF032A2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellRegisterDequeueProtocol.swift; sourceTree = ""; }; C0DF032C2A5A91D90037F740 /* DataTypeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTypeProtocol.swift; sourceTree = ""; }; C0DF032E2A5A92170037F740 /* NameSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameSpace.swift; sourceTree = ""; }; @@ -381,9 +381,7 @@ C0DF034E2A5A9B9C0037F740 /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = ""; }; C0DF03522A5A9BC80037F740 /* ArticleListByCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryViewController.swift; sourceTree = ""; }; C0DF03582A5A9BF80037F740 /* ArticleCategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewController.swift; sourceTree = ""; }; - C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryView.swift; sourceTree = ""; }; C0DF03662A5A9C680037F740 /* ArticleDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailViewController.swift; sourceTree = ""; }; - C0DF036A2A5A9C930037F740 /* BookMarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookMarkView.swift; sourceTree = ""; }; C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkViewController.swift; sourceTree = ""; }; C0DF036E2A5A9CA90037F740 /* TodayTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayTableViewCell.swift; sourceTree = ""; }; C0DF03722A5A9CB50037F740 /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = ""; }; @@ -757,6 +755,7 @@ C0B15E222AC100690058D56B /* LHStackView.swift */, C0B15E242AC103A50058D56B /* LHToggleImageButton.swift */, C0B15E262AC104D50058D56B /* LHImageButton.swift */, + C0B15E2A2AC115F90058D56B /* LHView.swift */, ); path = UIComponents; sourceTree = ""; @@ -851,7 +850,6 @@ children = ( 4A860AD22A626591002BA428 /* Model */, B598922F2A56B6ED00CE1FEB /* Cells */, - B598922E2A56B6E700CE1FEB /* Views */, B598922D2A56B6E300CE1FEB /* ViewControllers */, ); path = BookMark; @@ -915,7 +913,6 @@ D3BA0B722A5CFA6400B6361F /* Model */, B598922C2A56B6CA00CE1FEB /* Cells */, B59892252A56B6A000CE1FEB /* ViewControllers */, - B59892242A56B69D00CE1FEB /* Views */, ); path = ArticleCategory; sourceTree = ""; @@ -937,14 +934,6 @@ path = ViewControllers; sourceTree = ""; }; - B59892242A56B69D00CE1FEB /* Views */ = { - isa = PBXGroup; - children = ( - C0DF035A2A5A9C040037F740 /* ArticleCategoryView.swift */, - ); - path = Views; - sourceTree = ""; - }; B59892252A56B6A000CE1FEB /* ViewControllers */ = { isa = PBXGroup; children = ( @@ -999,14 +988,6 @@ path = ViewControllers; sourceTree = ""; }; - B598922E2A56B6E700CE1FEB /* Views */ = { - isa = PBXGroup; - children = ( - C0DF036A2A5A9C930037F740 /* BookMarkView.swift */, - ); - path = Views; - sourceTree = ""; - }; B598922F2A56B6ED00CE1FEB /* Cells */ = { isa = PBXGroup; children = ( @@ -1601,6 +1582,7 @@ B5C6A2C22A5DEA1B0021BE5E /* CopyRightTableViewCell.swift in Sources */, C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */, B59892E52A5B109900CE1FEB /* ScreenUtils.swift in Sources */, + C0B15E2B2AC115F90058D56B /* LHView.swift in Sources */, C0F029E82A5FB9EF00E0D185 /* RoundContainerView.swift in Sources */, B532E8652A5529F100F0DB19 /* BaseResponse.swift in Sources */, F4DB30B82A612D2800413EB9 /* CurriculumArticleByWeekTableViewCell.swift in Sources */, @@ -1660,7 +1642,6 @@ 4A2050152A5DCD1900C7AF3C /* UICollectionView+.swift in Sources */, C0DF037F2A5A9D090037F740 /* SplashViewController.swift in Sources */, C0F029D12A5FA87900E0D185 /* Float+.swift in Sources */, - C0DF036B2A5A9C930037F740 /* BookMarkView.swift in Sources */, B532E86C2A5564DD00F0DB19 /* Encodable+.swift in Sources */, C0DF032B2A5A918F0037F740 /* TableViewCellRegisterDequeueProtocol.swift in Sources */, B51220642A6039AA006CBE2D /* HttpMethod.swift in Sources */, @@ -1672,7 +1653,6 @@ 4A8980C72A6146DA00746C58 /* MyPageCustomerServiceCollectionViewCell.swift in Sources */, C0856B752ABFC4CB0026D9F8 /* MyPageManagerImpl.swift in Sources */, C0DF03752A5A9CD00037F740 /* TabBarViewController.swift in Sources */, - C0DF035B2A5A9C040037F740 /* ArticleCategoryView.swift in Sources */, C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */, C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */, B57BEB6C2A6149AD00D1727C /* NetworkRequest.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHNavigationBarView.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHNavigationBarView.swift index bf910cd5..c6bb2c9b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHNavigationBarView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHNavigationBarView.swift @@ -10,13 +10,8 @@ import UIKit final class LHNavigationBarView: UIView { // MARK: - UI Components - - private let titleLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head4) - label.textColor = .designSystem(.white) - return label - }() + private let titleLabel = LHLabel(type: .head4, color: .white) + private let leftBarItem: UIButton = { let button = UIButton() @@ -40,12 +35,8 @@ final class LHNavigationBarView: UIView { button.marginImageWithText(margin: 14) return button }() - - private let graySepartorLine: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.gray800) - return view - }() + + private let graySepartorLine = LHUnderLine(lineColor: .gray800) private lazy var rightBarItemsStackView: UIStackView = { let stackView = UIStackView(arrangedSubviews: [ diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/CopyRightTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/CopyRightTableViewCell.swift index 2f77773f..929246c0 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/CopyRightTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/CopyRightTableViewCell.swift @@ -11,28 +11,13 @@ import UIKit import SnapKit final class CopyRightTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - - private enum Size { - static let backgroundViewWidthHeightRatio: CGFloat = 118 / 375 - } - + + private let copyrightBackgroundView = LHView(color: .designSystem(.background)) + private let copyrightLabel = LHLabel(type: .body4, color: .gray600, basicText: "모든 콘텐츠는 제공자와 라이온하트에 저작권이 있습니다.\n저작권법에 의거 무단 전재 및 재배포를 금지합니다.") + //TODO: - inputData가 없는 경우.. var inputData: DummyModel? - private let copyrightBackgroundView: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.background) - return view - }() - - private let copyrightLabel: UILabel = { - let label = UILabel() - label.text = "모든 콘텐츠는 제공자와 라이온하트에 저작권이 있습니다.\n저작권법에 의거 무단 전재 및 재배포를 금지합니다." - label.font = .pretendard(.body4) - label.textColor = .designSystem(.gray600) - return label - }() - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setHierarchy() @@ -47,6 +32,10 @@ final class CopyRightTableViewCell: UITableViewCell, TableViewCellRegisterDequeu private extension CopyRightTableViewCell { + enum Size { + static let backgroundViewWidthHeightRatio: CGFloat = 118 / 375 + } + func setHierarchy() { contentView.addSubview(copyrightBackgroundView) copyrightBackgroundView.addSubview(copyrightLabel) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/EditorTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/EditorTableViewCell.swift index bb32027d..809e7316 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/EditorTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/EditorTableViewCell.swift @@ -11,37 +11,17 @@ import UIKit import SnapKit final class EditorTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - + + private let editorBackgroundView = LHView(color: .designSystem(.gray100)).makeRound(4) + private let titleLabel = LHLabel(type: .body2M, color: .gray900) + private let commentLabel = LHLabel(type: .body2R, color: .gray900, lines: 0) + var inputData: ArticleBlockData? { didSet { configureCell(inputData) } } - private let editorBackgroundView: UIView = { - let view = UIView() - view.layer.cornerRadius = 4 - view.clipsToBounds = true - view.backgroundColor = .designSystem(.gray100) - return view - }() - - private let titleLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2M) - label.textColor = .designSystem(.gray900) - return label - }() - - private let commentLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2R) - label.textColor = .designSystem(.gray900) - label.numberOfLines = 0 - return label - }() - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setHierarchy() @@ -79,7 +59,6 @@ private extension EditorTableViewCell { make.trailing.equalToSuperview().inset(16) make.bottom.equalToSuperview().inset(20) } - } func configureCell(_ model: ArticleBlockData?) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/ThumnailTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/ThumnailTableViewCell.swift index 25ee277a..be7918fe 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/ThumnailTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/ThumnailTableViewCell.swift @@ -11,45 +11,13 @@ import UIKit import SnapKit final class ThumnailTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - - private enum Size { - static let thumbnailWidthHeightRatio: CGFloat = 224 / 375 - } + + private let gradientImageView = LHImageView(in: ImageLiterals.Curriculum.gradient, contentMode: .scaleAspectFill) + private let thumbnailImageView = LHImageView(contentMode: .scaleAspectFill) + private let imageCaptionLabel = LHLabel(type: .body4, color: .gray500) + private lazy var bookMarkButton = LHToggleImageButton(normal: ImageLiterals.BookMark.inactiveBookmarkBig, select: ImageLiterals.BookMark.activeBookmarkBig) var bookmarkButtonDidTap: ((Bool) -> Void)? - - private let thumbnailImageView: UIImageView = { - let imageView = UIImageView() - imageView.contentMode = .scaleAspectFill - imageView.clipsToBounds = true - return imageView - }() - - let gradientImageView: UIImageView = { - let imageView = UIImageView() - imageView.image = ImageLiterals.Curriculum.gradient - return imageView - }() - - private let imageCaptionLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body4) - label.textColor = .designSystem(.gray500) - return label - }() - - private lazy var bookMarkButton: UIButton = { - let button = UIButton() - button.setImage(ImageLiterals.BookMark.inactiveBookmarkBig, for: .normal) - button.setImage(ImageLiterals.BookMark.activeBookmarkBig, for: .selected) - button.addButtonAction { [weak self] _ in - guard let self else { return } - button.isSelected.toggle() - self.bookmarkButtonDidTap?(button.isSelected) - } - return button - }() - var inputData: ArticleBlockData? { didSet { configureCell(inputData) @@ -67,6 +35,7 @@ final class ThumnailTableViewCell: UITableViewCell, TableViewCellRegisterDequeue super.init(style: style, reuseIdentifier: reuseIdentifier) setHierarchy() setLayout() + setAddTarget() } @available(*, unavailable) @@ -81,6 +50,10 @@ final class ThumnailTableViewCell: UITableViewCell, TableViewCellRegisterDequeue private extension ThumnailTableViewCell { + enum Size { + static let thumbnailWidthHeightRatio: CGFloat = 224 / 375 + } + func setHierarchy() { contentView.addSubviews(thumbnailImageView, imageCaptionLabel, bookMarkButton) thumbnailImageView.addSubview(gradientImageView) @@ -120,6 +93,14 @@ private extension ThumnailTableViewCell { } imageCaptionLabel.text = model.caption } + + func setAddTarget() { + bookMarkButton.addButtonAction { [weak self] _ in + guard let self else { return } + self.isSelected.toggle() + self.bookmarkButtonDidTap?(self.isSelected) + } + } } extension ThumnailTableViewCell { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/TitleTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/TitleTableViewCell.swift index a81d9ff9..93c58016 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/TitleTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleDetail/Cells/TitleTableViewCell.swift @@ -12,33 +12,15 @@ import SnapKit final class TitleTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol { - private let titleLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.head1) - label.textColor = .designSystem(.gray900) - label.numberOfLines = 2 - return label - }() - - private let authorLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body3R) - label.textColor = .designSystem(.gray700) - return label - }() - - private let seperatorLineView: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.gray100) - return view - }() + private let titleLabel = LHLabel(type: .head1, color: .gray900, lines: 2) + private let authorLabel = LHLabel(type: .body3R, color: .gray700) + private let seperatorLineView = LHUnderLine(lineColor: .gray100) var inputData: ArticleBlockData? { didSet { configureCell(inputData) } } - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift index 6b996ac5..4ff420fd 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift @@ -12,33 +12,11 @@ import SnapKit final class ChallengeDayCheckCollectionViewCollectionViewCell: UICollectionViewCell, CollectionViewCellRegisterDequeueProtocol { - var inputData: DummyModel? + private let countLabel = LHLabel(type: .body2M, color: .gray700, alignment: .center) + private let lineView = LHUnderLine(lineColor: .gray900) - var inputString: String? { - didSet { - countLabel.text = inputString - } - } - - var whiteTextColor: UIColor? { - didSet { - countLabel.textColor = whiteTextColor - } - } - - private let countLabel: UILabel = { - let label = UILabel() - label.textAlignment = .center - label.font = .pretendard(.body2M) - label.textColor = .designSystem(.gray700) - return label - }() - - private let lineView: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.gray900) - return view - }() + var inputString: String? + var whiteTextColor: UIColor? override init(frame: CGRect) { super.init(frame: frame) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index b3cd195c..eff0c2bf 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -19,13 +19,6 @@ final class ChallengeViewController: UIViewController { private var manager: ChallengeManager - private var inputData: ChallengeData? { - didSet { - guard let inputData else { return } - configureData(inputData) - } - } - private let leftSeperateLine = LHUnderLine(lineColor: .background) private let rightSeperateLine = LHUnderLine(lineColor: .background) private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) @@ -36,6 +29,13 @@ final class ChallengeViewController: UIViewController { private lazy var lottieImageView = LHLottie() private let challengeDayCheckCollectionView = LHCollectionView() + private var inputData: ChallengeData? { + didSet { + guard let inputData else { return } + configureData(inputData) + } + } + init(manager: ChallengeManager) { self.manager = manager super.init(nibName: nil, bundle: nil) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift index a518a357..39decd41 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekRowZeroTableViewCell.swift @@ -17,21 +17,10 @@ final class CurriculumArticleByWeekRowZeroTableViewCell: UITableViewCell, TableV private let curriculumLabel = LHLabel(type: .body2R, color: .lionRed, alignment: .center, basicText: "Curriculum") private let weekLabel = LHLabel(type: .head1, color: .white, alignment: .center) private let curriculumAndWeekStackView = LHStackView(axis: .vertical, spacing: 2) + private let weekBackGroundImageView = LHImageView(contentMode: .scaleAspectFill) - private let weekBackGroundImageView: UIImageView = { - let imageView = UIImageView() - imageView.backgroundColor = .designSystem(.gray500) - imageView.isUserInteractionEnabled = true - imageView.contentMode = .scaleAspectFill - return imageView - }() + private let blurblackView = LHView(color: .designSystem(.black)?.withAlphaComponent(0.4)) - private let blurblackView: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.black)?.withAlphaComponent(0.4) - return view - }() - var inputData: Int? { didSet { guard let inputData else { return } @@ -42,6 +31,7 @@ final class CurriculumArticleByWeekRowZeroTableViewCell: UITableViewCell, TableV override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) + setUI() setHierarchy() setLayout() setAddTarget() @@ -58,6 +48,11 @@ private extension CurriculumArticleByWeekRowZeroTableViewCell { enum Size { static let weekBackGroundImageSize: CGFloat = 200 / 375 } + + func setUI() { + weekBackGroundImageView.backgroundColor = .designSystem(.gray500) + weekBackGroundImageView.isUserInteractionEnabled = true + } func setHierarchy() { curriculumAndWeekStackView.addArrangedSubviews(curriculumLabel, weekLabel) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift index e550f954..66e760d6 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Curriculum/Cells/CurriculumArticleByWeekTableViewCell.swift @@ -30,16 +30,9 @@ final class CurriculumArticleByWeekTableViewCell: UITableViewCell, TableViewCell private lazy var bookMarkButton = LHToggleImageButton(normal: ImageLiterals.BookMark.inactiveBookmarkSmall, select: ImageLiterals.BookMark.activeBookmarkSmall) private let articleImageView = LHImageView(contentMode: .scaleToFill).makeRound(4).opacity(0.4) - - private let readTimeAndBookmarkView: UIView = { - let view = UIView() - view.layer.cornerRadius = 4 - view.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] - view.layer.masksToBounds = true - view.backgroundColor = .designSystem(.black) - view.layer.opacity = 0.6 - return view - }() + private let readTimeAndBookmarkView = LHView(color: .designSystem(.black)).makeRound(4).opacity(0.6) + .maskedCorners(corners: [.layerMinXMinYCorner, .layerMaxXMinYCorner]) + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/Cells/MyPageCustomerServiceCollectionViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/Cells/MyPageCustomerServiceCollectionViewCell.swift index c0bb1a4f..2c711fb8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/Cells/MyPageCustomerServiceCollectionViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/MyPage/Cells/MyPageCustomerServiceCollectionViewCell.swift @@ -12,28 +12,9 @@ import SnapKit final class MyPageCustomerServiceCollectionViewCell: UICollectionViewCell, CollectionViewCellRegisterDequeueProtocol { - private let listNameLabel = { - let label = UILabel() - label.font = .pretendard(.body2M) - label.textColor = .designSystem(.white) - return label - }() - - private lazy var nextButton = { - var configuration = UIButton.Configuration.plain() - configuration.image = ImageLiterals.Curriculum.arrowRightSmall - let button = UIButton(configuration: configuration) - button.addButtonAction { _ in - print("눌리냐") - } - return button - }() - - private let bottomView = { - let view = UIView() - view.backgroundColor = .designSystem(.gray800) - return view - }() + private let listNameLabel = LHLabel(type: .body2M, color: .white) + private lazy var nextButton = LHImageButton(setImage: ImageLiterals.Curriculum.arrowRightSmall) + private let bottomView = LHView(color: .designSystem(.gray800)) var inputData: MyPageLocalData? { didSet { @@ -43,11 +24,9 @@ final class MyPageCustomerServiceCollectionViewCell: UICollectionViewCell, Colle override init(frame: CGRect) { super.init(frame: frame) - setHierarchy() setLayout() setAddTarget() - setDelegate() } @available(*, unavailable) @@ -80,11 +59,9 @@ private extension MyPageCustomerServiceCollectionViewCell { } func setAddTarget() { - - } - - func setDelegate() { - + nextButton.addButtonAction { _ in + print("눌리냐") + } } func configureData(_ model: MyPageLocalData?) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift index 05c925e9..14be543d 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift @@ -18,6 +18,14 @@ final class TodayViewController: UIViewController { private let manager: TodayManager + private lazy var todayNavigationBar = LHNavigationBarView(type: .today, viewController: self) + private var titleLabel = LHTodayArticleTitle() + private var subTitleLable = LHTodayArticleTitle(initalizeString: "오늘의 아티클이에요") + private var mainArticleView = TodayArticleView() + private var pointImage = LHImageView(in: UIImage(named: "TodayArticle_PointImage"), contentMode: .scaleAspectFit) + + private var todayArticleID: Int? + init(manager: TodayManager) { self.manager = manager super.init(nibName: nil, bundle: nil) @@ -27,24 +35,6 @@ final class TodayViewController: UIViewController { fatalError("init(coder:) has not been implemented") } - enum TodayArticleImage { - static let ratio: CGFloat = 400/335 - } - - private var todayArticleID: Int? - - private lazy var todayNavigationBar = LHNavigationBarView(type: .today, viewController: self) - - private var titleLabel = LHTodayArticleTitle() - private var subTitleLable = LHTodayArticleTitle(initalizeString: "오늘의 아티클이에요") - private var mainArticleView = TodayArticleView() - - private var pointImage: UIImageView = { - let imageView = UIImageView(image: UIImage(named: "TodayArticle_PointImage")) - imageView.contentMode = .scaleAspectFit - return imageView - }() - public override func viewDidLoad() { super.viewDidLoad() setUI() @@ -75,7 +65,6 @@ extension TodayViewController { titleLabel.userNickName = responseArticle.fetalNickname mainArticleView.data = responseArticle todayArticleID = responseArticle.aticleID - // MARK: - 추후에 디팀에서 그라데이션있는 이미지로 받아오기로함 DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { self.hideLoading() } @@ -83,13 +72,15 @@ extension TodayViewController { guard let error = error as? NetworkError else { return } handleError(error) } - } } } -// MARK: - layout private extension TodayViewController { + enum TodayArticleImage { + static let ratio: CGFloat = 400/335 + } + func setUI() { view.backgroundColor = .designSystem(.black) } @@ -156,7 +147,6 @@ private extension TodayViewController { } } -// MARK: - 네트워킹 extension TodayViewController: ViewControllerServiceable { func handleError(_ error: NetworkError) { switch error { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/Views/TodayArticleView.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/Views/TodayArticleView.swift index 0a0a9333..cb5181a7 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/Views/TodayArticleView.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/Views/TodayArticleView.swift @@ -12,64 +12,20 @@ import SnapKit final class TodayArticleView: UIView { + private let backgroundView = LHView(color: .designSystem(.black)?.withAlphaComponent(0.2)).makeRound(4) + private var weekInfomationLabel = LHLabel(type: .body2R, color: .componentLionRed) + private var articleTitleLabel = LHLabel(type: .head2, color: .white, lines: 0) + private var descriptionLabel = LHLabel(type: .body2R, color: .gray400, lines: 3) + private var weekInfomationView = LHImageView(in: UIImage(named: "today_test_label"), contentMode: .scaleAspectFill) + var mainArticlImageView = LHImageView(contentMode: .scaleAspectFill).makeRound(4) + private var seperateLine = LHImageView(in: UIImage(named: "MainArticleSeperateLine"), contentMode: .scaleAspectFill) + var data: TodayArticle? { didSet { configureView(data: data) } } - private let backgroundView: UIView = { - let view = UIView() - view.backgroundColor = .designSystem(.black)?.withAlphaComponent(0.2) - view.layer.cornerRadius = 4 - view.clipsToBounds = true - return view - }() - - var mainArticlImageView: UIImageView = { - let imageView = UIImageView() - imageView.contentMode = .scaleAspectFill - imageView.layer.cornerRadius = 4 - imageView.clipsToBounds = true - return imageView - }() - - private var weekInfomationView: UIImageView = { - let imageView = UIImageView(image: UIImage(named: "today_test_label")) - imageView.contentMode = .scaleAspectFill - return imageView - }() - - private var weekInfomationLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2R) - label.textColor = .designSystem(.componentLionRed) - return label - }() - - private var articleTitleLabel: UILabel = { - let label = UILabel() - label.textColor = .designSystem(.white) - label.font = .pretendard(.head2) - label.numberOfLines = 0 - return label - }() - - private var seperateLine: UIImageView = { - let imageview = UIImageView(image: UIImage(named: "MainArticleSeperateLine")) - imageview.contentMode = .scaleAspectFill - return imageview - }() - - private var descriptionLabel: UILabel = { - let label = UILabel() - label.font = .pretendard(.body2R) - label.textColor = .designSystem(.gray400) - label.numberOfLines = 3 - return label - }() - - override init(frame: CGRect) { super.init(frame: frame) setHierarchy() @@ -79,11 +35,9 @@ final class TodayArticleView: UIView { override func draw(_ rect: CGRect) { super.draw(rect) mainArticlImageView.setGradient(firstColor: .designSystem(.black)!.withAlphaComponent(0.2), secondColor: .designSystem(.gray1000)!, axis: .vertical) - weekInfomationView.addSubview(weekInfomationLabel) - mainArticlImageView.addSubviews(descriptionLabel, seperateLine, articleTitleLabel, weekInfomationView) - + descriptionLabel.snp.makeConstraints { make in make.bottom.equalToSuperview().inset(36) make.leading.trailing.equalToSuperview().inset(20) @@ -128,7 +82,6 @@ private extension TodayArticleView { } func setLayout() { - mainArticlImageView.snp.makeConstraints { make in make.edges.equalToSuperview() } @@ -144,7 +97,6 @@ private extension TodayArticleView { descriptionLabel.text = data.articleDescription articleTitleLabel.setTextWithLineHeight(lineHeight: 32) descriptionLabel.setTextWithLineHeight(lineHeight: 24) - /// 얘도 text가 있을때 적용되는 녀석 descriptionLabel.lineBreakMode = .byTruncatingTail } } From 348c9f9b0daef0b6382f451fadc16161eb32480a Mon Sep 17 00:00:00 2001 From: kimscastle Date: Mon, 25 Sep 2023 11:35:16 +0900 Subject: [PATCH 39/39] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20LHLottie=20contentMo?= =?UTF-8?q?de=20default=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift | 2 +- .../ViewControllers/ArticleListByCategoryViewController.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift index 04c41e90..67b1122d 100644 --- a/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift +++ b/LionHeart-iOS/LionHeart-iOS/Global/UIComponents/LHLottie.swift @@ -11,7 +11,7 @@ import Lottie final class LHLottie: LottieAnimationView { init() { super.init(frame: .zero) - self.contentMode = .scaleToFill + self.contentMode = .scaleAspectFill } required init?(coder aDecoder: NSCoder) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift index 9772f05b..74622696 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift @@ -19,6 +19,7 @@ protocol ArticleListByCategoryManager { final class ArticleListByCategoryViewController: UIViewController { private let manager: ArticleListByCategoryManager + private lazy var navigationBar = LHNavigationBarView(type: .exploreEachCategory, viewController: self) private let articleListTableView = ArticleListTableView()