Skip to content

Commit

Permalink
[Fix/#28] Onboarding - baseViewController 파일 이슈 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-seonwoo committed Jan 8, 2024
1 parent 8725824 commit a24d0a9
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 11 deletions.
18 changes: 16 additions & 2 deletions HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -131,7 +133,6 @@
/* Begin PBXFileReference section */
0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = "<group>"; };
0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = "<group>"; };
0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingButton.swift; sourceTree = "<group>"; };
0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = "<group>"; };
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 = "<group>"; };
Expand All @@ -140,6 +141,8 @@
0B50F9D32B369815000C5046 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
0B50F9D62B369815000C5046 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
0B50F9D82B369815000C5046 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0B78174D2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingBaseViewControllers.swift; sourceTree = "<group>"; };
0B78174F2B4BD9F10078E925 /* OnboardingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingButton.swift; sourceTree = "<group>"; };
0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCell.swift; sourceTree = "<group>"; };
0B8A89AE2B369E4300688BA6 /* HomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeModel.swift; sourceTree = "<group>"; };
0B8A89B02B369E4C00688BA6 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -245,6 +248,7 @@
0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = {
isa = PBXGroup;
children = (
0B78174C2B4BD9450078E925 /* ViewControllers */,
0B2C2D3D2B4559C90023CCFA /* Views */,
);
path = Onboarding;
Expand All @@ -253,9 +257,9 @@
0B2C2D3D2B4559C90023CCFA /* Views */ = {
isa = PBXGroup;
children = (
0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */,
0BC0EBD32B494459003EF5D4 /* OnboardingSwipeView.swift */,
0BC0EBD12B493B6B003EF5D4 /* OnboardingProgressView.swift */,
0B78174F2B4BD9F10078E925 /* OnboardingButton.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -339,6 +343,14 @@
path = Presentation;
sourceTree = "<group>";
};
0B78174C2B4BD9450078E925 /* ViewControllers */ = {
isa = PBXGroup;
children = (
0B78174D2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
};
0B8A89952B369CD900688BA6 /* Extension */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -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 */,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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()
}
}





Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit a24d0a9

Please sign in to comment.