Skip to content

Commit cace2a3

Browse files
authored
Improve the floating shell button and fix its position in the screens (status-im#16981)
1 parent 92403f5 commit cace2a3

File tree

14 files changed

+161
-163
lines changed

14 files changed

+161
-163
lines changed

src/quo2/components/buttons/dynamic_button/view.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
:active-opacity 1
6262
:hit-slop {:top 5 :bottom 5 :left 5 :right 5}
6363
:pointer-events :auto
64+
:style {:height 24}
6465
:accessibility-label type}
6566
[rn/view
6667
{:style (merge

src/quo2/components/navigation/floating_shell_button.cljs

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(ns quo2.components.navigation.floating-shell-button.style
2+
(:require [react-native.reanimated :as reanimated]))
3+
4+
(defn floating-shell-button
5+
[style opacity-anim]
6+
(reanimated/apply-animations-to-style
7+
(if opacity-anim
8+
{:opacity opacity-anim}
9+
{})
10+
(merge
11+
{:flex-direction :row
12+
:height 44
13+
:align-self :center
14+
:padding-top 8
15+
:padding-horizontal 12
16+
:pointer-events :box-none}
17+
style)))
18+
19+
(def right-section
20+
{:position :absolute
21+
:flex-direction :row
22+
:right 0})
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
(ns quo2.components.navigation.floating-shell-button.view
2+
(:require [react-native.core :as rn]
3+
[react-native.reanimated :as reanimated]
4+
[quo2.components.buttons.dynamic-button.view :as dynamic-button]
5+
[quo2.components.navigation.floating-shell-button.style :as style]))
6+
7+
(defn dynamic-button-view
8+
[type dynamic-buttons style]
9+
(when-let [{:keys [on-press customization-color label] :as props} (get dynamic-buttons type)]
10+
[dynamic-button/view
11+
{:type type
12+
:label label
13+
:on-press on-press
14+
:count (:count props)
15+
:style style
16+
:customization-color customization-color}]))
17+
18+
(defn- section
19+
[children]
20+
[rn/view {:style {:flex 1} :pointer-events :box-none} children])
21+
22+
(defn- f-floating-shell-button
23+
[dynamic-buttons style opacity-anim]
24+
[reanimated/view {:style (style/floating-shell-button style opacity-anim)}
25+
;; Left Section
26+
[section
27+
[dynamic-button-view :search dynamic-buttons
28+
{:position :absolute
29+
:right 8}]]
30+
;; Mid Section (jump-to)
31+
[dynamic-button-view :jump-to dynamic-buttons nil]
32+
;; Right Section
33+
[section
34+
[rn/view
35+
{:style style/right-section}
36+
[dynamic-button-view :mention dynamic-buttons {:margin-left 8}]
37+
[dynamic-button-view :notification-down dynamic-buttons {:margin-left 8}]
38+
[dynamic-button-view :notification-up dynamic-buttons {:margin-left 8}]
39+
[dynamic-button-view :scroll-to-bottom dynamic-buttons {:margin-left 8}]]]])
40+
41+
(defn view
42+
"[floating-shell-button dynamic-buttons style opacity-anim pointer-anim]
43+
dynamic-buttons {:button-type {:on-press on-press :count count}}
44+
style override style
45+
opacity-anim reanimated value (optional)"
46+
([dynamic-buttons style]
47+
[:f> f-floating-shell-button dynamic-buttons style nil])
48+
([dynamic-buttons style opacity-anim]
49+
[:f> f-floating-shell-button dynamic-buttons style opacity-anim]))

src/quo2/core.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
quo2.components.messages.author.view
7373
quo2.components.messages.gap
7474
quo2.components.messages.system-message
75-
quo2.components.navigation.floating-shell-button
75+
quo2.components.navigation.floating-shell-button.view
7676
quo2.components.navigation.page-nav
7777
quo2.components.notifications.activity-log.view
7878
quo2.components.notifications.activity-logs-photos.view
@@ -243,7 +243,7 @@
243243
(def static-skeleton quo2.components.loaders.skeleton.view/view)
244244

245245
;;;; Navigation
246-
(def floating-shell-button quo2.components.navigation.floating-shell-button/floating-shell-button)
246+
(def floating-shell-button quo2.components.navigation.floating-shell-button.view/view)
247247
(def page-nav quo2.components.navigation.page-nav/page-nav)
248248

249249
;;;; Markdown

src/status_im2/contexts/chat/composer/style.cljs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
:shadow-offset {:width 0 :height (colors/theme-colors -4 -8)}}
1515
{:elevation (if @focused? 10 0)}))
1616

