Просмотр исходного кода

feat(mobile): tap status bar to scroll to top

leizhe 3 лет назад
Родитель
Сommit
79a1c15ba9
6 измененных файлов с 27 добавлено и 10 удалено
  1. 8 6
      ios/App/App/Info.plist
  2. 1 0
      ios/App/Podfile
  3. 1 0
      package.json
  4. 8 2
      src/main/frontend/mobile/core.cljs
  5. 4 2
      src/main/frontend/util.cljc
  6. 5 0
      yarn.lock

+ 8 - 6
ios/App/App/Info.plist

@@ -31,6 +31,8 @@
 	<string>$(MARKETING_VERSION)</string>
 	<key>CFBundleVersion</key>
 	<string>$(CURRENT_PROJECT_VERSION)</string>
+	<key>LSApplicationCategoryType</key>
+	<string></string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>LSSupportsOpeningDocumentsInPlace</key>
@@ -40,6 +42,8 @@
 		<key>NSAllowsArbitraryLoads</key>
 		<true/>
 	</dict>
+	<key>NSCameraUsageDescription</key>
+	<string>We will access your camera when you take a photo, and embed it in your note.</string>
 	<key>NSDocumentsFolderUsageDescription</key>
 	<string></string>
 	<key>NSDownloadsFolderUsageDescription</key>
@@ -48,6 +52,10 @@
 	<string></string>
 	<key>NSFileProviderPresenceUsageDescription</key>
 	<string></string>
+	<key>NSPhotoLibraryAddUsageDescription</key>
+	<string>We will access your album when you save a photo.</string>
+	<key>NSPhotoLibraryUsageDescription</key>
+	<string>We will access your album when you choose a photo, and embed it in your note.</string>
 	<key>NSUbiquitousContainers</key>
 	<dict>
 		<key>iCloud.com.logseq.logseq</key>
@@ -64,12 +72,6 @@
 	<string>LaunchScreen</string>
 	<key>UIMainStoryboardFile</key>
 	<string>Main</string>
-	<key>NSPhotoLibraryAddUsageDescription</key>
-	<string>We will access your album when you save a photo.</string>
-	<key>NSCameraUsageDescription</key>
-	<string>We will access your camera when you take a photo, and embed it in your note.</string>
-	<key>NSPhotoLibraryUsageDescription</key>
-	<string>We will access your album when you choose a photo, and embed it in your note.</string>
 	<key>UIRequiredDeviceCapabilities</key>
 	<array>
 		<string>armv7</string>

+ 1 - 0
ios/App/Podfile

@@ -14,6 +14,7 @@ def capacitor_pods
   pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
   pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
   pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
+  pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
 end
 
 target 'Logseq' do

+ 1 - 0
package.json

@@ -71,6 +71,7 @@
         "@capacitor/ios": "3.2.2",
         "@capacitor/keyboard": "^1.2.0",
         "@capacitor/splash-screen": "1.1.3",
+        "@capacitor/status-bar": "1.0.6",
         "@excalidraw/excalidraw": "0.4.3",
         "@kanru/rage-wasm": "0.2.1",
         "@sentry/browser": "6.4.1",

+ 8 - 2
src/main/frontend/mobile/core.cljs

@@ -3,13 +3,15 @@
             [frontend.state :as state]
             ["@capacitor/app" :refer [^js App]]
             ["@capacitor/keyboard" :refer [^js Keyboard]]
+            ["@capacitor/status-bar" :refer [^js StatusBar]]
             [clojure.string :as string]
             [frontend.fs.capacitor-fs :as fs]
             [frontend.components.repo :as repo]
             [frontend.handler.web.nfs :as nfs-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.notification :as notification]
-            [promesa.core :as p]))
+            [promesa.core :as p]
+            [frontend.util :as util]))
 
 (defn init!
   []
@@ -51,4 +53,8 @@
                         (if is-active?
                           (p/do! (nfs-handler/refresh! repo repo/refresh-cb)
                                  (notification/show! "Notes updated!" :success true))
-                          (editor-handler/save-current-block!))))))))
+                          (editor-handler/save-current-block!)))))))
+
+  (when (mobile-util/is-native-platform?)
+    (.addEventListener js/window "statusTap"
+                       #(util/scroll-to-top true))))

+ 4 - 2
src/main/frontend/util.cljc

@@ -465,8 +465,10 @@
 
 #?(:cljs
    (defn scroll-to-top
-     []
-     (scroll-to (app-scroll-container-node) 0 false)))
+     ([]
+      (scroll-to (app-scroll-container-node) 0 false))
+     ([animate?]
+      (scroll-to (app-scroll-container-node) 0 animate?))))
 
 #?(:cljs
    (defn scroll-to-bottom

+ 5 - 0
yarn.lock

@@ -500,6 +500,11 @@
   resolved "https://registry.yarnpkg.com/@capacitor/splash-screen/-/splash-screen-1.1.3.tgz#024bc91b2b521b9f1d5e86f16a114f294bf326fa"
   integrity sha512-DJh1w9872UofZWAxPLgd5yWi09W0IoWPVBdVd8Ku1mrPfFvtcMeguZHGLEIo+A6DkdCTWzMrh26TLCIympws2g==
 
+"@capacitor/[email protected]":
+  version "1.0.6"
+  resolved "https://registry.npmmirror.com/@capacitor/status-bar/download/@capacitor/status-bar-1.0.6.tgz#d58c9087cfc7c7377e8009bea86152e4fdd2939e"
+  integrity sha1-1YyQh8/Hxzd+gAm+qGFS5P3Sk54=
+
 "@electron/get@^1.13.0":
   version "1.13.1"
   resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.13.1.tgz#42a0aa62fd1189638bd966e23effaebb16108368"