Fix composer opacity on reenter screen (#16010)

* fix: composer opacity on re-enter screen
This commit is contained in:
Omar Basem 2023-05-24 22:10:33 +04:00 committed by GitHub
parent 7fc05bc069
commit 24eaec80bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 17 deletions

View File

@ -8,6 +8,7 @@
[status-im.async-storage.core :as async-storage]
[status-im2.contexts.chat.composer.constants :as constants]
[status-im2.contexts.chat.composer.keyboard :as kb]
[status-im2.contexts.chat.composer.utils :as utils]
[utils.debounce :as debounce]
[utils.number :as utils.number]
[utils.re-frame :as rf]))
@ -83,20 +84,9 @@
(reanimated/animate container-opacity 1)))
(defn empty-effect
[{:keys [text-value maximized? focused?]}
{:keys [container-opacity]}
images?
link-previews?
reply?
audio]
(when
(and (empty? @text-value)
(not images?)
(not link-previews?)
(not reply?)
(not @maximized?)
(not @focused?)
(not audio))
[{:keys [container-opacity]}
{:keys [input-text images link-previews? reply audio]}]
(when (utils/empty-input? input-text images link-previews? reply audio)
(reanimated/animate-delay container-opacity constants/empty-opacity 200)))
(defn component-will-unmount
@ -113,7 +103,7 @@
(fn []
;; Some subscriptions can arrive after the composer if focused (esp. link
;; previews), so we need to react to changes in `max-height` outside of the
;; `on-focus` handler.
;; `on-focus` handler
(when @focused?
(let [new-height (min max-height (reanimated/get-shared-value last-height))]
(reanimated/set-shared-value last-height new-height)
@ -123,7 +113,7 @@
(defn initialize
[props state animations {:keys [max-height] :as dimensions}
{:keys [chat-input images link-previews? reply audio]}]
{:keys [chat-input images audio] :as subs}]
(max-height-effect state dimensions animations)
(rn/use-effect
(fn []
@ -135,7 +125,7 @@
(images-effect props animations images)
(link-preview-effect state)
(audio-effect state animations audio)
(empty-effect state animations images link-previews? reply audio)
(empty-effect animations subs)
(kb/add-kb-listeners props state animations dimensions)
#(component-will-unmount props))
[max-height]))