metatext/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 02:29:08 +00:00
import Kingfisher
import SwiftUI
2020-09-01 07:33:49 +00:00
import ViewModels
2021-01-27 20:31:32 +00:00
struct AddIdentityView: UIViewControllerRepresentable {
let viewModelClosure: () -> AddIdentityViewModel
let displayWelcome: Bool
2021-01-28 03:58:23 +00:00
@EnvironmentObject var rootViewModel: RootViewModel
2021-01-27 20:31:32 +00:00
func makeUIViewController(context: Context) -> AddIdentityViewController {
2021-01-28 03:58:23 +00:00
AddIdentityViewController(viewModel: viewModelClosure(),
rootViewModel: rootViewModel,
displayWelcome: displayWelcome)
2021-01-27 20:31:32 +00:00
}
func updateUIViewController(_ uiViewController: AddIdentityViewController, context: Context) {
2020-09-12 07:36:59 +00:00
}
}
2020-09-10 00:52:46 +00:00
extension AddIdentityError: LocalizedError {
public var errorDescription: String? {
2021-01-17 20:24:50 +00: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 00:52:46 +00:00
}
}
2020-07-31 21:40:57 +00:00
#if DEBUG
2020-09-01 07:33:49 +00:00
import PreviewViewModels
struct AddAccountView_Previews: PreviewProvider {
static var previews: some View {
2020-09-11 09:55:06 +00:00
NavigationView {
2021-01-27 20:31:32 +00:00
AddIdentityView(viewModelClosure: { RootViewModel.preview.addIdentityViewModel() }, displayWelcome: false)
2020-09-11 09:55:06 +00:00
.navigationBarTitleDisplayMode(.inline)
2021-01-30 09:03:05 +00:00
.environmentObject(RootViewModel.preview)
2020-09-11 09:55:06 +00:00
}
}
}
2020-07-31 21:40:57 +00:00
#endif