fix: composer opacity (#15929)

This commit is contained in:
Omar Basem 2023-05-17 19:43:42 +04:00 committed by GitHub
parent 03f501ca7b
commit b264d25b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 25 deletions

View File

@ -64,7 +64,7 @@
[:f> f-send-button state animations window-height images? btn-opacity z-index])) [:f> f-send-button state animations window-height images? btn-opacity z-index]))
(defn audio-button (defn audio-button
[{:keys [record-reset-fn]} [{:keys [record-reset-fn input-ref]}
{:keys [record-permission? recording? gesture-enabled? focused?]} {:keys [record-permission? recording? gesture-enabled? focused?]}
{:keys [container-opacity]}] {:keys [container-opacity]}]
(let [audio (rf/sub [:chats/sending-audio])] (let [audio (rf/sub [:chats/sending-audio])]
@ -86,17 +86,22 @@
(reset! recording? false) (reset! recording? false)
(reset! gesture-enabled? true) (reset! gesture-enabled? true)
(rf/dispatch [:chat/send-audio file-path duration]) (rf/dispatch [:chat/send-audio file-path duration])
(when-not @focused? (if-not @focused?
(reanimated/animate container-opacity (reanimated/animate container-opacity
constants/empty-opacity)) constants/empty-opacity)
(js/setTimeout #(when @input-ref (.focus ^js @input-ref))
300))
(rf/dispatch [:chat.ui/set-input-audio nil])) (rf/dispatch [:chat.ui/set-input-audio nil]))
:on-cancel (fn [] :on-cancel (fn []
(when @recording? (when @recording?
(reset! recording? false) (reset! recording? false)
(reset! gesture-enabled? true) (reset! gesture-enabled? true)
(when-not @focused? (if-not @focused?
(reanimated/animate container-opacity (reanimated/animate container-opacity
constants/empty-opacity)) constants/empty-opacity)
(js/setTimeout #(when @input-ref
(.focus ^js @input-ref))
300))
(rf/dispatch [:chat.ui/set-input-audio nil]))) (rf/dispatch [:chat.ui/set-input-audio nil])))
:on-check-audio-permissions (fn [] :on-check-audio-permissions (fn []
(permissions/permission-granted? (permissions/permission-granted?

View File

@ -36,29 +36,30 @@
(defn blur (defn blur
[{:keys [text-value focused? lock-selection? cursor-position saved-cursor-position gradient-z-index [{:keys [text-value focused? lock-selection? cursor-position saved-cursor-position gradient-z-index
maximized?]} maximized? recording?]}
{:keys [height saved-height last-height gradient-opacity container-opacity opacity background-y]} {:keys [height saved-height last-height gradient-opacity container-opacity opacity background-y]}
{:keys [content-height max-height window-height]} {:keys [content-height max-height window-height]}
{:keys [images reply]}] {:keys [images reply]}]
(let [lines (utils/calc-lines (- @content-height constants/extra-content-offset)) (when-not @recording?
min-height (utils/get-min-height lines) (let [lines (utils/calc-lines (- @content-height constants/extra-content-offset))
reopen-height (utils/calc-reopen-height text-value min-height content-height saved-height)] min-height (utils/get-min-height lines)
(reset! focused? false) reopen-height (utils/calc-reopen-height text-value min-height content-height saved-height)]
(rf/dispatch [:chat.ui/set-input-focused false]) (reset! focused? false)
(reanimated/set-shared-value last-height reopen-height) (rf/dispatch [:chat.ui/set-input-focused false])
(reanimated/animate height min-height) (reanimated/set-shared-value last-height reopen-height)
(reanimated/set-shared-value saved-height min-height) (reanimated/animate height min-height)
(reanimated/animate opacity 0) (reanimated/set-shared-value saved-height min-height)
(js/setTimeout #(reanimated/set-shared-value background-y (- window-height)) 300) (reanimated/animate opacity 0)
(when (utils/empty-input? @text-value images reply nil) (js/setTimeout #(reanimated/set-shared-value background-y (- window-height)) 300)
(reanimated/animate container-opacity constants/empty-opacity)) (when (utils/empty-input? @text-value images reply nil)
(reanimated/animate gradient-opacity 0) (reanimated/animate container-opacity constants/empty-opacity))
(reset! lock-selection? true) (reanimated/animate gradient-opacity 0)
(reset! saved-cursor-position @cursor-position) (reset! lock-selection? true)
(reset! gradient-z-index (if (= (reanimated/get-shared-value gradient-opacity) 1) -1 0)) (reset! saved-cursor-position @cursor-position)
(when (not= reopen-height max-height) (reset! gradient-z-index (if (= (reanimated/get-shared-value gradient-opacity) 1) -1 0))
(reset! maximized? false) (when (not= reopen-height max-height)
(rf/dispatch [:chat.ui/set-input-maximized false])))) (reset! maximized? false)
(rf/dispatch [:chat.ui/set-input-maximized false])))))
(defn content-size-change (defn content-size-change
[event [event