-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoginView.swift
More file actions
79 lines (72 loc) · 2.16 KB
/
Copy pathLoginView.swift
File metadata and controls
79 lines (72 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// LoginView.swift
// DevLogPresentation
//
// Created by opfic on 12/30/24.
//
import SwiftUI
import ComposableArchitecture
import DevLogDomain
struct LoginView: View {
@Environment(\.colorScheme) var colorScheme
@Environment(\.sceneWidth) var sceneWidth
@State private var store: StoreOf<LoginFeature>
init(signInUseCase: SignInUseCase) {
self._store = State(initialValue: Store(
initialState: LoginFeature.State()
) {
LoginFeature()
} withDependencies: {
$0.signInUseCase = signInUseCase
})
}
var body: some View {
VStack {
Spacer()
Image("Primary")
.resizable()
.scaledToFit()
.frame(width: sceneWidth / 5)
Spacer()
VStack(spacing: 20) {
signInButton(
provider: .google,
logo: Image("Google"),
text: String(localized: "login_google_sign_in")
)
signInButton(
provider: .github,
logo: Image("Github"),
text: String(localized: "login_github_sign_in")
)
signInButton(
provider: .apple,
logo: Image("Apple"),
text: String(localized: "login_apple_sign_in")
)
}
.padding(.bottom, 30)
Text(String(localized: "login_terms_notice"))
.font(.caption2)
.foregroundStyle(Color.gray)
.multilineTextAlignment(.center)
.padding(.vertical)
}
.alert($store.scope(state: \.alert, action: \.alert))
}
private func signInButton(
provider: AuthProvider,
logo: Image,
text: String
) -> some View {
LoginButton(
logo: logo,
text: text,
showsProgressView: store.activeSignInProvider == provider
) {
store.send(.tapSignInButton(provider))
}
.disabled(store.isLoading)
.opacity(store.isLoading ? 0.5 : 1)
}
}