From b7948b98699babbb317b7486d83910d5b2e33044 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 30 Oct 2020 07:17:38 +0100 Subject: [PATCH] navigate to home when press chat tab on chat screen --- src/status_im/ui/components/tabbar/core.cljs | 32 +++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/status_im/ui/components/tabbar/core.cljs b/src/status_im/ui/components/tabbar/core.cljs index 65b1a52493..a02bb509ae 100644 --- a/src/status_im/ui/components/tabbar/core.cljs +++ b/src/status_im/ui/components/tabbar/core.cljs @@ -75,16 +75,16 @@ (def tabs (reagent/adapt-react-class (fn [props] - (let [{:keys [navigate index route state]} (bean props) + (let [{:keys [navigate index route state popToTop]} (bean props) {:keys [keyboard-shown] :or {keyboard-shown false}} (when platform/android? (rn/use-keyboard)) - {:keys [bottom]} (safe-area/use-safe-area) - animated-visible (animated/use-timing-transition - (main-tab? (keyword route)) - {:duration 150}) - keyboard-visible (animated/use-timing-transition - keyboard-shown - {:duration 200})] + {:keys [bottom]} (safe-area/use-safe-area) + animated-visible (animated/use-timing-transition + (main-tab? (keyword route)) + {:duration 150}) + keyboard-visible (animated/use-timing-transition + keyboard-shown + {:duration 200})] (reagent/as-element [animated/view {:style (tabs.styles/tabs-wrapper keyboard-shown keyboard-visible) :pointer-events (if keyboard-shown "none" "auto")} @@ -99,10 +99,12 @@ [tab {:icon icon :label title - :on-press #(let [view-id (navigation/get-index-route-name route-index (bean state))] - (re-frame/dispatch-sync [:screens/tab-will-change view-id]) - (reagent/flush) - (navigate (name nav-stack))) + :on-press #(if (= (str index) (str route-index)) + (popToTop) + (let [view-id (navigation/get-index-route-name route-index (bean state))] + (re-frame/dispatch-sync [:screens/tab-will-change view-id]) + (reagent/flush) + (navigate (name nav-stack)))) :accessibility-label accessibility-label :count-subscription count-subscription :active? (= (str index) (str route-index)) @@ -112,10 +114,12 @@ (defn tabbar [props] (let [navigate (oget props "navigation" "navigate") - state (bean (oget props "state")) - index (get state :index)] + pop-to-top (oget props "navigation" "popToTop") + state (bean (oget props "state")) + index (get state :index)] (reagent/as-element [tabs {:navigate navigate :state (oget props "state") + :popToTop pop-to-top :route (navigation/get-active-route-name state) :index index}])))