2020-12-06 04:10:27 +01:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
2021-01-30 02:14:22 +01:00
|
|
|
import AVKit
|
2020-12-06 04:10:27 +01:00
|
|
|
import Combine
|
|
|
|
import ServiceLayer
|
2021-01-01 01:49:59 +01:00
|
|
|
import SwiftUI
|
2020-12-06 04:10:27 +01:00
|
|
|
import ViewModels
|
|
|
|
|
|
|
|
@objc(ShareExtensionNavigationViewController)
|
|
|
|
class ShareExtensionNavigationViewController: UINavigationController {
|
2021-01-30 02:14:22 +01:00
|
|
|
private let environment = AppEnvironment.live(
|
|
|
|
userNotificationCenter: .current(),
|
2021-03-06 03:25:18 +01:00
|
|
|
reduceMotion: { UIAccessibility.isReduceMotionEnabled },
|
|
|
|
autoplayVideos: { UIAccessibility.isVideoAutoplayEnabled })
|
2021-01-17 08:14:17 +01:00
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
2020-12-06 04:10:27 +01:00
|
|
|
|
2021-01-30 02:14:22 +01:00
|
|
|
try? AVAudioSession.sharedInstance().setCategory(.ambient, mode: .default)
|
|
|
|
try? ImageCacheConfiguration(environment: environment).configure()
|
|
|
|
|
|
|
|
let viewModel = ShareExtensionNavigationViewModel(environment: environment)
|
2020-12-10 03:44:06 +01:00
|
|
|
let newStatusViewModel: NewStatusViewModel
|
2020-12-06 04:10:27 +01:00
|
|
|
|
|
|
|
do {
|
2021-01-17 08:14:17 +01:00
|
|
|
newStatusViewModel = try viewModel.newStatusViewModel(extensionContext: extensionContext)
|
2020-12-06 04:10:27 +01:00
|
|
|
} catch {
|
|
|
|
setViewControllers([ShareErrorViewController(error: error)], animated: false)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-10 03:44:06 +01:00
|
|
|
setViewControllers(
|
2021-02-04 22:33:29 +01:00
|
|
|
[NewStatusViewController(viewModel: newStatusViewModel, rootViewModel: nil)],
|
2020-12-10 03:44:06 +01:00
|
|
|
animated: false)
|
2020-12-06 04:10:27 +01:00
|
|
|
}
|
|
|
|
}
|