metatext/Share Extension/ShareExtensionNavigationViewController.swift

37 lines
1.1 KiB
Swift
Raw Normal View History

2020-12-06 03:10:27 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Combine
import ServiceLayer
2021-01-01 00:49:59 +00:00
import SwiftUI
2020-12-06 03:10:27 +00:00
import ViewModels
@objc(ShareExtensionNavigationViewController)
class ShareExtensionNavigationViewController: UINavigationController {
2020-12-10 02:44:06 +00:00
private let viewModel = ShareExtensionNavigationViewModel(
environment: .live(
userNotificationCenter: .current(),
reduceMotion: { UIAccessibility.isReduceMotionEnabled }))
2020-12-06 03:10:27 +00:00
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
2020-12-10 02:44:06 +00:00
let newStatusViewModel: NewStatusViewModel
2020-12-06 03:10:27 +00:00
do {
2020-12-10 02:44:06 +00:00
newStatusViewModel = try viewModel.newStatusViewModel()
2020-12-06 03:10:27 +00:00
} catch {
setViewControllers([ShareErrorViewController(error: error)], animated: false)
return
}
2020-12-10 02:44:06 +00:00
setViewControllers(
2021-01-01 00:49:59 +00:00
[UIHostingController(rootView: NewStatusView { newStatusViewModel })],
2020-12-10 02:44:06 +00:00
animated: false)
2020-12-06 03:10:27 +00:00
}
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}