generated from baekteun/Tuist_Modular_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
484 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Projects/Feature/BaseFeature/Sources/EnvironmentValues/RootPresentationMode.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import SwiftUI | ||
|
||
public struct RootPresentationModeKey: EnvironmentKey { | ||
public static let defaultValue: Binding<RootPresentationMode> = .constant(RootPresentationMode()) | ||
} | ||
|
||
public extension EnvironmentValues { | ||
var rootPresentationMode: Binding<RootPresentationMode> { | ||
get { return self[RootPresentationModeKey.self] } | ||
set { self[RootPresentationModeKey.self] = newValue } | ||
} | ||
} | ||
|
||
public typealias RootPresentationMode = Bool | ||
|
||
public extension Binding<RootPresentationMode> { | ||
func popToRootView() { | ||
self.wrappedValue.toggle() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Projects/Feature/FindPasswordFeature/Interface/InputEmailFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import SwiftUI | ||
|
||
public protocol InputEmailFactory { | ||
associatedtype SomeView: View | ||
func makeView() -> SomeView | ||
} |
6 changes: 6 additions & 0 deletions
6
Projects/Feature/FindPasswordFeature/Interface/InputNewPasswordFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import SwiftUI | ||
|
||
public protocol InputNewPasswordFactory { | ||
associatedtype SomeView: View | ||
func makeView() -> SomeView | ||
} |
6 changes: 6 additions & 0 deletions
6
Projects/Feature/FindPasswordFeature/Interface/VerifyAuthCodeFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import SwiftUI | ||
|
||
public protocol VerifyAuthCodeFactory { | ||
associatedtype SomeView: View | ||
func makeView() -> SomeView | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import DependencyPlugin | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
|
||
let project = Project.module( | ||
name: ModulePaths.Feature.FindPasswordFeature.rawValue, | ||
targets: [ | ||
.interface(module: .feature(.FindPasswordFeature)), | ||
.implements(module: .feature(.FindPasswordFeature), dependencies: [ | ||
.feature(target: .FindPasswordFeature, type: .interface), | ||
.feature(target: .BaseFeature) | ||
]), | ||
.tests(module: .feature(.FindPasswordFeature), dependencies: [ | ||
.feature(target: .FindPasswordFeature) | ||
]) | ||
] | ||
) |
16 changes: 16 additions & 0 deletions
16
Projects/Feature/FindPasswordFeature/Sources/Email/InputEmailComponent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import SwiftUI | ||
import NeedleFoundation | ||
import FindPasswordFeatureInterface | ||
|
||
public protocol InputEmailDependency: Dependency { | ||
var verifyAuthCodeFactory: any VerifyAuthCodeFactory { get } | ||
} | ||
|
||
public final class InputEmailComponent: Component<InputEmailDependency>, InputEmailFactory { | ||
public func makeView() -> some View { | ||
InputEmailView( | ||
viewModel: .init(), | ||
verifyAuthCodeFactory: dependency.verifyAuthCodeFactory | ||
) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Projects/Feature/FindPasswordFeature/Sources/Email/InputEmailViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import BaseFeature | ||
import Combine | ||
|
||
final class InputEmailViewModel: BaseViewModel { | ||
@Published var email: String = "" | ||
|
||
@Published var isNavigatedToVerifyAuthCode: Bool = false | ||
|
||
func nextButtonDidTap() { | ||
self.isNavigatedToVerifyAuthCode = true | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Projects/Feature/FindPasswordFeature/Sources/Email/InputSignupEmailView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import DesignSystem | ||
import SwiftUI | ||
import BaseFeature | ||
import ViewUtil | ||
import FindPasswordFeatureInterface | ||
|
||
struct InputEmailView: View { | ||
private enum FocusField { | ||
case email | ||
} | ||
@FocusState private var focusField: FocusField? | ||
@StateObject var viewModel: InputEmailViewModel | ||
@Environment(\.rootPresentationMode) var rootPresentationMode | ||
|
||
private let verifyAuthCodeFactory: any VerifyAuthCodeFactory | ||
|
||
init( | ||
viewModel: InputEmailViewModel, | ||
verifyAuthCodeFactory: any VerifyAuthCodeFactory | ||
) { | ||
_viewModel = StateObject(wrappedValue: viewModel) | ||
self.verifyAuthCodeFactory = verifyAuthCodeFactory | ||
} | ||
|
||
var body: some View { | ||
VStack(spacing: 0) { | ||
NavigationTitleView( | ||
title: "이메일을 입력해 주세요", | ||
description: "이메일로 인증번호를 전송해 드릴게요" | ||
) | ||
|
||
KGTextField( | ||
"이메일을 입력해주세요", | ||
text: $viewModel.email, | ||
title: "이메일", | ||
isError: viewModel.isErrorOccurred, | ||
errorMessage: viewModel.errorMessage, | ||
onCommit: viewModel.nextButtonDidTap | ||
) | ||
.textContentType(.emailAddress) | ||
.keyboardType(.emailAddress) | ||
.focused($focusField, equals: .email) | ||
|
||
Spacer() | ||
} | ||
.bottomButton( | ||
text: "다음", | ||
isEditing: focusField != nil, | ||
isDisabled: viewModel.email.isEmpty, | ||
action: viewModel.nextButtonDidTap | ||
) | ||
.navigationBackButton() | ||
.kgBackground() | ||
.hideKeyboardWhenTap() | ||
.navigate( | ||
to: verifyAuthCodeFactory.makeView().eraseToAnyView() | ||
.environment(\.rootPresentationMode, rootPresentationMode), | ||
when: $viewModel.isNavigatedToVerifyAuthCode | ||
) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Projects/Feature/FindPasswordFeature/Sources/NewPassword/InputNewPasswordComponent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import SwiftUI | ||
import NeedleFoundation | ||
import FindPasswordFeatureInterface | ||
|
||
public protocol InputNewPasswordDependency: Dependency {} | ||
|
||
public final class InputNewPasswordComponent: Component<InputNewPasswordDependency>, InputNewPasswordFactory { | ||
public func makeView() -> some View { | ||
InputNewPasswordView( | ||
viewModel: .init() | ||
) | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
Projects/Feature/FindPasswordFeature/Sources/NewPassword/InputNewPasswordView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import DesignSystem | ||
import SwiftUI | ||
import BaseFeature | ||
import SignupFeatureInterface | ||
import ViewUtil | ||
|
||
struct InputNewPasswordView: View { | ||
private enum FocusField { | ||
case password | ||
case checkPassword | ||
} | ||
@FocusState private var focusField: FocusField? | ||
@StateObject var viewModel: InputNewPasswordViewModel | ||
@Environment(\.rootPresentationMode) var rootPresentationMode | ||
|
||
init( | ||
viewModel: InputNewPasswordViewModel | ||
) { | ||
_viewModel = StateObject(wrappedValue: viewModel) | ||
} | ||
|
||
var body: some View { | ||
VStack(spacing: 0) { | ||
NavigationTitleView( | ||
title: "새 비밀번호를 입력해주세요", | ||
description: "비밀번호는 영어와 숫자를 조합해 만들어 주세요" | ||
) | ||
|
||
KGTextField( | ||
"비밀번호(8~12자)를 입력해 주세요", | ||
text: $viewModel.password, | ||
title: "비밀번호", | ||
isError: viewModel.isErrorOccurred, | ||
errorMessage: viewModel.errorMessage, | ||
isSecure: true | ||
) { | ||
self.focusField = .checkPassword | ||
} | ||
.textContentType(.password) | ||
.focused($focusField, equals: .password) | ||
|
||
KGTextField( | ||
"비밀번호 다시 입력해 주세요", | ||
text: $viewModel.checkPassword, | ||
title: "비밀번호 확인", | ||
isError: viewModel.isErrorOccurred, | ||
errorMessage: viewModel.errorMessage, | ||
isSecure: true, | ||
onCommit: viewModel.nextButtonDidTap | ||
) | ||
.textContentType(.password) | ||
.focused($focusField, equals: .checkPassword) | ||
|
||
Spacer() | ||
} | ||
.bottomButton( | ||
text: "다음", | ||
isEditing: focusField != nil, | ||
isDisabled: viewModel.password.isEmpty || viewModel.checkPassword.isEmpty, | ||
action: viewModel.nextButtonDidTap | ||
) | ||
.navigationBar() | ||
.kgBackground() | ||
.hideKeyboardWhenTap() | ||
.onSuccess(of: viewModel.isSuccessToChangePassword) { | ||
DispatchQueue.main.async { | ||
self.rootPresentationMode.popToRootView() | ||
} | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Projects/Feature/FindPasswordFeature/Sources/NewPassword/InputNewPasswordViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import BaseFeature | ||
import Combine | ||
|
||
final class InputNewPasswordViewModel: BaseViewModel { | ||
@Published var password: String = "" | ||
@Published var checkPassword: String = "" | ||
|
||
@Published var isSuccessToChangePassword: Bool = false | ||
|
||
func nextButtonDidTap() { | ||
self.isSuccessToChangePassword = true | ||
} | ||
} |
Oops, something went wrong.