2022-11-09 03:14:40 +00:00
|
|
|
//
|
|
|
|
// Duckable+Root.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 11/7/22.
|
|
|
|
// Copyright © 2022 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import Duckable
|
|
|
|
|
|
|
|
@available(iOS 16.0, *)
|
|
|
|
extension DuckableContainerViewController: TuskerRootViewController {
|
2022-11-23 16:35:25 +00:00
|
|
|
func stateRestorationActivity() -> NSUserActivity? {
|
2022-11-28 20:21:05 +00:00
|
|
|
var activity = (child as? TuskerRootViewController)?.stateRestorationActivity()
|
|
|
|
if let compose = duckedViewController as? ComposeHostingController,
|
|
|
|
compose.draft.hasContent {
|
|
|
|
activity = UserActivityManager.addDuckedDraft(to: activity, draft: compose.draft)
|
|
|
|
}
|
|
|
|
return activity
|
2022-11-23 16:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func restoreActivity(_ activity: NSUserActivity) {
|
2022-11-28 20:21:05 +00:00
|
|
|
if let draft = UserActivityManager.getDraft(from: activity),
|
|
|
|
let account = UserActivityManager.getAccount(from: activity) {
|
|
|
|
let mastodonController = MastodonController.getForAccount(account)
|
|
|
|
let compose = ComposeHostingController(draft: draft, mastodonController: mastodonController)
|
|
|
|
_ = presentDuckable(compose, animated: false, isDucked: true)
|
|
|
|
}
|
2022-11-23 16:35:25 +00:00
|
|
|
(child as? TuskerRootViewController)?.restoreActivity(activity)
|
|
|
|
}
|
|
|
|
|
2022-11-09 03:14:40 +00:00
|
|
|
func presentCompose() {
|
|
|
|
(child as? TuskerRootViewController)?.presentCompose()
|
|
|
|
}
|
|
|
|
|
|
|
|
func select(tab: MainTabBarViewController.Tab) {
|
|
|
|
(child as? TuskerRootViewController)?.select(tab: tab)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getTabController(tab: MainTabBarViewController.Tab) -> UIViewController? {
|
|
|
|
return (child as? TuskerRootViewController)?.getTabController(tab: tab)
|
|
|
|
}
|
|
|
|
|
|
|
|
func performSearch(query: String) {
|
|
|
|
(child as? TuskerRootViewController)?.performSearch(query: query)
|
|
|
|
}
|
|
|
|
|
|
|
|
func presentPreferences(completion: (() -> Void)?) {
|
|
|
|
(child as? TuskerRootViewController)?.presentPreferences(completion: completion)
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
|
|
|
(child as? TuskerRootViewController)?.handleStatusBarTapped(xPosition: xPosition) ?? .continue
|
|
|
|
}
|
|
|
|
}
|