mirror of
https://github.com/metabolist/metatext
synced 2024-12-26 09:42:48 +01:00
48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import SwiftUI
|
|
|
|
struct AddIdentityView: View {
|
|
@StateObject var viewModel: AddIdentityViewModel
|
|
|
|
var body: some View {
|
|
Form {
|
|
#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)
|
|
}
|
|
.alertItem($viewModel.alertItem)
|
|
}
|
|
}
|
|
|
|
extension AddIdentityView {
|
|
private var urlTextField: some View {
|
|
TextField("add-identity.instance-url", text: $viewModel.urlFieldText)
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct AddAccountView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
AddIdentityView(viewModel: AddIdentityViewModel(
|
|
networkClient: MastodonClient.development,
|
|
environment: .development))
|
|
}
|
|
}
|
|
#endif
|