persist pickerView tab selection

This commit is contained in:
True Zhuanjia
2026-04-10 23:25:46 +08:00
parent 8fd43d47dd
commit ca69fd62d9
3 changed files with 67 additions and 10 deletions
@@ -29,6 +29,7 @@ public final class WidgetPickerViewController: UIViewController {
public var shortcutPickerTipText: String?
@objc public var shortcutIdentifier: String?
private let presentationState = WidgetPickerPresentationState()
private var hostingViewController: UIHostingController<WidgetPickerView>?
public override func viewDidLoad() {
@@ -46,6 +47,7 @@ public final class WidgetPickerViewController: UIViewController {
keyboardPickerMode: keyboardPickerMode,
shortcutPickerTipText: shortcutPickerTipText,
shortcutIdentififier: shortcutIdentifier,
presentationState: presentationState,
onWidgetCreated: { [weak self] payload in
guard let self else { return }
self.delegate?.widgetPickerViewController(self, didCreateWidget: payload as NSDictionary)
@@ -78,6 +80,11 @@ public final class WidgetPickerViewController: UIViewController {
navigationController?.setNavigationBarHidden(true, animated: false)
}
public override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
presentationState.hasHostAppeared = true
}
private func resolvedTabs() -> [WidgetPickerTab] {
let tabs = tabIdentifiers.compactMap(WidgetPickerTab.init(identifier:))
return tabs.isEmpty ? WidgetPickerTab.allCases : tabs