2020-07-30 01:50:30 +02:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import SwiftUI
|
2020-09-01 09:33:49 +02:00
|
|
|
import ViewModels
|
2020-07-30 01:50:30 +02:00
|
|
|
|
2021-01-27 21:31:32 +01:00
|
|
|
struct AddIdentityView: UIViewControllerRepresentable {
|
|
|
|
let viewModelClosure: () -> AddIdentityViewModel
|
|
|
|
let displayWelcome: Bool
|
2021-01-28 04:58:23 +01:00
|
|
|
@EnvironmentObject var rootViewModel: RootViewModel
|
2021-01-27 21:31:32 +01:00
|
|
|
|
|
|
|
func makeUIViewController(context: Context) -> AddIdentityViewController {
|
2021-01-28 04:58:23 +01:00
|
|
|
AddIdentityViewController(viewModel: viewModelClosure(),
|
|
|
|
rootViewModel: rootViewModel,
|
|
|
|
displayWelcome: displayWelcome)
|
2021-01-27 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func updateUIViewController(_ uiViewController: AddIdentityViewController, context: Context) {
|
2020-09-12 09:36:59 +02:00
|
|
|
|
2020-07-30 01:50:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-10 02:52:46 +02:00
|
|
|
extension AddIdentityError: LocalizedError {
|
|
|
|
public var errorDescription: String? {
|
2021-01-17 21:24:50 +01:00
|
|
|
switch self {
|
|
|
|
case .unableToConnectToInstance:
|
|
|
|
return NSLocalizedString("add-identity.unable-to-connect-to-instance", comment: "")
|
|
|
|
case .instanceNotSupported:
|
|
|
|
return NSLocalizedString("add-identity.instance-not-supported", comment: "")
|
|
|
|
}
|
|
|
|
|
2020-09-10 02:52:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-31 23:40:57 +02:00
|
|
|
#if DEBUG
|
2020-09-01 09:33:49 +02:00
|
|
|
import PreviewViewModels
|
|
|
|
|
2020-07-30 01:50:30 +02:00
|
|
|
struct AddAccountView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2020-09-11 11:55:06 +02:00
|
|
|
NavigationView {
|
2021-01-27 21:31:32 +01:00
|
|
|
AddIdentityView(viewModelClosure: { RootViewModel.preview.addIdentityViewModel() }, displayWelcome: false)
|
2020-09-11 11:55:06 +02:00
|
|
|
.navigationBarTitleDisplayMode(.inline)
|
2021-01-30 10:03:05 +01:00
|
|
|
.environmentObject(RootViewModel.preview)
|
2020-09-11 11:55:06 +02:00
|
|
|
}
|
2020-07-30 01:50:30 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-31 23:40:57 +02:00
|
|
|
#endif
|