wip
This commit is contained in:
parent
3c8f86d509
commit
4d35351474
|
@ -4,6 +4,9 @@ enum AppFlow: Codable {
|
|||
case start
|
||||
case welcome
|
||||
|
||||
case login
|
||||
case registration
|
||||
|
||||
case contacts
|
||||
case chats
|
||||
case settings
|
||||
|
|
|
@ -14,6 +14,12 @@ struct BaseNavigationView: View {
|
|||
case .welcome:
|
||||
WelcomeScreen()
|
||||
|
||||
case .login:
|
||||
LoginScreen()
|
||||
|
||||
case .registration:
|
||||
RegistrationScreen()
|
||||
|
||||
case .contacts:
|
||||
ContactsScreen()
|
||||
|
||||
|
|
96
Snikket/View/Screens/LoginScreen.swift
Normal file
96
Snikket/View/Screens/LoginScreen.swift
Normal file
|
@ -0,0 +1,96 @@
|
|||
import SwiftUI
|
||||
|
||||
struct LoginScreen: View {
|
||||
@EnvironmentObject var store: AppStore
|
||||
|
||||
enum Field {
|
||||
case userJid
|
||||
case password
|
||||
}
|
||||
|
||||
@FocusState private var focus: Field?
|
||||
|
||||
#if DEBUG
|
||||
@State private var jidStr: String = "testman_n1@conversations.im"
|
||||
@State private var pass: String = "testman123"
|
||||
#else
|
||||
@State private var jidStr: String = ""
|
||||
@State private var pass: String = ""
|
||||
#endif
|
||||
|
||||
public var body: some View {
|
||||
ZStack {
|
||||
// background
|
||||
Color.Main.backgroundLight
|
||||
.ignoresSafeArea()
|
||||
|
||||
// content
|
||||
VStack(spacing: 32) {
|
||||
// icon
|
||||
Image.logo
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 120, height: 120)
|
||||
|
||||
// texts
|
||||
VStack(spacing: 10) {
|
||||
Text(L10n.Login.title)
|
||||
.font(.head1l)
|
||||
.foregroundColor(.Tango.blueMedium)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
Text(L10n.Login.subtitle)
|
||||
.font(.body2)
|
||||
.foregroundColor(.Tango.blueLight)
|
||||
.multilineTextAlignment(.center)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
|
||||
VStack(spacing: 16) {
|
||||
UniversalInputCollection.TextField(
|
||||
prompt: L10n.Login.Hint.jid,
|
||||
text: $jidStr,
|
||||
focus: $focus,
|
||||
fieldType: .userJid,
|
||||
contentType: .emailAddress,
|
||||
keyboardType: .emailAddress,
|
||||
submitLabel: .next,
|
||||
action: {
|
||||
focus = .password
|
||||
}
|
||||
)
|
||||
UniversalInputCollection.SecureField(
|
||||
prompt: L10n.Login.Hint.password,
|
||||
text: $pass,
|
||||
focus: $focus,
|
||||
fieldType: .password,
|
||||
submitLabel: .go,
|
||||
action: {
|
||||
focus = nil
|
||||
}
|
||||
)
|
||||
|
||||
Button {
|
||||
// store.dispatch(.onboardAction(.tryLogin(jidStr, pass)))
|
||||
} label: {
|
||||
Text(L10n.Login.btn)
|
||||
}
|
||||
.buttonStyle(PrimaryButtonStyle())
|
||||
.disabled(!loginInputValid)
|
||||
|
||||
Button {
|
||||
store.dispatch(.changeFlow(.welcome))
|
||||
} label: {
|
||||
Text("\(Image(systemName: "chevron.left")) \(L10n.Global.back)")
|
||||
.foregroundColor(.Tango.blueLight)
|
||||
.font(.body2)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 32)
|
||||
}
|
||||
}
|
||||
|
||||
private var loginInputValid: Bool {
|
||||
!jidStr.isEmpty && !pass.isEmpty && UniversalInputCollection.Validators.isEmail(jidStr)
|
||||
}
|
||||
}
|
20
Snikket/View/Screens/RegistrationScreen.swift
Normal file
20
Snikket/View/Screens/RegistrationScreen.swift
Normal file
|
@ -0,0 +1,20 @@
|
|||
import SwiftUI
|
||||
|
||||
struct RegistrationScreen: View {
|
||||
@EnvironmentObject var store: AppStore
|
||||
|
||||
public var body: some View {
|
||||
ZStack {
|
||||
Color.Main.backgroundLight
|
||||
Button {
|
||||
store.dispatch(.changeFlow(.welcome))
|
||||
} label: {
|
||||
VStack {
|
||||
Text("Not yet implemented")
|
||||
Text(L10n.Global.back)
|
||||
}
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
}
|
|
@ -33,13 +33,13 @@ struct WelcomeScreen: View {
|
|||
// buttons
|
||||
VStack(spacing: 16) {
|
||||
Button {
|
||||
// store.dispatch(.onboardAction(.changeStep(.loginWithExistingAccount)))
|
||||
store.dispatch(.changeFlow(.login))
|
||||
} label: {
|
||||
Text(L10n.Start.Btn.login)
|
||||
}
|
||||
.buttonStyle(SecondaryButtonStyle())
|
||||
Button {
|
||||
// store.dispatch(.onboardAction(.changeStep(.registerNewAccount)))
|
||||
store.dispatch(.changeFlow(.registration))
|
||||
} label: {
|
||||
Text(L10n.Start.Btn.register)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue