Sfoglia il codice sorgente

wip, test folder picker

Weihua Lu 4 anni fa
parent
commit
c0ec0ee227
3 ha cambiato i file con 38 aggiunte e 21 eliminazioni
  1. 30 20
      src/main/frontend/components/widgets.cljs
  2. 3 1
      src/main/frontend/mobile/util.cljs
  3. 5 0
      yarn.lock

+ 30 - 20
src/main/frontend/components/widgets.cljs

@@ -1,5 +1,6 @@
 (ns frontend.components.widgets
 (ns frontend.components.widgets
   (:require [clojure.string :as string]
   (:require [clojure.string :as string]
+            [frontend.mobile.util :as mobile]
             [frontend.context.i18n :as i18n]
             [frontend.context.i18n :as i18n]
             [frontend.handler.notification :as notification]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
             [frontend.handler.page :as page-handler]
@@ -84,27 +85,36 @@
   (rum/with-context [[t] i18n/*tongue-context*]
   (rum/with-context [[t] i18n/*tongue-context*]
     [:div.flex.flex-col
     [:div.flex.flex-col
      [:h1.title "Add a graph"]
      [:h1.title "Add a graph"]
-     (let [nfs-supported? (nfs/supported?)]
-       [:div.cp__widgets-open-local-directory
-        [:div.select-file-wrap.cursor
-         (when nfs-supported?
-           {:on-click #(page-handler/ls-dir-files! shortcut/refresh!)})
-         [:div
-          [:h1.title "Open a local directory"]
-          [:p "Logseq supports both Markdown and Org-mode. You can open an existing directory or create a new one on your device, a directory is also known simply as a folder. Your data will be stored only on this device."]
-          [:p "After you have opened your directory, it will create three folders in that directory:"]
-          [:ul
-           [:li "/journals - store your journal pages"]
-           [:li "/pages - store the other pages"]
-           [:li "/logseq - store configuration, custom.css, and some metadata."]]
-          (when-not nfs-supported?
-            (ui/admonition :warning
-                           [:p "It seems that your browser doesn't support the "
+     (if (mobile/is-native-platform?)
+       (ui/button "Open mobile graph test"
+                  :on-click
+                  (fn []
+                    (let [folder (.pickFolder mobile/folder-picker)]
+                      (js/console.log folder)
+                      ;;TODO
+                      nil)))
+       (let [nfs-supported? (nfs/supported?)]
+         [:div.cp__widgets-open-local-directory
+          [:div.select-file-wrap.cursor
+           (when nfs-supported?
+             {:on-click #(page-handler/ls-dir-files! shortcut/refresh!)})
+
+           [:div
+            [:h1.title "Open a local directory"]
+            [:p "Logseq supports both Markdown and Org-mode. You can open an existing directory or create a new one on your device, a directory is also known simply as a folder. Your data will be stored only on this device."]
+            [:p "After you have opened your directory, it will create three folders in that directory:"]
+            [:ul
+             [:li "/journals - store your journal pages"]
+             [:li "/pages - store the other pages"]
+             [:li "/logseq - store configuration, custom.css, and some metadata."]]
+            (when-not nfs-supported?
+              (ui/admonition :warning
+                             [:p "It seems that your browser doesn't support the "
 
 
-                            [:a {:href "https://web.dev/file-system-access/"
-                                 :target "_blank"}
-                             "new native filesystem API"]
-                            [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]))]]])]))
+                              [:a {:href   "https://web.dev/file-system-access/"
+                                   :target "_blank"}
+                               "new native filesystem API"]
+                              [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]))]]]))]))
 
 
 (rum/defcs add-graph <
 (rum/defcs add-graph <
   [state & {:keys [graph-types]
   [state & {:keys [graph-types]

+ 3 - 1
src/main/frontend/mobile/util.cljs

@@ -1,5 +1,5 @@
 (ns frontend.mobile.util
 (ns frontend.mobile.util
-  (:require ["@capacitor/core" :refer [Capacitor]]))
+  (:require ["@capacitor/core" :refer [Capacitor registerPlugin]]))
 
 
 (defn platform []
 (defn platform []
   (.getPlatform Capacitor))
   (.getPlatform Capacitor))
@@ -12,3 +12,5 @@
 
 
 (defn is-plugin-available? [name]
 (defn is-plugin-available? [name]
   (.isPluginAvailable Capacitor name))
   (.isPluginAvailable Capacitor name))
+
+(defonce folder-picker (registerPlugin "FolderPicker"))

+ 5 - 0
yarn.lock

@@ -6367,6 +6367,11 @@ mkdirp@^0.5.0, mkdirp@^0.5.4, mkdirp@~0.5.1:
   dependencies:
   dependencies:
     minimist "^1.2.5"
     minimist "^1.2.5"
 
 
+mkdirp@^1.0.3:
+  version "1.0.4"
+  resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
+  integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
+
 [email protected]:
 [email protected]:
   version "1.0.7"
   version "1.0.7"
   resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.0.7.tgz#b2034f29973eb278ac003003149c4b0220fa480e"
   resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.0.7.tgz#b2034f29973eb278ac003003149c4b0220fa480e"