17+
(def composer-sheet-and-jump-to-container
18+
{:position :absolute
19+
:bottom 0
20+
:left 0
21+
:right 0})
22+
1723
(defn sheet-container
1824
[insets {:keys [focused?]} {:keys [container-opacity]}]
1925
(reanimated/apply-animations-to-style
@@ -22,10 +28,6 @@
2228
{:border-top-left-radius 20
2329
:border-top-right-radius 20
2430
:padding-horizontal 20
25-
:position :absolute
26-
:bottom 0
27-
:left 0
28-
:right 0
2931
:background-color (colors/theme-colors colors/white colors/neutral-95)
3032
:z-index 3
3133
:padding-bottom (:bottom insets)}
@@ -87,8 +89,7 @@
8789
:right 0
8890
:bottom 0
8991
:height window-height
90-
:background-color colors/neutral-95-opa-70
91-
:z-index 1}))
92+
:background-color colors/neutral-95-opa-70}))
9293

9394
(defn blur-container
9495
[height focused?]
@@ -110,18 +111,11 @@
110111
:blur-type (colors/theme-colors :light :dark)
111112
:blur-amount 20})
112113

113-
(defn shell-container
114-
[bottom translate-y]
115-
(reanimated/apply-animations-to-style
116-
{:bottom bottom ; we use height of the input directly as bottom position
117-
:transform [{:translate-y translate-y}]}
118-
{:position :absolute
119-
:left 0
120-
:right 0}))
121-
122114
(defn shell-button
123115
[translate-y opacity]
124116
(reanimated/apply-animations-to-style
125117
{:transform [{:translate-y translate-y}]
126118
:opacity opacity}
127-
{}))
119+
{:position :absolute
120+
:top 0
121+
:align-self :center}))

src/status_im2/contexts/chat/composer/sub_view.cljs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
[react-native.core :as rn]
66
[status-im2.config :as config]
77
[react-native.reanimated :as reanimated]
8-
[react-native.safe-area :as safe-area]
98
[status-im2.contexts.chat.composer.style :as style]
10-
[status-im2.contexts.chat.composer.utils :as utils]
119
[status-im2.contexts.chat.messages.list.view :as messages.list]
1210
[utils.i18n :as i18n]
1311
[utils.re-frame :as rf]))
@@ -27,12 +25,8 @@
2725
[:f> f-blur-view layout-height focused?])
2826

2927
(defn- f-shell-button
30-
[{:keys [maximized? focused?]} {:keys [height]} {:keys [reply edit]}]
28+
[{:keys [focused?]}]
3129
(let [customization-color (rf/sub [:profile/customization-color])
32-
insets (safe-area/get-insets)
33-
extra-height (utils/calc-top-content-height reply edit)
34-
neg-y (utils/calc-shell-neg-y insets maximized? extra-height)
35-
y-container (reanimated/use-shared-value neg-y)
3630
hide-shell? (or @focused? @messages.list/show-floating-scroll-down-button)
3731
y-shell (reanimated/use-shared-value (if hide-shell? 35 0))
3832
opacity (reanimated/use-shared-value (if hide-shell? 0 1))]
@@ -41,8 +35,7 @@
4135
(reanimated/animate opacity (if hide-shell? 0 1))
4236
(reanimated/animate y-shell (if hide-shell? 35 0)))
4337
[@focused? @messages.list/show-floating-scroll-down-button])
44-
[reanimated/view
45-
{:style (style/shell-container height y-container)}
38+
[:<>
4639
[reanimated/view
4740
{:style (style/shell-button y-shell opacity)}
4841
[quo/floating-shell-button
@@ -53,11 +46,12 @@
5346
(rf/dispatch [:shell/navigate-to-jump-to]))
5447
:customization-color customization-color
5548
:label (i18n/label :t/jump-to)
56-
:style {:align-self :center}}} {}]]
49+
:style {:align-self :center}}}
50+
{}]]
5751
[quo/floating-shell-button
5852
(when @messages.list/show-floating-scroll-down-button
5953
{:scroll-to-bottom {:on-press messages.list/scroll-to-bottom}})
60-
{:bottom 24}]]))
54+
{}]]))
6155

