88import UIKit
99import Combine
1010import Domain
11+ import Shared
1112
1213final class OnboardingRecommendedRoutineView : BaseViewController < OnboardingViewModel > {
1314
@@ -20,7 +21,9 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
2021 static let routineStackViewTopSpacing : CGFloat = 28
2122 static let routineButtonHeight : CGFloat = 84
2223 static let registerButtonHeight : CGFloat = 54
23- static let registerButtonBottomSpacing : CGFloat = 20
24+ static let registerButtonBottomSpacing : CGFloat = 10
25+ static let skipButtonHeight : CGFloat = 54
26+ static let skipButtonBottomSpacing : CGFloat = 20
2427
2528 static var mainLabelTopSpacing : CGFloat {
2629 let height = UIScreen . main. bounds. height
@@ -34,6 +37,8 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
3437 private let recommendedRoutineStackView = UIStackView ( )
3538 private var recommendedRoutines : [ Int : OnboardingChoiceButton ] = [ : ]
3639 private let registerButton = PrimaryButton ( buttonState: . disabled, buttonTitle: " 등록하기 " )
40+ private let skipButtonLabel = UILabel ( )
41+ private let skipButton = UIButton ( )
3742 private var cancellables : Set < AnyCancellable >
3843
3944 override init ( viewModel: OnboardingViewModel ) {
@@ -82,6 +87,20 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
8287 registerButton. addAction ( UIAction { [ weak self] _ in
8388 self ? . viewModel. action ( input: . registerRecommendedRoutine)
8489 } , for: . touchUpInside)
90+
91+ skipButtonLabel. do {
92+ $0. attributedText = BitnagilFont (
93+ fontSize: 14 ,
94+ lineHeight: 20 ,
95+ underline: true ,
96+ weight: . regular
97+ ) . attributedString ( text: " 건너뛰기 " )
98+ $0. textColor = BitnagilColor . navy500
99+ }
100+
101+ skipButton. addAction ( UIAction { [ weak self] _ in
102+ self ? . goToHomeView ( )
103+ } , for: . touchUpInside)
85104 }
86105
87106 override func configureLayout( ) {
@@ -92,6 +111,8 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
92111 view. addSubview ( subLabel)
93112 view. addSubview ( recommendedRoutineStackView)
94113 view. addSubview ( registerButton)
114+ skipButton. addSubview ( skipButtonLabel)
115+ view. addSubview ( skipButton)
95116
96117 mainLabel. snp. makeConstraints { make in
97118 make. leading. equalTo ( safeArea) . offset ( Layout . horizontalMargin)
@@ -116,9 +137,20 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
116137 registerButton. snp. makeConstraints { make in
117138 make. leading. equalTo ( safeArea) . offset ( Layout . horizontalMargin)
118139 make. trailing. equalTo ( safeArea) . inset ( Layout . horizontalMargin)
119- make. bottom. equalTo ( safeArea ) . inset ( Layout . registerButtonBottomSpacing)
140+ make. bottom. equalTo ( skipButton . snp . top ) . offset ( - Layout. registerButtonBottomSpacing)
120141 make. height. equalTo ( Layout . registerButtonHeight)
121142 }
143+
144+ skipButtonLabel. snp. makeConstraints { make in
145+ make. center. equalToSuperview ( )
146+ }
147+
148+ skipButton. snp. makeConstraints { make in
149+ make. leading. equalTo ( safeArea) . offset ( Layout . horizontalMargin)
150+ make. trailing. equalTo ( safeArea) . inset ( Layout . horizontalMargin)
151+ make. bottom. equalTo ( safeArea) . inset ( Layout . skipButtonBottomSpacing)
152+ make. height. equalTo ( Layout . skipButtonHeight)
153+ }
122154 }
123155
124156 override func bind( ) {
@@ -142,6 +174,18 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
142174 self ? . registerButton. updateButtonState ( buttonState: canRegister ? . default : . disabled)
143175 }
144176 . store ( in: & cancellables)
177+
178+ viewModel. output. registerRoutineResultPublisher
179+ . receive ( on: DispatchQueue . main)
180+ . sink { [ weak self] registerResult in
181+ if registerResult {
182+ BitnagilLogger . log ( logType: . debug, message: " 추천 루틴 등록 완료 " )
183+ self ? . goToHomeView ( )
184+ } else {
185+ BitnagilLogger . log ( logType: . error, message: " 추천 루틴 등록 실패 " )
186+ }
187+ }
188+ . store ( in: & cancellables)
145189 }
146190
147191 private func updateRecommendedRoutines( routines: Set < RecommendedRoutine > ) {
@@ -176,4 +220,12 @@ final class OnboardingRecommendedRoutineView: BaseViewController<OnboardingViewM
176220 }
177221 }
178222 }
223+
224+ private func goToHomeView( ) {
225+ guard let homeViewModel = DIContainer . shared. resolve ( type: HomeViewModel . self) else {
226+ fatalError ( " homeViewModel 의존성이 등록되지 않았습니다. " )
227+ }
228+ let homeView = HomeViewController ( viewModel: homeViewModel)
229+ self . navigationController? . pushViewController ( homeView, animated: true )
230+ }
179231}
0 commit comments