Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Parveshdhull committed Nov 7, 2023
1 parent 1755780 commit ad28663
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 166 deletions.
24 changes: 9 additions & 15 deletions src/status_im2/contexts/chat/composer/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,15 @@

(defn init-subs
[]
(let [chat-screen-loaded? (rf/sub [:shell/chat-screen-loaded?])]
(merge
{:chat-screen-loaded? chat-screen-loaded?
:link-previews? false}
(when chat-screen-loaded?
(let [chat-input (rf/sub [:chats/current-chat-input])]
{:images (seq (rf/sub [:chats/sending-image]))
:link-previews? (rf/sub [:chats/link-previews?])
:audio (rf/sub [:chats/sending-audio])
:reply (rf/sub [:chats/reply-message])
:edit (rf/sub [:chats/edit-message])
:input-with-mentions (rf/sub [:chat/input-with-mentions])
:input-text (:input-text chat-input)
:input-content-height (:input-content-height chat-input)
:chat-screen-loaded? chat-screen-loaded?})))))
(let [chat-input (rf/sub [:chats/current-chat-input])]
{:images (seq (rf/sub [:chats/sending-image]))
:link-previews? (rf/sub [:chats/link-previews?])
:audio (rf/sub [:chats/sending-audio])
:reply (rf/sub [:chats/reply-message])
:edit (rf/sub [:chats/edit-message])
:input-with-mentions (rf/sub [:chat/input-with-mentions])
:input-text (:input-text chat-input)
:input-content-height (:input-content-height chat-input)}))

(defn init-animations
[{:keys [input-text images link-previews? reply audio]}
Expand Down
59 changes: 40 additions & 19 deletions src/status_im2/contexts/chat/composer/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
[status-im2.contexts.chat.composer.style :as style]
[status-im2.contexts.chat.composer.sub-view :as sub-view]
[status-im2.contexts.chat.composer.utils :as utils]
[utils.i18n :as i18n]))
[status-im2.contexts.chat.messages.contact-requests.bottom-drawer :as contact-requests.bottom-drawer]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn sheet-component
[{:keys [insets
Expand All @@ -34,8 +36,7 @@
opacity
background-y
theme]} props state]
(let [{:keys [chat-screen-loaded?]
:as subscriptions} (utils/init-subs)
(let [subscriptions (utils/init-subs)
content-height (reagent/atom (or (:input-content-height ; Actual text height
subscriptions)
constants/input-height))
Expand Down Expand Up @@ -80,12 +81,11 @@
(effects/link-previews props state animations subscriptions)
(effects/use-images props state animations subscriptions)
[:<>
(when chat-screen-loaded?
[mentions/view props state animations max-height cursor-pos
(:images subscriptions)
(:link-previews? subscriptions)
(:reply subscriptions)
(:edit subscriptions)])
[mentions/view props state animations max-height cursor-pos
(:images subscriptions)
(:link-previews? subscriptions)
(:reply subscriptions)
(:edit subscriptions)]
[rn/view
{:style style/composer-sheet-and-jump-to-container}
[sub-view/shell-button state scroll-to-bottom-fn show-floating-scroll-down-button?]
Expand All @@ -96,10 +96,9 @@
{:style (style/sheet-container insets state animations theme)
:on-layout #(handler/layout % state blur-height)}
[sub-view/bar]
(when chat-screen-loaded?
[:<>
[reply/view state]
[edit/view state]])
[:<>
[reply/view state]
[edit/view state]]
[reanimated/touchable-opacity
{:active-opacity 1
:on-press (fn []
Expand Down Expand Up @@ -138,15 +137,14 @@
:theme theme})
:max-length constants/max-text-size
:accessibility-label :chat-message-input}]]]
(when chat-screen-loaded?
[:<>
[gradients/view props state animations show-bottom-gradient?]
[link-preview/view]
[images/images-list]])
[:<>
[gradients/view props state animations show-bottom-gradient?]
[link-preview/view]
[images/images-list]]
[:f> actions/view props state animations window-height insets scroll-to-bottom-fn
subscriptions]]]]]))

