Skip to content

Commit 9ebe370

Browse files
authored
Enhance/native bottom tabs (#12202)
* enhance(ux): native bottom tabs on iOS * fix: hide bottom tabs when sheet has been opened
1 parent 079c894 commit 9ebe370

File tree

10 files changed

+143
-25
lines changed

10 files changed

+143
-25
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ jobs:
7373
run: clojure -A:cljs -P
7474

7575
- name: Fetch yarn deps
76-
run: yarn install --frozen-lockfile
76+
# run: yarn install --frozen-lockfile
77+
run: yarn install
7778

7879
- name: Build test asset
7980
run: clojure -M:test compile test
@@ -179,4 +180,4 @@ jobs:
179180
run: cd deps/db && yarn nbb-logseq script/export_graph.cljs ../../scripts/properties-graph -f properties.edn -T
180181

181182
- name: Create graph from the export and diff the two graphs
182-
run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T
183+
run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T

ios/App/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def capacitor_pods
2626
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
2727
pod 'CapgoCapacitorNavigationBar', :path => '../../node_modules/@capgo/capacitor-navigation-bar'
2828
pod 'SendIntent', :path => '../../node_modules/send-intent'
29+
pod 'StayLiquid', :path => '../../node_modules/stay-liquid'
2930
pod 'JcesarmobileSslSkip', :path => '../../node_modules/@jcesarmobile/ssl-skip'
3031
end
3132

ios/App/Podfile.lock

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ PODS:
3434
- Capacitor
3535
- SendIntent (7.0.0):
3636
- Capacitor
37+
- StayLiquid (0.1.0):
38+
- Capacitor (>= 6.0.0)
3739

3840
DEPENDENCIES:
3941
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
@@ -54,6 +56,7 @@ DEPENDENCIES:
5456
- "CapgoCapacitorNavigationBar (from `../../node_modules/@capgo/capacitor-navigation-bar`)"
5557
- "JcesarmobileSslSkip (from `../../node_modules/@jcesarmobile/ssl-skip`)"
5658
- SendIntent (from `../../node_modules/send-intent`)
59+
- StayLiquid (from `../../node_modules/stay-liquid`)
5760

5861
EXTERNAL SOURCES:
5962
Capacitor:
@@ -92,27 +95,30 @@ EXTERNAL SOURCES:
9295
:path: "../../node_modules/@jcesarmobile/ssl-skip"
9396
SendIntent:
9497
:path: "../../node_modules/send-intent"
98+
StayLiquid:
99+
:path: "../../node_modules/stay-liquid"
95100

96101
SPEC CHECKSUMS:
97-
Capacitor: 106e7a4205f4618d582b886a975657c61179138d
98-
CapacitorActionSheet: 24609588961cc27c87e8b033be92b5eee65b5d4c
99-
CapacitorApp: d63334c052278caf5d81585d80b21905c6f93f39
100-
CapacitorCamera: eb8687d8687fed853598ec9460d94bcd5e16babe
101-
CapacitorClipboard: b98aead5dc7ec595547fc2c5d75bacd2ae3338bc
102-
CapacitorCommunitySafeArea: cc370b4f8d4aa340e4616acef9b73eda41ba0914
102+
Capacitor: 03bc7cbdde6a629a8b910a9d7d78c3cc7ed09ea7
103+
CapacitorActionSheet: 4213427449132ae4135674d93010cb011725647e
104+
CapacitorApp: febecbb9582cb353aed037e18ec765141f880fe9
105+
CapacitorCamera: 6e73f1fc6c629a672658705a02409b60854bc0f1
106+
CapacitorClipboard: 70bfdb42b877b320a6e511ab94fa7a6a55d57ecb
107+
CapacitorCommunitySafeArea: 3f049619072ab5d0da2529bcb05b358ff6c13dc1
103108
CapacitorCordova: 5967b9ba03915ef1d585469d6e31f31dc49be96f
104-
CapacitorDevice: a50a45f0d075e55e2392c7a4be5404d4f69515de
105-
CapacitorFilesystem: 307f97c27a265edf8396a1c9c235592fd8572fe3
106-
CapacitorHaptics: 70e47470fa1a6bd6338cd102552e3846b7f9a1b3
107-
CapacitorKeyboard: 969647d0ca2e5c737d7300088e2517aa832434e2
108-
CapacitorNetwork: 07ec4c69c1bb696f41c23e00d31bda1bbb221bba
109-
CapacitorShare: 58d6c2da63b093e8693287b2d36db92435538435
110-
CapacitorSplashScreen: 19cd3573e57507e02d6f34597a8c421e00931487
111-
CapacitorStatusBar: 275cbf2f4dfc00388f519ef80c7ec22edda342c9
112-
CapgoCapacitorNavigationBar: 028e6cc0f00357381c46edb7b0d7cd1cda73493b
113-
JcesarmobileSslSkip: b0f921e9d397a57f7983731209ca1ee244119c1f
114-
SendIntent: 1f4f65c7103eb423067c566682dfcda973b5fb29
109+
CapacitorDevice: 81ae78d5d1942707caad79276badd458bf6ec603
110+
CapacitorFilesystem: e6261c410436f54908c11f94336c5b58286b1db0
111+
CapacitorHaptics: 1f1e17041f435d8ead9ff2a34edd592c6aa6a8d6
112+
CapacitorKeyboard: 09fd91dcde4f8a37313e7f11bde553ad1ed52036
113+
CapacitorNetwork: 15cb4385f0913a8ceb5e9a4d7af1ec554bdb8de8
114+
CapacitorShare: e573823f511f260f598d0423c33b1e3d7bbe5fd1
115+
CapacitorSplashScreen: 1d67815a422a9b61539c94f283c08ed56667c0fc
116+
CapacitorStatusBar: 6e7af040d8fc4dd655999819625cae9c2d74c36f
117+
CapgoCapacitorNavigationBar: 067b1c1d1ede5ce96200a730ce7fd498e9641509
118+
JcesarmobileSslSkip: 5fa98636a64c36faa50f32ab4daf34e38f4d45b9
119+
SendIntent: 8a6f646a4489f788d253ffbd1082a98ea388d870
120+
StayLiquid: dac4b6cd7761472754f97d367ba4651ca79fcd2e
115121

116-
PODFILE CHECKSUM: 00fbb7ba3788966b68cb8a5a6f2abc380d7b7b9a
122+
PODFILE CHECKSUM: 858411d5b4560fd80593ea76b0fd6359bccabec3
117123

118124
COCOAPODS: 1.16.2

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
"sanitize-filename": "1.6.3",
191191
"send-intent": "^7.0.0",
192192
"shepherd.js": "^9.1.0",
193+
"stay-liquid": "https://github.com/logseq/stay-liquid.git#b2fde7447e2fff96f16b7715c6857d91c992359d",
193194
"tailwind-capitalize-first-letter": "^1.0.4",
194195
"threads": "1.6.5",
195196
"url": "^0.11.0",

src/main/mobile/bottom_tabs.cljs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
(ns mobile.bottom-tabs
2+
"iOS bottom tabs"
3+
(:require ["stay-liquid" :refer [TabsBar]]
4+
[cljs-bean.core :as bean]
5+
[frontend.handler.editor :as editor-handler]
6+
[frontend.mobile.util :as mobile-util]
7+
[frontend.state :as state]
8+
[frontend.util :as util]
9+
[mobile.state :as mobile-state]
10+
[promesa.core :as p]))
11+
12+
(defn- tab-options
13+
[theme visible?]
14+
{:visible visible?
15+
:initialId "home"
16+
:items [{:id "home"
17+
:title "Journals"
18+
:systemIcon "house"}
19+
20+
{:id "search"
21+
:title "Search"
22+
:systemIcon "magnifyingglass"}
23+
24+
{:id "quick-add"
25+
:title "Quick add"
26+
:systemIcon "plus"}
27+
28+
{:id "settings"
29+
:title "Settings"
30+
:systemIcon "gear"}]
31+
:selectedIconColor (if (= "light" theme)
32+
"rgb(0, 105, 182)"
33+
"#8ec2c2")
34+
:unselectedIconColor "#8E8E93"
35+
:titleOpacity 0.7})
36+
37+
(defn- configure-tabs
38+
[theme visible?]
39+
(.configure ^js TabsBar
40+
(bean/->js
41+
(tab-options theme visible?))))
42+
43+
(defn configure
44+
[]
45+
(p/do!
46+
(configure-tabs (:ui/theme @state/state) true)
47+
(.addListener ^js TabsBar
48+
"selected"
49+
(fn [^js data]
50+
(let [tab (.-id data)
51+
;; interaction (.-interaction data)
52+
]
53+
(when-not (= tab "quick-add")
54+
(mobile-state/set-tab! tab))
55+
(case tab
56+
"home"
57+
(util/scroll-to-top false)
58+
"quick-add"
59+
(editor-handler/show-quick-add)
60+
;; TODO: support longPress detection
61+
;; (if (= "longPress" interaction)
62+
;; (state/pub-event! [:mobile/start-audio-record])
63+
;; (editor-handler/show-quick-add))
64+
nil)))))
65+
66+
;; Update selected icon color according to current theme
67+
(add-watch state/state
68+
:theme-changed
69+
(fn [_ _ old new]
70+
(when-not (= (:ui/theme old) (:ui/theme new))
71+
(configure-tabs (:ui/theme new) true)))))
72+
73+
(defn hide!
74+
[]
75+
(when (mobile-util/native-ios?)
76+
(.hide ^js TabsBar)))
77+
78+
(defn show!
79+
[]
80+
(when (mobile-util/native-ios?)
81+
(.show ^js TabsBar)))

src/main/mobile/components/app.cljs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[frontend.components.journal :as journal]
55
[frontend.handler.common :as common-handler]
66
[frontend.handler.user :as user-handler]
7+
[frontend.mobile.util :as mobile-util]
78
[frontend.rum :as frum]
89
[frontend.state :as state]
910
[frontend.ui :as ui]
@@ -14,6 +15,7 @@
1415
[logseq.shui.silkhq :as silkhq]
1516
[logseq.shui.toaster.core :as shui-toaster]
1617
[logseq.shui.ui :as shui]
18+
[mobile.bottom-tabs :as bottom-tabs]
1719
[mobile.components.editor-toolbar :as editor-toolbar]
1820
[mobile.components.header :as mobile-header]
1921
[mobile.components.left-sidebar :as mobile-left-sidebar]
@@ -27,7 +29,6 @@
2729
[mobile.state :as mobile-state]
2830
[rum.core :as rum]))
2931

