-
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.
Merge pull request #70 from team-aliens/42-signin-feature
merge :: 로그인 Feature
- Loading branch information
Showing
24 changed files
with
446 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import SwiftUI | ||
import DesignSystem | ||
import SigninFeature | ||
|
||
@main | ||
struct DMSApp: App { | ||
init() { | ||
registerProviderFactories() | ||
} | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
DesignSystemPlaygroundView() | ||
NavigationView { | ||
AppComponent().signinComponent.makeView() | ||
} | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
Projects/Features/SigninFeature/Derived/InfoPlists/SigninFeature-Info.plist
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
22 changes: 22 additions & 0 deletions
22
Projects/Features/SigninFeature/Derived/InfoPlists/SigninFeatureTests-Info.plist
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
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,10 @@ | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
|
||
let project = Project.makeModule( | ||
name: "SigninFeature", | ||
product: .staticFramework, | ||
dependencies: [ | ||
.Project.Features.BaseFeature | ||
] | ||
) |
17 changes: 17 additions & 0 deletions
17
Projects/Features/SigninFeature/Sources/SigninComponent.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,17 @@ | ||
import DomainModule | ||
import NeedleFoundation | ||
import SwiftUI | ||
|
||
public protocol SigninDependency: Dependency { | ||
var signinUseCase: any SigninUseCase { get } | ||
} | ||
|
||
public final class SigninComponent: Component<SigninDependency> { | ||
public func makeView() -> some View { | ||
SigninView( | ||
viewModel: .init( | ||
signinUseCase: dependency.signinUseCase | ||
) | ||
) | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
Projects/Features/SigninFeature/Sources/SigninView.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,117 @@ | ||
import SwiftUI | ||
import DesignSystem | ||
|
||
struct SigninView: View { | ||
private enum FocusField { | ||
case id | ||
case password | ||
} | ||
@StateObject var viewModel: SigninViewModel | ||
@FocusState private var focusField: FocusField? | ||
|
||
public init(viewModel: SigninViewModel) { | ||
_viewModel = StateObject(wrappedValue: viewModel) | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
HStack { | ||
VStack(alignment: .leading, spacing: 8) { | ||
Text("DMS") | ||
.dmsFont(.title(.extraLarge), color: .PrimaryVariant.primary) | ||
.padding(.top, 28) | ||
|
||
Text("더 편한 기숙사 생활을 위해") | ||
.dmsFont(.text(.medium), color: .GrayScale.gray6) | ||
} | ||
|
||
Spacer() | ||
} | ||
|
||
VStack(spacing: 72) { | ||
DMSFloatingTextField( | ||
"아이디", | ||
text: $viewModel.id, | ||
isError: viewModel.isErrorOcuured | ||
) { | ||
focusField = .password | ||
} | ||
.textContentType(.username) | ||
.focused($focusField, equals: .id) | ||
|
||
SecureDMSFloatingTextField("비밀번호", text: $viewModel.password) { | ||
viewModel.signinButtonDidTap() | ||
} | ||
.textContentType(.password) | ||
.focused($focusField, equals: .password) | ||
} | ||
.padding(.top, 68) | ||
|
||
HStack(spacing: 16) { | ||
HStack(spacing: 12) { | ||
DMSRadioButton(isOn: $viewModel.isOnAutoSignin) | ||
|
||
Text("자동로그인") | ||
.dmsFont(.text(.small), color: .GrayScale.gray6) | ||
} | ||
.onTapGesture { | ||
withAnimation { | ||
viewModel.isOnAutoSignin.toggle() | ||
} | ||
} | ||
|
||
Spacer() | ||
|
||
NavigationLink { | ||
Text("아이디 찾기") | ||
} label: { | ||
Text("아이디 찾기") | ||
.dmsFont(.text(.extraSmall), color: .GrayScale.gray5) | ||
} | ||
|
||
Divider() | ||
.foregroundColor(.GrayScale.gray5) | ||
.frame(height: 13) | ||
|
||
NavigationLink { | ||
Text("비밀번호 재설정") | ||
} label: { | ||
Text("비밀번호 재설정") | ||
.dmsFont(.text(.extraSmall), color: .GrayScale.gray5) | ||
} | ||
} | ||
.padding(.top, 16) | ||
|
||
Spacer() | ||
|
||
HStack(spacing: 16) { | ||
Text("아직 회원이 아니신가요?") | ||
.dmsFont(.text(.extraSmall), color: .GrayScale.gray5) | ||
|
||
DMSButton(text: "회원가입", style: .text, color: .GrayScale.gray6) { | ||
viewModel.isNavigateSignup.toggle() | ||
} | ||
} | ||
|
||
DMSWideButton(text: "로그인", color: .PrimaryVariant.primary) { | ||
viewModel.signinButtonDidTap() | ||
} | ||
.disabled(!viewModel.isSigninButtonEnabled) | ||
.padding(.top, 24) | ||
.frame(maxWidth: .infinity) | ||
.padding(.bottom, 40) | ||
} | ||
.dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) | ||
.frame(maxWidth: .infinity) | ||
.padding(.horizontal, 24) | ||
.dmsBackground() | ||
.navigate(to: Text("회원가입"), when: $viewModel.isNavigateSignup) | ||
.ignoresSafeArea(.keyboard, edges: .bottom) | ||
} | ||
} | ||
|
||
struct SigninView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Text("A") | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Projects/Features/SigninFeature/Sources/SigninViewModel.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,27 @@ | ||
import BaseFeature | ||
import Combine | ||
import DomainModule | ||
|
||
final class SigninViewModel: BaseViewModel { | ||
@Published var id = "" | ||
@Published var password = "" | ||
@Published var isOnAutoSignin = true | ||
@Published var isNavigateSignup = false | ||
@Published var isSuccessSignin = false | ||
var isSigninButtonEnabled: Bool { | ||
!id.isEmpty && !password.isEmpty | ||
} | ||
|
||
private let signinUseCase: any SigninUseCase | ||
|
||
public init(signinUseCase: any SigninUseCase) { | ||
self.signinUseCase = signinUseCase | ||
} | ||
|
||
func signinButtonDidTap() { | ||
guard isSigninButtonEnabled else { return } | ||
addCancellable(signinUseCase.execute(req: .init(accountID: id, password: password))) { [weak self] _ in | ||
self?.isSuccessSignin = true | ||
} | ||
} | ||
} |
Oops, something went wrong.