Double-tap for communities & fix for 'Recent' tab not being shown as selected if message icon is double tapped (#15844)

* Updates

* Small namespace fix
This commit is contained in:
Alexander 2023-05-11 18:17:50 +02:00 committed by GitHub
parent 3c278ed06c
commit c71224e73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 53 deletions

View File

@ -62,7 +62,8 @@
[status-im2.common.theme.core :as theme]
[react-native.core :as rn]
[react-native.platform :as platform]
status-im2.contexts.chat.home.events))
status-im2.contexts.chat.home.events
status-im2.contexts.communities.home.events))
(re-frame/reg-fx
:dismiss-keyboard

View File

@ -102,7 +102,8 @@
[]
(fn []
(let [pending-contact-requests (rf/sub [:activity-center/pending-contact-requests])
selected-tab (or (rf/sub [:messages-home/selected-tab]) :tab/recent)
selected-tab (or (rf/sub [:messages-home/selected-tab])
:tab/recent)
top (safe-area/get-top)]
[:<>
(if (= selected-tab :tab/contacts)
@ -122,6 +123,7 @@
[quo/discover-card
{:title (i18n/label :t/invite-friends-to-status)
:description (i18n/label :t/share-invite-link)}]
^{:key (str "tabs-" selected-tab)}
[quo/tabs
{:style style/tabs
:size 32

View File

@ -0,0 +1,8 @@
(ns status-im2.contexts.communities.home.events
(:require
[utils.re-frame :as rf]))
(rf/defn communities-select-tab-event
{:events [:communities/select-tab]}
[{:keys [db]} tab]
{:db (assoc db :communities/selected-tab tab)})

View File

@ -1,7 +1,6 @@
(ns status-im2.contexts.communities.home.view
(:require [utils.i18n :as i18n]
[quo2.core :as quo]
[reagent.core :as reagent]
[react-native.core :as rn]
[status-im2.common.home.view :as common.home]
[status-im2.contexts.communities.actions.community-options.view :as options]
@ -35,10 +34,10 @@
(defn home
[]
(let [selected-tab (reagent/atom :joined)]
(fn []
(let [{:keys [joined pending opened]} (rf/sub [:communities/grouped-by-status])
selected-items (case @selected-tab
(let [selected-tab (or (rf/sub [:communities/selected-tab]) :joined)
{:keys [joined pending opened]} (rf/sub [:communities/grouped-by-status])
selected-items (case selected-tab
:joined joined
:pending pending
:opened opened)
@ -66,9 +65,11 @@
:title (i18n/label :t/discover)
:description (i18n/label :t/whats-trending)
:accessibility-label :communities-home-discover-card}]
^{:key (str "tabs-" selected-tab)}
[quo/tabs
{:size 32
:style style/tabs
:on-change #(reset! selected-tab %)
:default-active @selected-tab
:data tabs-data}]]]))))
:on-change (fn [tab]
(rf/dispatch [:communities/select-tab tab]))
:default-active selected-tab
:data tabs-data}]]])))

View File

@ -38,6 +38,11 @@
animated-style (reanimated/apply-animations-to-style
{:height (:bottom-tabs-height shared-values)}
original-style)
communities-double-tab-gesture (-> (gesture/gesture-tap)
(gesture/number-of-taps 2)
(gesture/on-start
(fn [_event]
(rf/dispatch [:communities/select-tab :joined]))))
messages-double-tap-gesture (-> (gesture/gesture-tap)
(gesture/number-of-taps 2)
(gesture/on-start
@ -49,7 +54,8 @@
(when pass-through?
[blur/view (blur-overlay-params style/bottom-tabs-blur-overlay)])
[rn/view {:style (style/bottom-tabs)}
[bottom-tab :i/communities :communities-stack shared-values notifications-data]
[gesture/gesture-detector {:gesture communities-double-tab-gesture}
[bottom-tab :i/communities :communities-stack shared-values notifications-data]]
[gesture/gesture-detector {:gesture messages-double-tap-gesture}
[bottom-tab :i/messages :chats-stack shared-values notifications-data]]
[bottom-tab :i/wallet :wallet-stack shared-values notifications-data]

View File

@ -249,6 +249,7 @@
(reg-root-key-sub :communities/resolve-community-info :communities/resolve-community-info)
(reg-root-key-sub :communities/my-pending-requests-to-join :communities/my-pending-requests-to-join)
(reg-root-key-sub :communities/collapsed-categories :communities/collapsed-categories)
(reg-root-key-sub :communities/selected-tab :communities/selected-tab)
(reg-root-key-sub :activity-center :activity-center)