2020-07-30 01:50:30 +02:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct AddIdentityView: View {
|
|
|
|
@StateObject var viewModel: AddIdentityViewModel
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Form {
|
2020-08-03 07:54:47 +02:00
|
|
|
Spacer()
|
2020-07-30 01:50:30 +02:00
|
|
|
#if os(iOS)
|
|
|
|
urlTextField
|
|
|
|
.autocapitalization(.none)
|
|
|
|
.disableAutocorrection(true)
|
|
|
|
.keyboardType(.URL)
|
|
|
|
#else
|
|
|
|
urlTextField
|
|
|
|
#endif
|
|
|
|
Group {
|
|
|
|
if viewModel.loading {
|
|
|
|
ProgressView()
|
|
|
|
} else {
|
|
|
|
Button(
|
|
|
|
action: viewModel.goTapped,
|
|
|
|
label: { Text("go") })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
2020-08-03 07:54:47 +02:00
|
|
|
Spacer()
|
2020-07-30 01:50:30 +02:00
|
|
|
}
|
2020-08-03 07:54:47 +02:00
|
|
|
.padding()
|
2020-07-30 01:50:30 +02:00
|
|
|
.alertItem($viewModel.alertItem)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension AddIdentityView {
|
|
|
|
private var urlTextField: some View {
|
|
|
|
TextField("add-identity.instance-url", text: $viewModel.urlFieldText)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-31 23:40:57 +02:00
|
|
|
#if DEBUG
|
2020-07-30 01:50:30 +02:00
|
|
|
struct AddAccountView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
AddIdentityView(viewModel: AddIdentityViewModel(
|
2020-07-31 23:40:57 +02:00
|
|
|
networkClient: MastodonClient.development,
|
2020-08-03 00:23:01 +02:00
|
|
|
environment: .development))
|
2020-07-30 01:50:30 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-31 23:40:57 +02:00
|
|
|
#endif
|