From 499f4acd19eae46ff9445595da5012bef494a90e Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Sun, 16 Nov 2025 23:06:57 +0800 Subject: [PATCH] slide-out animation for left sidebar --- ios/App/App/AppDelegate.swift | 27 +++++++++++++++++++++++++++ src/main/mobile/components/app.css | 16 ---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index b624c14c95..1637da97f3 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -9,6 +9,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel private var navController: UINavigationController? private var pathStack: [String] = ["/"] private var ignoreRoutePopCount = 0 + private lazy var sidebarCloseGesture: UISwipeGestureRecognizer = { + let gesture = UISwipeGestureRecognizer(target: self, action: #selector(handleSidebarCloseSwipe(_:))) + gesture.direction = .left // right-to-left swipe to close + gesture.cancelsTouchesInView = false + return gesture + }() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { @@ -183,6 +189,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { guard let current = viewController as? NativePageViewController else { return } SharedWebViewController.instance.attach(to: current) + updateSidebarGestureAttachment(for: current) } func navigationController(_ navigationController: UINavigationController, @@ -198,6 +205,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel return pageVC.targetPath == "/left-sidebar" } + private func updateSidebarGestureAttachment(for vc: NativePageViewController) { + guard let nav = navController else { return } + if isLeftSidebar(vc) { + if sidebarCloseGesture.view !== nav.view { + nav.view.addGestureRecognizer(sidebarCloseGesture) + } + } else if sidebarCloseGesture.view != nil { + nav.view.removeGestureRecognizer(sidebarCloseGesture) + } + } + + @objc private func handleSidebarCloseSwipe(_ gesture: UISwipeGestureRecognizer) { + guard gesture.state == .ended else { return } + guard let nav = navController, + let top = nav.topViewController as? NativePageViewController, + isLeftSidebar(top) else { return } + // Let navigation delegate handle stack bookkeeping and JS back sync. + nav.popViewController(animated: true) + } + private func observeRouteChanges() { NotificationCenter.default.addObserver( forName: UILocalPlugin.routeChangeNotification, diff --git a/src/main/mobile/components/app.css b/src/main/mobile/components/app.css index 83bf184efd..e13ab09da9 100644 --- a/src/main/mobile/components/app.css +++ b/src/main/mobile/components/app.css @@ -472,17 +472,6 @@ html[data-silk-native-page-scroll-replaced=false] .app-silk-index-scroll-view { } } -.app-silk-sidebar-sheet-content { - @apply bg-white dark:bg-gray-02 flex flex-col items-center p-2; - box-sizing: border-box; - height: 100%; - max-width: 800px; - - /* APPEARANCE */ - border-radius: 0; - overflow: hidden; -} - .app-audio-recorder { @apply flex flex-col p-4 gap-4; @@ -540,11 +529,6 @@ html[data-silk-native-page-scroll-replaced=false] .app-silk-index-scroll-view { } } -.Sidebar-hidden { - @apply bg-transparent dark:bg-transparent; - box-shadow: none; -} - #app-main-content { padding-bottom: 200px; }