enhance(android ): ux improvements (#12665)

This commit is contained in:
Charlie
2026-05-22 14:54:21 +08:00
committed by GitHub
parent 3173364abb
commit a50407846f
19 changed files with 952 additions and 186 deletions

View File

@@ -274,14 +274,14 @@
(mobile-tabs/selected-tab-ids
(storage/get :ls-mobile-tabs)
{:flashcards? (state/enable-flashcards?)}
(mobile-tabs/max-main-tabs (mobile-util/native-iphone?))))
(mobile-tabs/max-main-tabs)))
(defn configure
[]
(let [tabs (->> (mobile-tabs/tab-configs
(storage/get :ls-mobile-tabs)
{:flashcards? (state/enable-flashcards?)}
(mobile-tabs/max-main-tabs (mobile-util/native-iphone?)))
(mobile-tabs/max-main-tabs))
(mapv translated-tab))]
(configure-tabs
(cond-> tabs

View File

@@ -26,7 +26,7 @@ html.is-ios {
html.is-native-android {
#app-container-wrapper {
padding-top: 56px;
padding-bottom: 0;
padding-bottom: 36px;
}
}
html.is-native-ios body,
@@ -236,11 +236,11 @@ ul {
max-width: calc(100vw - 40px);
&[data-side=top] {
max-height: var(--top-popup-content-max-height, 50vh);
max-height: var(--top-popup-content-max-height, 60vh);
}
&[data-side=bottom] {
max-height: var(--bottom-popup-content-max-height, 50vh);
max-height: var(--bottom-popup-content-max-height, 60vh);
}
}
}

View File

@@ -77,7 +77,7 @@
(defn- wrap-calc-commands-popup-side
[pos opts]
(let [[side mh] (let [[_x y _ height] pos
(let [[side _mh] (let [[_x y _ height] pos
vh (.-clientHeight js/document.body)
[th bh] [(- y 85) (- vh (+ y height) 310)]
direction (if (> bh 280) "bottom"
@@ -86,8 +86,7 @@
(if (= "top" direction)
["top" th]
["bottom" bh]))]
(-> (assoc opts :auto-side? false)
(assoc :max-popup-height mh)
(-> (assoc opts :auto-side? true)
(assoc-in [:content-props :side] side))))
(defn popup-show!

View File

@@ -9,7 +9,6 @@
[frontend.dicts :as dicts]
[frontend.handler.ui :as ui-handler]
[frontend.handler.user :as user-handler]
[frontend.mobile.util :as mobile-util]
[frontend.state :as state]
[frontend.storage :as storage]
[frontend.ui :as ui]
@@ -173,7 +172,7 @@
(let [[custom-tab-ids set-custom-tab-ids!] (hooks/use-state
(storage/get :ls-mobile-tabs))
features {:flashcards? (state/enable-flashcards?)}
max-tabs (mobile-tabs/max-main-tabs (mobile-util/native-iphone?))
max-tabs (mobile-tabs/max-main-tabs)
selected-tab-ids (mobile-tabs/selected-tab-ids custom-tab-ids features max-tabs)
selected-tab-id-set (set selected-tab-ids)
available-tabs (mobile-tabs/available-tabs features)

View File

@@ -14,7 +14,7 @@
;; Native search UI owns query/result clearing on each platform; doing it here
;; makes the Search UI redraw during the Home tab transition on iOS.
(when (and (= prev "search")
(not= tab "search"))
(not= tab "search"))
(mobile-nav/reset-stack-history! "search"))
(reset! *tab tab)
(mobile-nav/switch-stack! tab)))

View File

@@ -29,8 +29,9 @@
(def required-tab-id "home")
(defn max-main-tabs
[native-iphone?]
(if native-iphone? 4 5))
"Maximum number of configurable main tabs shown across mobile platforms."
[]
4)
(defn available-tabs
[{:keys [flashcards?]}]

View File

@@ -5,33 +5,33 @@
(deftest iphone-limits-main-tabs-to-four
(testing "iPhone keeps four configurable content tabs; native search is separate"
(is (= ["home" "graphs" "capture" "flashcards"]
(tabs/selected-tab-ids nil {:flashcards? true} (tabs/max-main-tabs true)))))
(tabs/selected-tab-ids nil {:flashcards? true} (tabs/max-main-tabs)))))
(testing "custom tab selections are respected before applying the iPhone cap"
(is (= ["home" "graphs" "go to" "capture"]
(tabs/selected-tab-ids ["home" "graphs" "go to" "capture" "flashcards"]
{:flashcards? true}
(tabs/max-main-tabs true))))))
(tabs/max-main-tabs))))))
(deftest selected-tabs-ignore-unavailable-tabs
(testing "disabled flashcards and unknown tab ids are removed"
(is (= ["home" "graphs" "go to"]
(tabs/selected-tab-ids ["unknown" "home" "flashcards" "graphs" "go to"]
{:flashcards? false}
(tabs/max-main-tabs false))))))
(tabs/max-main-tabs))))))
(deftest selected-tabs-always-include-home
(testing "home is kept as the stable first tab even when custom data omits it"
(is (= ["home" "graphs" "capture"]
(tabs/selected-tab-ids ["graphs" "capture"]
{:flashcards? true}
(tabs/max-main-tabs false)))))
(tabs/max-main-tabs)))))
(testing "home is moved back to the first position when custom data reorders it"
(is (= ["home" "graphs" "capture"]
(tabs/selected-tab-ids ["graphs" "home" "capture"]
{:flashcards? true}
(tabs/max-main-tabs false))))))
(tabs/max-main-tabs))))))
(deftest reorder-selected-tabs
(testing "dragging a selected tab before another selected tab changes tab order"
@@ -40,7 +40,7 @@
"flashcards"
"graphs"
{:flashcards? true}
(tabs/max-main-tabs true)))))
(tabs/max-main-tabs)))))
(testing "dragging a selected tab down inserts it after the target tab"
(is (= ["home" "capture" "flashcards" "graphs"]
@@ -48,7 +48,7 @@
"graphs"
"flashcards"
{:flashcards? true}
(tabs/max-main-tabs true)))))
(tabs/max-main-tabs)))))
(testing "dragging home is ignored because it is the stable first tab"
(is (= ["home" "graphs" "capture" "flashcards"]
@@ -56,7 +56,7 @@
"home"
"capture"
{:flashcards? true}
(tabs/max-main-tabs true)))))
(tabs/max-main-tabs)))))
(testing "dragging before home is ignored because home is pinned"
(is (= ["home" "graphs" "capture" "flashcards"]
@@ -64,7 +64,7 @@
"capture"
"home"
{:flashcards? true}
(tabs/max-main-tabs true)))))
(tabs/max-main-tabs)))))
(testing "reordering ignores unavailable targets"
(is (= ["home" "graphs" "capture"]
@@ -72,4 +72,4 @@
"capture"
"flashcards"
{:flashcards? false}
(tabs/max-main-tabs false))))))
(tabs/max-main-tabs))))))