Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed Oct 31, 2023
1 parent 2f711b9 commit c32a7ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
11 changes: 5 additions & 6 deletions src/status_im2/contexts/chat/messages/list/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,13 @@
[message/message message-data context keyboard-shown?])]))

(defn scroll-handler
[event scroll-y animate-topbar-opacity?]
[event scroll-y animate-topbar-opacity? on-end-reached?]
(let [content-size-y (- (oops/oget event "nativeEvent.contentSize.height")
(oops/oget event "nativeEvent.layoutMeasurement.height"))
current-y (oops/oget event "nativeEvent.contentOffset.y")
scroll-distance (- content-size-y current-y)]

(when (and @on-end-reached? (> scroll-distance 0))
(reset! on-end-reached? false))
(if (< topbar-visible-scroll-y-value scroll-distance)
(when-not @animate-topbar-opacity?
(reset! animate-topbar-opacity? true))
Expand All @@ -297,8 +298,7 @@
(reanimated/set-shared-value scroll-y scroll-distance)))

(defn f-messages-list-content
[{:keys [chat insets scroll-y content-height cover-bg-color keyboard-shown? inner-state-atoms
animate-topbar-name? big-name-visible? animate-topbar-opacity? composer-active?
[{:keys [chat insets scroll-y content-height cover-bg-color keyboard-shown? inner-state-atoms big-name-visible? animate-topbar-opacity? composer-active?
on-end-reached?]}]
(let [theme (quo.theme/use-theme-value)
{window-height :height} (rn/get-window)
Expand All @@ -307,7 +307,6 @@
messages (rf/sub [:chats/raw-chat-messages-stream (:chat-id chat)])
recording? (rf/sub [:chats/recording?])
all-loaded? (rf/sub [:chats/all-loaded? (:chat-id chat)])
more-than-two-messages? (<= 2 (count messages))
{:keys [show-floating-scroll-down-button?
messages-view-height
messages-view-header-height]} inner-state-atoms]
Expand Down Expand Up @@ -373,7 +372,7 @@
:on-momentum-scroll-end state/stop-scrolling
:scroll-event-throttle 16
:on-scroll (fn [event]
(scroll-handler event scroll-y animate-topbar-opacity?)
(scroll-handler event scroll-y animate-topbar-opacity? on-end-reached?)
(on-scroll event show-floating-scroll-down-button?))
:style (add-inverted-y-android
{:background-color (if all-loaded?
Expand Down
25 changes: 14 additions & 11 deletions src/status_im2/contexts/chat/messages/navigation/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@
more-than-seven-messages? (<= 7 (count messages))]
(rn/use-effect
(fn []
(if (or
(and (not composer-active?)
more-than-seven-messages?
(= :initial-render @big-name-visible?))
(and more-than-two-messages?
(< title-opacity-interpolation-start (reanimated/get-shared-value scroll-y))
composer-active?)
(and more-than-two-messages?
composer-active?)
@animate-topbar-name?
@animate-topbar-opacity?)
(if (when-not (and
@on-end-reached?
(not composer-active?))
(or
(and (not composer-active?)
more-than-seven-messages?
(= :initial-render @big-name-visible?))
(and more-than-two-messages?
(< title-opacity-interpolation-start (reanimated/get-shared-value scroll-y))
composer-active?)
(and more-than-two-messages?
composer-active?)
@animate-topbar-name?
@animate-topbar-opacity?))
(do
(reanimated/animate title-opacity-animation 1)
(reanimated/animate opacity-animation 1)
Expand Down

0 comments on commit c32a7ef

Please sign in to comment.