Skip to content

Commit 93b9599

Browse files
committed
enhance(capacitor): improve ux for android
1 parent 9ba5665 commit 93b9599

File tree

4 files changed

+12
-46
lines changed

4 files changed

+12
-46
lines changed

src/main/capacitor/components/app.cljs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,20 @@
217217
(fn []
218218
(let [handle-back!
219219
(fn []
220-
(fstate/clear-edit!)
221-
(fstate/clear-selection!)
222220
(cond
223221
(seq (ui/get-modal))
224222
(ui/close-modal!)
225223

224+
(seq (fstate/get-selection-blocks))
225+
(fstate/clear-selection!)
226+
226227
:else
227228
(-> (nav/nav-length?)
228-
(p/then (fn [len]
229-
(if (= len 1)
230-
(.exitApp App)
231-
(nav/nav-pop!)))))))
229+
(p/then (fn [len]
230+
(if (= len 1)
231+
(.exitApp App)
232+
(nav/nav-pop!))))))
233+
(fstate/clear-edit!))
232234
^js back-listener (.addListener App "backButton" handle-back!)]
233235
#(.remove back-listener)))
234236
[])

src/main/frontend/mobile/core.cljs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"Main ns for handling mobile start"
33
(:require ["@capacitor/app" :refer [^js App]]
44
["@capacitor/keyboard" :refer [^js Keyboard]]
5-
[clojure.string :as string]
65
[frontend.handler.editor :as editor-handler]
76
[frontend.mobile.deeplink :as deeplink]
87
[frontend.mobile.intent :as intent]
@@ -33,35 +32,6 @@
3332
(defn- android-init
3433
"Initialize Android-specified event listeners"
3534
[]
36-
;; patch back navigation
37-
(.addListener App "backButton"
38-
#(let [href js/window.location.href]
39-
(when (true? (cond
40-
(state/settings-open?)
41-
(state/close-settings!)
42-
43-
(state/modal-opened?)
44-
(state/close-modal!)
45-
46-
(state/get-left-sidebar-open?)
47-
(state/set-left-sidebar-open! false)
48-
49-
(state/action-bar-open?)
50-
(state/set-state! :mobile/show-action-bar? false)
51-
52-
(not-empty (state/get-selection-blocks))
53-
(editor-handler/clear-selection!)
54-
55-
(state/editing?)
56-
(editor-handler/escape-editing)
57-
58-
:else true))
59-
(if (or (string/ends-with? href "#/")
60-
(string/ends-with? href "/")
61-
(not (string/includes? href "#/")))
62-
(.exitApp App)
63-
(js/window.history.back)))))
64-
6535
(.addEventListener js/window "sendIntentReceived"
6636
#(intent/handle-received)))
6737

src/main/frontend/mobile/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939

4040
#mobile-editor-toolbar {
41-
@apply fixed bottom-0 left-0 w-full z-[9999] flex justify-between bg-gray-100 border-t border-gray-200;
41+
@apply fixed -bottom-1 left-0 w-full z-[9999] flex justify-between bg-gray-100 border-t border-gray-200;
4242

4343
transform: translateY(calc(-1 * var(--ls-native-kb-height, 0)));
4444

src/main/frontend/mobile/mobile_bar.cljs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
[command-handler {:keys [icon class]} & [event?]]
3636
[:div
3737
[:button.bottom-action
38-
{:on-pointer-down (fn [e]
39-
(util/stop e)
38+
{:on-mouse-down (fn [e]
4039
(if event?
4140
(command-handler e)
42-
(command-handler)))}
41+
(command-handler))
42+
(util/stop e))}
4343
(ui/icon icon {:size ui/icon-size :class class})]])
4444

4545
(rum/defc timestamp-submenu
@@ -55,12 +55,6 @@
5555
(callback e))}
5656
description])]
5757
[:div
58-
[:button.bottom-action
59-
{:on-pointer-down (fn [event]
60-
(util/stop event)
61-
(let [target (gdom/getElement "mobile-toolbar-timestamp-submenu")]
62-
(dom/add-class! target "show-submenu")))}
63-
(ui/icon "calendar" {:size ui/icon-size})]
6458
[:div#mobile-toolbar-timestamp-submenu.submenu
6559
{:style {:bottom @util/keyboard-height}}
6660
(command-cp #(let [today (page-handler/get-page-ref-text (date/today))]

0 commit comments

Comments
 (0)