This commit is contained in:
fmodf 2024-04-02 23:24:17 +04:00
parent 3c8f86d509
commit 4d35351474
5 changed files with 127 additions and 2 deletions

View file

@ -4,6 +4,9 @@ enum AppFlow: Codable {
case start
case welcome
case login
case registration
case contacts
case chats
case settings

View file

@ -14,6 +14,12 @@ struct BaseNavigationView: View {
case .welcome:
WelcomeScreen()
case .login:
LoginScreen()
case .registration:
RegistrationScreen()
case .contacts:
ContactsScreen()

View 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)
}
}

View 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()
}
}

View file

@ -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)
}