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-01-03 17:56:43 +00:00
|
|
|
@Binding var server: String
|
2019-10-04 01:33:14 +00:00
|
|
|
@State var username: String = ""
|
|
|
|
@State var email: String = ""
|
|
|
|
@State var password: String = ""
|
|
|
|
@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-01-03 17:56:43 +00:00
|
|
|
TextField(LocalizedStringKey("prompt_server"), text: self.$server)
|
|
|
|
.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)
|
|
|
|
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
|
|
|
server: self.server,
|
|
|
|
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()
|
|
|
|
// }
|
|
|
|
//}
|