mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 14:39:48 +00:00
slide-out animation for left sidebar
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user