(defn composer
(defn f-composer
[{:keys [insets scroll-to-bottom-fn show-floating-scroll-down-button?]}]
(let [window-height (:height (rn/get-window))
theme (quo.theme/use-theme-value)
Expand All @@ -172,3 +170,26 @@
:focused? (:focused? state)
:theme theme}]
[:f> sheet-component extra-params props state]]))

(defn composer-placeholder []
[rn/view {:style {:width 100 :height 100 :background-color :red}}])

(defn composer
[{:keys [insets scroll-to-bottom-fn show-floating-scroll-down-button?]}]
(if (rf/sub [:shell/chat-screen-loaded?])
(let [chat-screen-loaded? (rf/sub [:shell/chat-screen-loaded?])
{:keys [chat-id
contact-request-state
group-chat
able-to-send-message?
chat-type]
:as chat} (rf/sub [:chats/current-chat-chat-view])]
(when (seq chat)
(if able-to-send-message?
[:f> f-composer
{:insets insets
:scroll-to-bottom-fn scroll-to-bottom-fn
:show-floating-scroll-down-button? show-floating-scroll-down-button?}]
[contact-requests.bottom-drawer/view chat-id contact-request-state group-chat])))
[composer-placeholder]))

43 changes: 24 additions & 19 deletions src/status_im2/contexts/chat/messages/list/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,30 @@
(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
big-name-visible? animate-topbar-opacity? composer-active?
on-end-reached? animate-topbar-name?]}]
(rn/use-effect (fn []
(if (and (not @on-end-reached?)
(< topbar-visible-scroll-y-value (reanimated/get-shared-value scroll-y)))
(reset! animate-topbar-opacity? true)
(reset! animate-topbar-opacity? false)))
[composer-active? @on-end-reached? @animate-topbar-opacity?])
(let [theme (quo.theme/use-theme-value)
{window-height :height} (rn/get-window)
{:keys [keyboard-height]} (hooks/use-keyboard)
context (rf/sub [:chats/current-chat-message-list-view-context])
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)])
[{:keys [insets scroll-y content-height cover-bg-color inner-state-atoms composer-active?]}]
(let [theme (quo.theme/use-theme-value)
chat (rf/sub [:chats/current-chat-chat-view])
{composer-active? :focused?} (rf/sub [:chats/current-chat-input])
{:keys [keyboard-shown]} (hooks/use-keyboard)
{window-height :height} (rn/get-window)
{:keys [keyboard-height]} (hooks/use-keyboard)
context (rf/sub [:chats/current-chat-message-list-view-context])
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)])
{:keys [show-floating-scroll-down-button?
messages-view-height
messages-view-header-height]} inner-state-atoms]
messages-view-header-height
big-name-visible?
animate-topbar-opacity?
on-end-reached?
animate-topbar-name?]} inner-state-atoms]
(rn/use-effect (fn []
(if (and (not @on-end-reached?)
(< topbar-visible-scroll-y-value (reanimated/get-shared-value scroll-y)))
(reset! animate-topbar-opacity? true)
(reset! animate-topbar-opacity? false)))
[composer-active? @on-end-reached? @animate-topbar-opacity?])
[rn/view {:style {:flex 1}}
[rnio/flat-list
{:root-margin root-margin-for-big-name-visibility-detector
Expand All @@ -340,7 +345,7 @@
:data messages
:render-data {:theme theme
:context context
:keyboard-shown? keyboard-shown?
:keyboard-shown? keyboard-shown
:insets insets}
:render-fn render-fn
:on-viewable-items-changed on-viewable-items-changed
Expand Down Expand Up @@ -372,7 +377,7 @@
(reanimated/set-shared-value scroll-y
(- y
window-height
(- (when keyboard-shown?
(- (when keyboard-shown
keyboard-height))))
(reanimated/set-shared-value content-height y))))
:on-end-reached #(list-on-end-reached scroll-y on-end-reached?)
Expand Down
6 changes: 2 additions & 4 deletions src/status_im2/contexts/chat/messages/navigation/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@
{:opacity animation})
blur-view))

