Skip to content

Commit

Permalink
fix: composer size when re-entering with unfinished multiline message (
Browse files Browse the repository at this point in the history
…#18089)

fix: composer space when expanding after re-entering

fix: composer bottom shadow and maximized state atom

fix: removing composer bottom gradient style changes
  • Loading branch information
clauxx authored Jan 17, 2024
1 parent 49e9b42 commit 72bf8a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
22 changes: 14 additions & 8 deletions src/status_im/contexts/chat/messenger/composer/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
(defn reenter-screen-effect
[{:keys [text-value saved-cursor-position maximized?]}
{:keys [content-height]}
{:keys [input-content-height input-text input-maximized?]}]
(when (and (empty? @text-value) (not= input-text nil))
(reset! text-value input-text)
(reset! content-height input-content-height)
(reset! saved-cursor-position (count input-text)))
(when input-maximized?
(reset! maximized? true)))
{:keys [input-content-height input-text input-maximized?]}
{:keys [height]}]
(let [lines (utils/calc-lines input-content-height)
minimized-height (if (or (= lines 1) (empty? input-text))
constants/input-height
constants/multiline-minimized-height)]
(when (and (empty? @text-value) (not= input-text nil))
(reset! text-value input-text)
(reset! content-height input-content-height)
(reset! saved-cursor-position (count input-text))
(reanimated/set-shared-value height minimized-height))
(when input-maximized?
(reset! maximized? true))))

(defn maximized-effect
[{:keys [maximized?]}
Expand Down Expand Up @@ -101,7 +107,7 @@
[max-height])
(rn/use-effect
(fn []
(reenter-screen-effect state dimensions subscriptions))
(reenter-screen-effect state dimensions subscriptions animations))
[max-height subscriptions]))

(defn use-edit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
:position :absolute
:bottom 0
:left 0
:right 0
:z-index 2})
:right 0})

(defn bottom-gradient
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
(when show-bottom-gradient?
[rn/pressable
{:on-press #(when @input-ref (.focus ^js @input-ref))
:style {:z-index 1}
:accessibility-label :bottom-gradient}
[linear-gradient/linear-gradient (style/bottom-gradient)]])]))

Expand Down
10 changes: 6 additions & 4 deletions src/status_im/contexts/chat/messenger/composer/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
(defn focus
"Animate to the `saved-height`, display background-overlay if needed, and set cursor position"
[{:keys [input-ref] :as props}
{:keys [text-value focused? lock-selection? saved-cursor-position composer-focused?]}
{:keys [text-value focused? lock-selection? saved-cursor-position composer-focused? maximized?]}
{:keys [height saved-height last-height opacity background-y container-opacity]
:as animations}
{:keys [max-height] :as dimensions}]
(reanimated/set-shared-value composer-focused? true)
(reset! focused? true)
(rf/dispatch [:chat.ui/set-input-focused true])
(let [last-height-value (reanimated/get-shared-value last-height)]
(reanimated/animate height last-height-value)
(reanimated/set-shared-value saved-height last-height-value)
(let [last-height-value (reanimated/get-shared-value last-height)
new-height (min max-height last-height-value)]
(reanimated/animate height new-height)
(reanimated/set-shared-value saved-height new-height)
(reanimated/animate container-opacity 1)
(when (> last-height-value (* constants/background-threshold max-height))
(reset! maximized? true)
(reanimated/animate opacity 1)
(reanimated/set-shared-value background-y 0)))

Expand Down

0 comments on commit 72bf8a8

Please sign in to comment.