1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-28 10:40:32 +01:00
metatext-app-ios-iphone-ipad/Views/SwiftUI/View Controller Representables/AddIdentityView.swift
2021-02-22 15:59:33 -08:00

47 lines
1.4 KiB
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
import ViewModels
struct AddIdentityView: UIViewControllerRepresentable {
let viewModelClosure: () -> AddIdentityViewModel
let displayWelcome: Bool
@EnvironmentObject var rootViewModel: RootViewModel
func makeUIViewController(context: Context) -> AddIdentityViewController {
AddIdentityViewController(viewModel: viewModelClosure(),
rootViewModel: rootViewModel,
displayWelcome: displayWelcome)
}
func updateUIViewController(_ uiViewController: AddIdentityViewController, context: Context) {
}
}
extension AddIdentityError: LocalizedError {
public var errorDescription: String? {
switch self {
case .unableToConnectToInstance:
return NSLocalizedString("add-identity.unable-to-connect-to-instance", comment: "")
case .instanceNotSupported:
return NSLocalizedString("add-identity.instance-not-supported", comment: "")
}
}
}
#if DEBUG
import PreviewViewModels
struct AddAccountView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
AddIdentityView(viewModelClosure: { RootViewModel.preview.addIdentityViewModel() }, displayWelcome: false)
.navigationBarTitleDisplayMode(.inline)
.environmentObject(RootViewModel.preview)
}
}
}
#endif