6256
(defn shell-button
6357
[state animations subs]

src/status_im2/contexts/chat/composer/view.cljs

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -66,62 +66,64 @@
6666
(effects/link-previews props state animations subs)
6767
(effects/images props state animations subs)
6868
[:<>
69-
[sub-view/shell-button state animations subs]
7069
(when chat-screen-loaded?
7170
[mentions/view props state animations max-height cursor-pos
7271
(:images subs)
7372
(:link-previews? subs)
7473
(:reply subs)
7574
(:edit subs)])
76-
[gesture/gesture-detector
77-
{:gesture (drag-gesture/drag-gesture props state animations subs dimensions keyboard-shown)}
78-
[reanimated/view
79-
{:style (style/sheet-container insets state animations)
80-
:on-layout #(handler/layout % state blur-height)}
81-
[sub-view/bar]
82-
(when chat-screen-loaded?
83-
[:<>
84-
[reply/view state]
85-
[edit/view state]])
86-
[reanimated/touchable-opacity
87-
{:active-opacity 1
88-
:on-press (when @(:input-ref props) #(.focus ^js @(:input-ref props)))
89-
:style (style/input-container (:height animations) max-height)
90-
:accessibility-label :message-input-container}
91-
[rn/selectable-text-input
92-
{:ref #(reset! (:selectable-input-ref props) %)
93-
:menu-items @(:menu-items state)
94-
:style (style/input-view state)}
95-
[rn/text-input
96-
{:ref #(reset! (:input-ref props) %)
97-
:default-value @(:text-value state)
98-
:on-focus #(handler/focus props state animations dimensions)
99-
:on-blur #(handler/blur state animations dimensions subs)
100-
:on-content-size-change #(handler/content-size-change %
101-
state
102-
animations
103-
subs
104-
dimensions
105-
(or keyboard-shown (:edit subs)))
106-
:on-scroll #(handler/scroll % props state animations dimensions)
107-
:on-change-text #(handler/change-text % props state)
108-
:on-selection-change #(handler/selection-change % props state)
109-
:on-selection #(selection/on-selection % props state)
110-
:keyboard-appearance (theme/theme-value :light :dark)
111-
:max-height max-height
112-
:max-font-size-multiplier 1
113-
:multiline true
114-
:placeholder (i18n/label :t/type-something)
115-
:placeholder-text-color (colors/theme-colors colors/neutral-30 colors/neutral-50)
116-
:style (style/input-text props state subs max-height)
117-
:max-length constants/max-text-size
118-
:accessibility-label :chat-message-input}]]
75+
[rn/view
76+
{:style style/composer-sheet-and-jump-to-container}
77+
[sub-view/shell-button state]
78+
[gesture/gesture-detector
79+
{:gesture (drag-gesture/drag-gesture props state animations subs dimensions keyboard-shown)}
80+
[reanimated/view
81+
{:style (style/sheet-container insets state animations)
82+
:on-layout #(handler/layout % state blur-height)}
83+
[sub-view/bar]
11984
(when chat-screen-loaded?
12085
[:<>
121-
[gradients/view props state animations show-bottom-gradient?]
122-
[link-preview/view]
123-
[images/images-list]])]
124-
[actions/view props state animations window-height insets subs]]]]))
86+
[reply/view state]
87+
[edit/view state]])
88+
[reanimated/touchable-opacity
89+
{:active-opacity 1
90+
:on-press (when @(:input-ref props) #(.focus ^js @(:input-ref props)))
91+
:style (style/input-container (:height animations) max-height)
92+
:accessibility-label :message-input-container}
93+
[rn/selectable-text-input
94+
{:ref #(reset! (:selectable-input-ref props) %)
95+
:menu-items @(:menu-items state)
96+
:style (style/input-view state)}
97+
[rn/text-input
98+
{:ref #(reset! (:input-ref props) %)
99+
:default-value @(:text-value state)
100+
:on-focus #(handler/focus props state animations dimensions)
101+
:on-blur #(handler/blur state animations dimensions subs)
102+
:on-content-size-change #(handler/content-size-change %
103+
state
104+
animations
105+
subs
106+
dimensions
107+
(or keyboard-shown (:edit subs)))
108+
:on-scroll #(handler/scroll % props state animations dimensions)
109+
:on-change-text #(handler/change-text % props state)
110+
:on-selection-change #(handler/selection-change % props state)
111+
:on-selection #(selection/on-selection % props state)
112+
:keyboard-appearance (theme/theme-value :light :dark)
113+
:max-height max-height
114+
:max-font-size-multiplier 1
115+
:multiline true
116+
:placeholder (i18n/label :t/type-something)
117+
:placeholder-text-color (colors/theme-colors colors/neutral-30 colors/neutral-50)
118+
:style (style/input-text props state subs max-height)
119+
:max-length constants/max-text-size
120+
:accessibility-label :chat-message-input}]]
121+
(when chat-screen-loaded?
122+
[:<>
123+
[gradients/view props state animations show-bottom-gradient?]
124+
[link-preview/view]
125+
[images/images-list]])]
126+
[actions/view props state animations window-height insets subs]]]]]))
125127

126128
(defn composer
127129
[insets]

0 commit comments

Comments
 (0)