implementation uses scroll-view

This commit is contained in:
Ulises M 2024-11-22 16:46:06 -06:00
parent b78d987cc5
commit 87cafabddc
No known key found for this signature in database
GPG Key ID: 5A15782EB758534E
1 changed files with 21 additions and 22 deletions

View File

@ -10,25 +10,27 @@
[status-im.contexts.chat.messenger.messages.constants :as messages.constants]
[utils.re-frame :as rf]))
(defn mention-item
[user]
[contact-list-item/contact-list-item
{:on-press #(rf/dispatch [:chat.ui/select-mention user])}
user])
(defn- mention-item
[[user-key user]]
(with-meta
[contact-list-item/contact-list-item {:on-press #(rf/dispatch [:chat.ui/select-mention user])}
user]
{:key user-key}))
(defn view
[layout-height]
(let [suggestions (rf/sub [:chat/mention-suggestions])
suggestions? (seq suggestions)
theme (quo.theme/use-theme)
opacity (reanimated/use-shared-value (if suggestions? 1 0))
[suggestions-state set-suggestions-state] (rn/use-state suggestions)
top (min constants/mentions-max-height
(* (count suggestions-state) 56)
(- @layout-height
(+ (safe-area/get-top)
messages.constants/top-bar-height
5)))]
(let [suggestions (rf/sub [:chat/mention-suggestions])
suggestions? (seq suggestions)
theme (quo.theme/use-theme)
opacity (reanimated/use-shared-value (if suggestions? 1 0))
[suggestions-state
set-suggestions-state] (rn/use-state suggestions)
top (min constants/mentions-max-height
(* (count suggestions-state) 56)
(- @layout-height
(+ (safe-area/get-top)
messages.constants/top-bar-height
5)))]
(rn/use-effect
(fn []
(if suggestions?
@ -37,9 +39,6 @@
(reanimated/animate opacity (if suggestions? 1 0)))
[suggestions])
[reanimated/view {:style (style/container opacity top theme)}
[reanimated/flat-list
{:keyboard-should-persist-taps :always
:data (vals suggestions-state)
:key-fn :key
:render-fn mention-item
:accessibility-label :mentions-list}]]))
[rn/scroll-view {:accessibility-label :mentions-list
:keyboard-should-persist-taps :always}
(map mention-item suggestions-state)]]))