From a24d0a9fe70a0220d38b9cbc4466e900581b5e3e Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Mon, 8 Jan 2024 16:37:18 +0900 Subject: [PATCH] =?UTF-8?q?[Fix/#28]=20Onboarding=20-=20baseViewController?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 18 ++++- .../OnboardingBaseViewController.swift | 8 -- .../OnboardingBaseViewControllers.swift | 80 +++++++++++++++++++ .../Onboarding/Views/OnboardingButton.swift | 68 +++++++++++++++- 4 files changed, 163 insertions(+), 11 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewController.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index b3405c2..b3f1604 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 0B50F9CF2B369813000C5046 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CE2B369813000C5046 /* HomeViewController.swift */; }; 0B50F9D42B369815000C5046 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0B50F9D32B369815000C5046 /* Assets.xcassets */; }; 0B50F9D72B369815000C5046 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0B50F9D52B369815000C5046 /* LaunchScreen.storyboard */; }; + 0B78174E2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B78174D2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift */; }; + 0B7817502B4BD9F10078E925 /* OnboardingButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B78174F2B4BD9F10078E925 /* OnboardingButton.swift */; }; 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */; }; 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */; }; 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B02B369E4C00688BA6 /* HomeView.swift */; }; @@ -131,7 +133,6 @@ /* Begin PBXFileReference section */ 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; - 0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingButton.swift; sourceTree = ""; }; 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = ""; }; 0B50F9C72B369813000C5046 /* HMH_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMH_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0B50F9CA2B369813000C5046 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -140,6 +141,8 @@ 0B50F9D32B369815000C5046 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 0B50F9D62B369815000C5046 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 0B50F9D82B369815000C5046 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0B78174D2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingBaseViewControllers.swift; sourceTree = ""; }; + 0B78174F2B4BD9F10078E925 /* OnboardingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingButton.swift; sourceTree = ""; }; 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCell.swift; sourceTree = ""; }; 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeModel.swift; sourceTree = ""; }; 0B8A89B02B369E4C00688BA6 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; @@ -245,6 +248,7 @@ 0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = { isa = PBXGroup; children = ( + 0B78174C2B4BD9450078E925 /* ViewControllers */, 0B2C2D3D2B4559C90023CCFA /* Views */, ); path = Onboarding; @@ -253,9 +257,9 @@ 0B2C2D3D2B4559C90023CCFA /* Views */ = { isa = PBXGroup; children = ( - 0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */, 0BC0EBD32B494459003EF5D4 /* OnboardingSwipeView.swift */, 0BC0EBD12B493B6B003EF5D4 /* OnboardingProgressView.swift */, + 0B78174F2B4BD9F10078E925 /* OnboardingButton.swift */, ); path = Views; sourceTree = ""; @@ -339,6 +343,14 @@ path = Presentation; sourceTree = ""; }; + 0B78174C2B4BD9450078E925 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 0B78174D2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift */, + ); + path = ViewControllers; + sourceTree = ""; + }; 0B8A89952B369CD900688BA6 /* Extension */ = { isa = PBXGroup; children = ( @@ -875,9 +887,11 @@ 0B8A89B52B369F0100688BA6 /* B.swift in Sources */, 174AF49C2B447D0700450D07 /* ChanllengeViewController.swift in Sources */, 17314F892B49A8B60089A551 /* AlertDelegate.swift in Sources */, + 0B78174E2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift in Sources */, 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */, 36A3D9B62B3EBBF7007EA272 /* Adjust+.swift in Sources */, 36A3D9BC2B3EBD2D007EA272 /* UIScreen+.swift in Sources */, + 0B7817502B4BD9F10078E925 /* OnboardingButton.swift in Sources */, 0B50F9CD2B369813000C5046 /* SceneDelegate.swift in Sources */, 36A3D9B42B3EBBED007EA272 /* UIStackView+.swift in Sources */, 174AF4962B447CE700450D07 /* ChanllengeCells.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewController.swift deleted file mode 100644 index 8d4b52d..0000000 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewController.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// OnboardingBaseViewController.swift -// HMH_iOS -// -// Created by Seonwoo Kim on 1/8/24. -// - -import Foundation diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift new file mode 100644 index 0000000..bccb845 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift @@ -0,0 +1,80 @@ +// +// OnboardingBaseViewController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/8/24. +// + +import UIKit + +import SnapKit +import Then + +protocol HomeViewPushDelegate: AnyObject { + func didTapButton() +} + +class OnboardingBaseViewController: UIViewController { + weak var delegate: HomeViewPushDelegate? + + let navigationBar = HMHNavigationBar(leftItem: .normal, isBackButton: true, isTitleLabel: false, isPointImage: false) + let progressBar = OnboardingProgressView(progressAmount: 2) + private let nextButton = OnboardingButton(buttonStatus: .enabled, buttonText: "완료") + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false + self.navigationController?.navigationBar.isHidden = true + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + progressBar.setProgressBar() + } + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + setTarget() + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + func setHierarchy() { + view.addSubviews(navigationBar, progressBar, nextButton) + } + func setConstraints() { + navigationBar.snp.makeConstraints { + $0.top.trailing.leading.equalToSuperview() + $0.height.equalTo(113) + } + + progressBar.snp.makeConstraints { + $0.top.equalTo(navigationBar.snp.bottom) + $0.trailing.leading.equalToSuperview().inset(20) + } + + nextButton.snp.makeConstraints { + $0.bottom.equalTo(view.safeAreaLayoutGuide).offset(-21) + $0.leading.trailing.equalToSuperview().inset(20) + } + } + + func setTarget() { + nextButton.addTarget(self, action: #selector(onTapButton), for: .touchUpInside) + } + + @objc + func onTapButton() { + print("taptaptap") + self.delegate?.didTapButton() + } +} + + + + + diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift index abd2bf9..5be29d6 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift @@ -5,4 +5,70 @@ // Created by Seonwoo Kim on 1/8/24. // -import Foundation +import UIKit + +import SnapKit +import Then + +final class OnboardingButton: UIButton { + @frozen + enum OnboardingButtonType { + case enabled + case disabled + } + + private var type: OnboardingButtonType = .disabled + + private let buttonTitleLabel = UILabel().then { + $0.textColor = .whiteText + $0.font = .iosText4Semibold16 + } + + init(buttonStatus type: OnboardingButtonType, buttonText: String) { + super.init(frame: .zero) + self.type = type + buttonTitleLabel.text = buttonText + + configureButton() + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubview(buttonTitleLabel) + } + + private func setConstraints() { + self.snp.makeConstraints { + $0.height.equalTo(52.adjusted) + } + + buttonTitleLabel.snp.makeConstraints { + $0.center.equalToSuperview() + } + } + + private func configureButton() { + self.makeCornerRound(radius: 6.adjustedHeight) + self.layer.cornerCurve = .continuous + + switch type { + case .enabled: + self.isEnabled = true + self.backgroundColor = .bluePurpleButton + + case .disabled: + self.isEnabled = false + self.backgroundColor = .gray5 + } + } +} +