metatext-app-ios-iphone-ipad/Views/SwiftUI/View Controller Representables/AddIdentityView.swift

48 lines
1.5 KiB
Swift
Raw Normal View History

// Copyright © 2020 Metabolist. All rights reserved.
2021-01-08 03:29:08 +01:00
import Kingfisher
import SwiftUI
2020-09-01 09:33:49 +02:00
import ViewModels
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-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
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-31 23:40:57 +02:00
#endif