From 2295b01bc9e72b9daab0b2b9bcee9528f8a8c328 Mon Sep 17 00:00:00 2001 From: Lungu Cristian Date: Tue, 19 Mar 2024 16:23:36 +0200 Subject: [PATCH] Fix drawer message according to desings (#19056) * fix: bottom-sheet's selected-item was not visible Signed-off-by: Cristian Lungu * fix: drawer message spacings and removed emojis & identicon Signed-off-by: Cristian Lungu * fix: bottom-sheet use-callback dependencies Signed-off-by: Cristian Lungu * fix: added :profile/public-key sub Signed-off-by: Cristian Lungu * test: added :profile/public-key sub test Signed-off-by: Cristian Lungu * fix: spacings & added reactions to message drawer Signed-off-by: Cristian Lungu --------- Signed-off-by: Cristian Lungu --- src/status_im/common/bottom_sheet/view.cljs | 40 ++++++++++++------- .../messenger/messages/content/style.cljs | 4 ++ .../chat/messenger/messages/content/view.cljs | 24 +++++------ src/status_im/subs/profile.cljs | 8 ++++ src/status_im/subs/profile_test.cljs | 6 +++ 5 files changed, 55 insertions(+), 27 deletions(-) diff --git a/src/status_im/common/bottom_sheet/view.cljs b/src/status_im/common/bottom_sheet/view.cljs index 4677b9a2d2..62c163a6ce 100644 --- a/src/status_im/common/bottom_sheet/view.cljs +++ b/src/status_im/common/bottom_sheet/view.cljs @@ -66,26 +66,35 @@ gradient-cover? customization-color hide-handle? blur-radius] :or {border-radius 12}}] (let [theme (quo.theme/use-theme-value) - sheet-height (rn/use-ref-atom 0) - item-height (rn/use-ref-atom 0) - set-sheet-height (rn/use-callback #(reset! sheet-height (get-layout-height %))) - set-item-height (rn/use-callback #(reset! item-height (get-layout-height %))) + [sheet-height set-sheet-height] (rn/use-state 0) + handle-sheet-height (rn/use-callback (fn [e] + (when (= sheet-height 0) + (set-sheet-height + (get-layout-height e)))) + [sheet-height]) + [item-height set-item-height] (rn/use-state 0) + handle-item-height (rn/use-callback (fn [e] + (when (= item-height 0) + (set-item-height + (get-layout-height e)))) + [item-height]) {window-height :height} (rn/get-window) bg-opacity (reanimated/use-shared-value 0) translate-y (reanimated/use-shared-value window-height) - sheet-gesture (get-sheet-gesture translate-y - bg-opacity - window-height - on-close) - selected-item-smaller-than-sheet? (< @item-height + sheet-gesture (rn/use-memo #(get-sheet-gesture translate-y + bg-opacity + window-height + on-close) + [window-height on-close]) + selected-item-smaller-than-sheet? (< item-height (- window-height - @sheet-height + sheet-height (:top insets) (:bottom insets) bottom-margin)) - top (- window-height (:top insets) @sheet-height) + top (- window-height (:top insets) sheet-height) bottom (if selected-item-smaller-than-sheet? - (+ @sheet-height bottom-margin) + (+ sheet-height bottom-margin) (:bottom insets)) sheet-max-height (- window-height (:top insets)) content-padding-bottom (or padding-bottom-override @@ -123,11 +132,12 @@ :overlay-color :transparent}]) (when selected-item [rn/view - {:on-layout set-item-height - :style (style/selected-item theme top bottom selected-item-smaller-than-sheet? border-radius)} + {:on-layout handle-item-height + :style + (style/selected-item theme top bottom selected-item-smaller-than-sheet? border-radius)} [selected-item]]) [rn/view - {:on-layout set-sheet-height + {:on-layout handle-sheet-height :style (style/sheet-content {:theme theme :shell? shell? :padding-bottom content-padding-bottom})} diff --git a/src/status_im/contexts/chat/messenger/messages/content/style.cljs b/src/status_im/contexts/chat/messenger/messages/content/style.cljs index d89e9030b8..ff2f396fd9 100644 --- a/src/status_im/contexts/chat/messenger/messages/content/style.cljs +++ b/src/status_im/contexts/chat/messenger/messages/content/style.cljs @@ -31,3 +31,7 @@ :opacity (if (and outgoing (= outgoing-status :sending)) 0.5 1)}) + +(def drawer-message-container + {:padding-top 4 + :padding-bottom 8}) diff --git a/src/status_im/contexts/chat/messenger/messages/content/view.cljs b/src/status_im/contexts/chat/messenger/messages/content/view.cljs index 5eeee5e046..4df9a5675c 100644 --- a/src/status_im/contexts/chat/messenger/messages/content/view.cljs +++ b/src/status_im/contexts/chat/messenger/messages/content/view.cljs @@ -77,11 +77,11 @@ (defn system-message-contact-request [{:keys [chat-id timestamp-str from]} type] - (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity chat-id]) - contact (rf/sub [:contacts/contact-by-address chat-id]) - photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id])) - customization-color (rf/sub [:profile/customization-color]) - {:keys [public-key]} (rf/sub [:profile/profile])] + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity chat-id]) + contact (rf/sub [:contacts/contact-by-address chat-id]) + photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id])) + customization-color (rf/sub [:profile/customization-color]) + public-key (rf/sub [:profile/public-key])] [quo/system-message {:type type :timestamp timestamp-str @@ -278,14 +278,14 @@ (fn [] [rn/view {:pointer-events :none - :padding-top 4} + :style style/drawer-message-container} [user-message-content - {:message-data message-data - :context context - :keyboard-shown? keyboard-shown? - :show-reactions? true - :show-user-info? true - :preview? true}]]))}])) + {:message-data message-data + :context context + :keyboard-shown? keyboard-shown? + :in-reaction-and-action-menu? true + :show-user-info? false + :show-reactions? true}]]))}])) (defn system-message? [content-type] diff --git a/src/status_im/subs/profile.cljs b/src/status_im/subs/profile.cljs index 0e6a4f3b2b..18b195d35e 100644 --- a/src/status_im/subs/profile.cljs +++ b/src/status_im/subs/profile.cljs @@ -82,12 +82,20 @@ :override-ring? override-ring? :font-file font-file}))})))) +;; DEPRECATED +;; use `:profile/public-key` instead (re-frame/reg-sub :multiaccount/public-key :<- [:profile/profile] (fn [{:keys [public-key]}] public-key)) +(re-frame/reg-sub + :profile/public-key + :<- [:profile/profile] + (fn [{:keys [public-key]}] + public-key)) + (re-frame/reg-sub :profile/webview-debug :<- [:profile/profile] diff --git a/src/status_im/subs/profile_test.cljs b/src/status_im/subs/profile_test.cljs index e3f6610248..818512712a 100644 --- a/src/status_im/subs/profile_test.cljs +++ b/src/status_im/subs/profile_test.cljs @@ -112,3 +112,9 @@ (testing "returns the symbol of the user's selected currency" (swap! rf-db/app-db #(assoc % :profile/profile sample-profile)) (is (match? "$" (rf/sub [sub-name]))))) + +(h/deftest-sub :profile/public-key + [sub-name] + (testing "returns the user's public key" + (swap! rf-db/app-db #(assoc % :profile/profile sample-profile)) + (is (match? (:public-key sample-profile) (rf/sub [sub-name])))))