30-
3132
(defn- sidebar-not-allowed-to-open?
3233
[]
3334
(or (seq @mobile-state/*modal-blocks)
@@ -185,6 +186,8 @@
185186
(use-theme-effects! current-repo)
186187
(hooks/use-effect!
187188
(fn []
189+
(when (mobile-util/native-ios?)
190+
(bottom-tabs/configure))
188191
(when-let [element (util/mobile-page-scroll)]
189192
(common-handler/listen-to-scroll! element))) [])
190193
(silkhq/depth-sheet-stack
@@ -213,7 +216,8 @@
213216
(mobile-left-sidebar/left-sidebar)
214217

215218
;; bottom tabs
216-
(ui-silk/app-silk-tabs)
219+
(when-not (mobile-util/native-ios?)
220+
(ui-silk/app-silk-tabs))
217221

218222
(ui-component/keep-keyboard-virtual-input)
219223
(ui-component/install-notifications)

src/main/mobile/components/left_sidebar.cljs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Mobile left sidebar"
33
(:require [frontend.components.left-sidebar :as app-left-sidebar]
44
[logseq.shui.silkhq :as silkhq]
5+
[mobile.bottom-tabs :as bottom-tabs]
56
[mobile.state :as mobile-state]
67
[rum.core :as rum]))
78

@@ -18,11 +19,14 @@
1819
[]
1920
(when (empty? (rum/react mobile-state/*modal-blocks))
2021
(let [open? (rum/react mobile-state/*left-sidebar-open?)]
22+
(when open?
23+
(bottom-tabs/hide!))
2124
(silkhq/sidebar-sheet
2225
{:presented (boolean open?)
2326
:onPresentedChange (fn [v]
2427
(when (false? v)
25-
(mobile-state/close-left-sidebar!)))}
28+
(mobile-state/close-left-sidebar!)
29+
(bottom-tabs/show!)))}
2630
(silkhq/sidebar-sheet-portal
2731
(silkhq/sidebar-sheet-view
2832
{:class "app-silk-sidebar-sheet-view"}

src/main/mobile/components/modal.cljs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[logseq.shui.hooks :as hooks]
1414
[logseq.shui.silkhq :as silkhq]
1515
[logseq.shui.ui :as shui]
16+
[mobile.bottom-tabs :as bottom-tabs]
1617
[mobile.components.ui :as mobile-ui]
1718
[mobile.init :as init]
1819
[mobile.state :as mobile-state]
@@ -199,6 +200,7 @@
199200
(hooks/use-effect!
200201
(fn []
201202
(when open?
203+
(bottom-tabs/hide!)
202204
(state/clear-edit!)
203205
(init/keyboard-hide)))
204206
[open?])
@@ -209,7 +211,8 @@
209211
(when (false? v?)
210212
(mobile-state/close-block-modal!)
211213
(state/clear-edit!)
212-
(state/pub-event! [:mobile/keyboard-will-hide])))}
214+
(state/pub-event! [:mobile/keyboard-will-hide])
215+
(bottom-tabs/show!)))}
213216
(silkhq/depth-sheet-portal
214217
(silkhq/depth-sheet-view
215218
{:class "block-modal-page"

src/main/mobile/components/popup.cljs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[logseq.shui.popup.core :as shui-popup]
88
[logseq.shui.silkhq :as silkhq]
99
[logseq.shui.ui :as shui]
10+
[mobile.bottom-tabs :as bottom-tabs]
1011
[mobile.state :as mobile-state]
1112
[rum.core :as rum]))
1213

@@ -74,14 +75,17 @@
7475
default-height (:default-height opts)]
7576

7677
(when open?
78+
(bottom-tabs/hide!)
7779
(silkhq/bottom-sheet
7880
(merge
7981
{:presented (boolean open?)
8082
:onPresentedChange (fn [v?]
8183
(when (false? v?)
8284
(state/pub-event! [:mobile/clear-edit])
8385
;; allows closing animation
84-
(js/setTimeout #(mobile-state/set-popup! nil) 150)))}
86+
(js/setTimeout #(do
87+
(mobile-state/set-popup! nil)
88+
(bottom-tabs/show!)) 150)))}
8589
(:modal-props opts))
8690
(silkhq/bottom-sheet-portal
8791
(silkhq/bottom-sheet-view

yarn.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@
291291
dependencies:
292292
tslib "^2.1.0"
293293

294+
"@capacitor/core@^7.4.4":
295+
version "7.4.4"
296+
resolved "https://registry.yarnpkg.com/@capacitor/core/-/core-7.4.4.tgz#b752dd7a12141e40d1c8ce2e37a79571d9f83518"
297+
integrity sha512-xzjxpr+d2zwTpCaN0k+C6wKSZzWFAb9OVEUtmO72ihjr/NEDoLvsGl4WLfjWPcCO2zOy0b2X52tfRWjECFUjtw==
298+
dependencies:
299+
tslib "^2.1.0"
300+
294301
"@capacitor/device@^7.0.2":
295302
version "7.0.2"
296303
resolved "https://registry.yarnpkg.com/@capacitor/device/-/device-7.0.2.tgz#406bde129d3fcf55f0de0b691509535e2a00e315"
@@ -9539,6 +9546,12 @@ statuses@~1.5.0:
95399546
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
95409547
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
95419548

9549+
"stay-liquid@https://github.com/logseq/stay-liquid":
9550+
version "0.1.0"
9551+
resolved "https://github.com/logseq/stay-liquid#b2fde7447e2fff96f16b7715c6857d91c992359d"
9552+
dependencies:
9553+
"@capacitor/core" "^7.4.4"
9554+
95429555
stop-iteration-iterator@^1.1.0:
95439556
version "1.1.0"
95449557
resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz#f481ff70a548f6124d0312c3aa14cbfa7aa542ad"

0 commit comments

Comments
 (0)