2019-10-04 01:33:14 +00:00
|
|
|
//
|
|
|
|
// RegistrationView.swift
|
|
|
|
// Budget
|
|
|
|
//
|
|
|
|
// Created by Billy Brawner on 10/3/19.
|
|
|
|
// Copyright © 2019 William Brawner. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct RegistrationView: View {
|
2022-05-18 02:33:38 +00:00
|
|
|
@Binding var username: String
|
2019-10-04 01:33:14 +00:00
|
|
|
@State var email: String = ""
|
2022-05-18 02:33:38 +00:00
|
|
|
@Binding var password: String
|
2019-10-04 01:33:14 +00:00
|
|
|
@State var confirmedPassword: String = ""
|
2022-05-18 01:04:27 +00:00
|
|
|
@EnvironmentObject var dataStore: DataStore
|
2019-10-04 01:33:14 +00:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
VStack {
|
2022-05-18 02:33:38 +00:00
|
|
|
TextField(LocalizedStringKey("prompt_server"), text: self.$dataStore.baseUrl)
|
2022-01-03 17:56:43 +00:00
|
|
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
|
|
|
.textContentType(.URL)
|
2019-10-04 01:33:14 +00:00
|
|
|
TextField("prompt_username", text: self.$username)
|
|
|
|
.autocapitalization(UITextAutocapitalizationType.none)
|
|
|
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
|
|
|
.textContentType(UITextContentType.username)
|
|
|
|
TextField("prompt_email", text: self.$email)
|
|
|
|
.textContentType(UITextContentType.emailAddress)
|
|
|
|
.autocapitalization(UITextAutocapitalizationType.none)
|
|
|
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
|
|
|
SecureField("prompt_password", text: self.$password)
|
|
|
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
|
|
|
.textContentType(UITextContentType.newPassword)
|
|
|
|
SecureField("prompt_confirm_password", text: self.$confirmedPassword)
|
|
|
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
|
|
|
.textContentType(UITextContentType.newPassword)
|
2022-05-18 02:35:49 +00:00
|
|
|
.onSubmit {
|
|
|
|
Task {
|
|
|
|
await self.dataStore.register(
|
|
|
|
username: self.username,
|
|
|
|
email: self.email,
|
|
|
|
password: self.password,
|
|
|
|
confirmPassword: self.confirmedPassword
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2019-10-04 01:33:14 +00:00
|
|
|
Button("action_register", action: {
|
2022-01-03 17:56:43 +00:00
|
|
|
Task {
|
2022-05-18 01:04:27 +00:00
|
|
|
await self.dataStore.register(
|
2022-01-03 17:56:43 +00:00
|
|
|
username: self.username,
|
|
|
|
email: self.email,
|
|
|
|
password: self.password,
|
|
|
|
confirmPassword: self.confirmedPassword
|
|
|
|
)
|
|
|
|
}
|
2019-10-04 01:33:14 +00:00
|
|
|
}).buttonStyle(DefaultButtonStyle())
|
|
|
|
}.padding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//struct RegistrationView_Previews: PreviewProvider {
|
|
|
|
// static var previews: some View {
|
|
|
|
// RegistrationView()
|
|
|
|
// }
|
|
|
|
//}
|