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] [status-im2.common.theme.core :as theme]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.platform :as platform] [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 (re-frame/reg-fx
:dismiss-keyboard :dismiss-keyboard

View File

@ -102,7 +102,8 @@
[] []
(fn [] (fn []
(let [pending-contact-requests (rf/sub [:activity-center/pending-contact-requests]) (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)] top (safe-area/get-top)]
[:<> [:<>
(if (= selected-tab :tab/contacts) (if (= selected-tab :tab/contacts)
@ -122,6 +123,7 @@
[quo/discover-card [quo/discover-card
{:title (i18n/label :t/invite-friends-to-status) {:title (i18n/label :t/invite-friends-to-status)
:description (i18n/label :t/share-invite-link)}] :description (i18n/label :t/share-invite-link)}]
^{:key (str "tabs-" selected-tab)}
[quo/tabs [quo/tabs
{:style style/tabs {:style style/tabs
:size 32 :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 (ns status-im2.contexts.communities.home.view
(:require [utils.i18n :as i18n] (:require [utils.i18n :as i18n]
[quo2.core :as quo] [quo2.core :as quo]
[reagent.core :as reagent]
[react-native.core :as rn] [react-native.core :as rn]
[status-im2.common.home.view :as common.home] [status-im2.common.home.view :as common.home]
[status-im2.contexts.communities.actions.community-options.view :as options] [status-im2.contexts.communities.actions.community-options.view :as options]
@ -35,40 +34,42 @@
(defn home (defn home
[] []
(let [selected-tab (reagent/atom :joined)] (fn []
(fn [] (let [selected-tab (or (rf/sub [:communities/selected-tab]) :joined)
(let [{:keys [joined pending opened]} (rf/sub [:communities/grouped-by-status]) {:keys [joined pending opened]} (rf/sub [:communities/grouped-by-status])
selected-items (case @selected-tab selected-items (case selected-tab
:joined joined :joined joined
:pending pending :pending pending
:opened opened) :opened opened)
top (safe-area/get-top)] top (safe-area/get-top)]
[:<> [:<>
[rn/flat-list [rn/flat-list
{:key-fn :id {:key-fn :id
:content-inset-adjustment-behavior :never :content-inset-adjustment-behavior :never
:header [rn/view {:height (+ 245 top)}] :header [rn/view {:height (+ 245 top)}]
:render-fn item-render :render-fn item-render
:data selected-items}] :data selected-items}]
[rn/view [rn/view
{:style (style/blur-container top)} {:style (style/blur-container top)}
[blur/view [blur/view
{:blur-amount (if platform/ios? 20 10) {:blur-amount (if platform/ios? 20 10)
:blur-type (if (colors/dark?) :dark (if platform/ios? :light :xlight)) :blur-type (if (colors/dark?) :dark (if platform/ios? :light :xlight))
:style style/blur}] :style style/blur}]
[common.home/top-nav] [common.home/top-nav]
[common.home/title-column [common.home/title-column
{:label (i18n/label :t/communities) {:label (i18n/label :t/communities)
:handler #(rf/dispatch [:show-bottom-sheet {:content actions.home-plus/view}]) :handler #(rf/dispatch [:show-bottom-sheet {:content actions.home-plus/view}])
:accessibility-label :new-chat-button}] :accessibility-label :new-chat-button}]
[quo/discover-card [quo/discover-card
{:on-press #(rf/dispatch [:navigate-to :discover-communities]) {:on-press #(rf/dispatch [:navigate-to :discover-communities])
:title (i18n/label :t/discover) :title (i18n/label :t/discover)
:description (i18n/label :t/whats-trending) :description (i18n/label :t/whats-trending)
:accessibility-label :communities-home-discover-card}] :accessibility-label :communities-home-discover-card}]
[quo/tabs ^{:key (str "tabs-" selected-tab)}
{:size 32 [quo/tabs
:style style/tabs {:size 32
:on-change #(reset! selected-tab %) :style style/tabs
:default-active @selected-tab :on-change (fn [tab]
:data tabs-data}]]])))) (rf/dispatch [:communities/select-tab tab]))
:default-active selected-tab
:data tabs-data}]]])))

View File

@ -31,25 +31,31 @@
(defn- f-bottom-tabs (defn- f-bottom-tabs
[] []
(let [notifications-data (rf/sub [:shell/bottom-tabs-notifications-data]) (let [notifications-data (rf/sub [:shell/bottom-tabs-notifications-data])
pass-through? (rf/sub [:shell/shell-pass-through?]) pass-through? (rf/sub [:shell/shell-pass-through?])
shared-values @animation/shared-values-atom shared-values @animation/shared-values-atom
original-style (style/bottom-tabs-container pass-through?) original-style (style/bottom-tabs-container pass-through?)
animated-style (reanimated/apply-animations-to-style animated-style (reanimated/apply-animations-to-style
{:height (:bottom-tabs-height shared-values)} {:height (:bottom-tabs-height shared-values)}
original-style) original-style)
messages-double-tap-gesture (-> (gesture/gesture-tap) communities-double-tab-gesture (-> (gesture/gesture-tap)
(gesture/number-of-taps 2) (gesture/number-of-taps 2)
(gesture/on-start (gesture/on-start
(fn [_event] (fn [_event]
(rf/dispatch [:messages-home/select-tab :tab/recent]))))] (rf/dispatch [:communities/select-tab :joined]))))
messages-double-tap-gesture (-> (gesture/gesture-tap)
(gesture/number-of-taps 2)
(gesture/on-start
(fn [_event]
(rf/dispatch [:messages-home/select-tab :tab/recent]))))]
(animation/load-stack @animation/selected-stack-id) (animation/load-stack @animation/selected-stack-id)
(reanimated/set-shared-value (:pass-through? shared-values) pass-through?) (reanimated/set-shared-value (:pass-through? shared-values) pass-through?)
[reanimated/view {:style animated-style} [reanimated/view {:style animated-style}
(when pass-through? (when pass-through?
[blur/view (blur-overlay-params style/bottom-tabs-blur-overlay)]) [blur/view (blur-overlay-params style/bottom-tabs-blur-overlay)])
[rn/view {:style (style/bottom-tabs)} [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} [gesture/gesture-detector {:gesture messages-double-tap-gesture}
[bottom-tab :i/messages :chats-stack shared-values notifications-data]] [bottom-tab :i/messages :chats-stack shared-values notifications-data]]
[bottom-tab :i/wallet :wallet-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/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/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/collapsed-categories :communities/collapsed-categories)
(reg-root-key-sub :communities/selected-tab :communities/selected-tab)
(reg-root-key-sub :activity-center :activity-center) (reg-root-key-sub :activity-center :activity-center)