(defn navigation-view
[loaded?]
(def navigation-view
{:z-index 1
:top 0
:right 0
:left 0
:position :absolute
:opacity (if loaded? 1 0)})
:position :absolute})

(def header-container
{:position :absolute
Expand Down
44 changes: 38 additions & 6 deletions src/status_im2/contexts/chat/messages/navigation/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[react-native.reanimated :as reanimated]
[status-im2.common.home.actions.view :as actions]
[status-im2.config :as config]
[status-im2.constants :as constants]
[status-im2.contexts.chat.messages.list.view :refer [topbar-invisible-scroll-y-value]]
[status-im2.contexts.chat.messages.navigation.style :as style]
[status-im2.contexts.chat.messages.pin.banner.view :as pin.banner]
Expand All @@ -23,10 +24,34 @@
(defonce ^:const minimum-scroll-y-topbar-overlaying-avatar-composer-active 85)

(defn f-view
[{:keys [theme scroll-y chat chat-screen-loaded? all-loaded? display-name online? photo-path
back-icon animate-topbar-name? composer-active? big-name-visible? animate-topbar-opacity?
on-end-reached?]}]
(let [{:keys [group-chat chat-id]} chat
[{:keys [theme scroll-y inner-state-atoms]}]
(let [{:keys [chat-id
contact-request-state
group-chat
able-to-send-message?
chat-type
chat-name
emoji]
:as chat} (rf/sub [:chats/current-chat-chat-view])
{:keys [animate-topbar-name? big-name-visible?
animate-topbar-opacity?
on-end-reached?]} inner-state-atoms
content-height (reanimated/use-shared-value 0)
all-loaded? (rf/sub [:chats/all-loaded? (:chat-id chat)])
{composer-active? :focused?} (rf/sub [:chats/current-chat-input])
display-name (cond
(= chat-type constants/one-to-one-chat-type)
(first (rf/sub
[:contacts/contact-two-names-by-identity
chat-id]))
(= chat-type constants/community-chat-type)
(str (when emoji (str emoji " ")) "# " chat-name)
:else (str emoji chat-name))
online? (rf/sub [:visibility-status-updates/online? chat-id])
photo-path (rf/sub [:chats/photo-path chat-id])
back-icon (if (= chat-type constants/one-to-one-chat-type)
:i/close
:i/arrow-left)
opacity-animation (reanimated/use-shared-value 0)
banner-opacity-animation (reanimated/interpolate
scroll-y
Expand Down Expand Up @@ -97,7 +122,7 @@
(reanimated/animate translate-animation title-opacity-interpolation-start))))
[@animate-topbar-name? @big-name-visible? @animate-topbar-opacity? composer-active?
@on-end-reached?])
[rn/view {:style (style/navigation-view chat-screen-loaded?)}
[rn/view {:style style/navigation-view}
[reanimated/view
{:style (style/animated-background-view all-loaded? opacity-animation nil)}]

Expand All @@ -109,6 +134,7 @@
:blur-radius (if platform/ios? 20 10)
:style {:flex 1}}]]

;; Extract header view content in different function and use in placeholder
[rn/view {:style style/header-container}
[quo/button
{:icon-only? true
Expand Down Expand Up @@ -165,8 +191,14 @@
:all-loaded? all-loaded?
:top-offset style/navigation-bar-height}]]))

(defn navigation-placeholder []
[rn/view {:style {:width 100 :height 100 :background-color :red :position :absolute :top 0}}])

(defn- internal-navigation-view
[params]
[:f> f-view params])
(let [chat-screen-loaded? (rf/sub [:shell/chat-screen-loaded?])]
(if chat-screen-loaded?
[:f> f-view params]
[navigation-placeholder])))

(def navigation-view (quo.theme/with-theme internal-navigation-view))
Loading

0 comments on commit ad28663

Please sign in to comment.