Skip to content

Commit

Permalink
Hide jump-to behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Parveshdhull committed May 22, 2024
1 parent 8bd1c8d commit 728f326
Show file tree
Hide file tree
Showing 24 changed files with 141 additions and 82 deletions.
11 changes: 5 additions & 6 deletions src/status_im/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@
(when-let [chat-id (:current-chat-id db)]
(chat.state/reset-visible-item)
(rf/merge cofx
(merge
{:db (-> db
(dissoc :current-chat-id)
(assoc-in [:chat/inputs chat-id :focused?] false))
:effects.async-storage/set {:chat-id nil
:key-uid nil}})
{:db (-> db
(dissoc :current-chat-id)
(assoc-in [:chat/inputs chat-id :focused?] false))
:effects.async-storage/set {:chat-id nil
:key-uid nil}}
(link-preview/reset-all)
(delete-for-me/sync-all)
(delete-message/send-all)
Expand Down
12 changes: 7 additions & 5 deletions src/status_im/contexts/chat/group_details/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[status-im.common.home.actions.view :as actions]
[status-im.constants :as constants]
[status-im.contexts.chat.group-details.style :as style]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -179,8 +180,9 @@
:admin? admin?}
:render-fn contact-item-render
:separator [rn/view {:style {:height 4}}]}]
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color profile-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button]]))
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color profile-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button])]))
4 changes: 3 additions & 1 deletion src/status_im/contexts/chat/messenger/composer/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
[status-im.contexts.chat.messenger.composer.utils :as utils]
[status-im.contexts.chat.messenger.messages.contact-requests.bottom-drawer.view :as
contact-requests.bottom-drawer]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -95,7 +96,8 @@
(:edit subscriptions)]
[rn/view
{:style style/composer-sheet-and-jump-to-container}
[sub-view/shell-button shared-values chat-list-scroll-y window-height]
(when (ff/enabled? ::ff/shell.jump-to)
[sub-view/shell-button shared-values chat-list-scroll-y window-height])
[gesture/gesture-detector
{:gesture
(drag-gesture/drag-gesture props state animations dimensions keyboard-shown)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[status-im.constants :as constants]
[status-im.contexts.chat.messenger.messages.contact-requests.bottom-drawer.style :as style]
[status-im.contexts.shell.jump-to.constants :as jump-to.constants]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -49,10 +50,11 @@

contact-request-pending?
(i18n/label :t/contact-request-chat-pending))}]
[quo/floating-shell-button
{:jump-to
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute
:top (- jump-to.constants/floating-shell-button-height)}]]))
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute
:top (- jump-to.constants/floating-shell-button-height)}])]))
17 changes: 12 additions & 5 deletions src/status_im/contexts/chat/messenger/messages/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
[react-native.platform :as platform]
[react-native.reanimated :as reanimated]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.contexts.chat.messenger.composer.view :as composer.view]
[status-im.contexts.chat.messenger.messages.list.style :as style]
[status-im.contexts.chat.messenger.messages.list.view :as list.view]
[status-im.contexts.chat.messenger.messages.navigation.view :as messages.navigation]
[status-im.contexts.chat.messenger.placeholder.view :as placeholder.view]
[status-im.feature-flags :as ff]
[utils.re-frame :as rf]))

(defn- chat-screen
Expand All @@ -24,7 +26,7 @@
[composer.view/composer props]])))

(defn lazy-chat-screen
[chat-screen-layout-calculations-complete?]
[chat-screen-layout-calculations-complete? screen-loaded-atom?]
(let [screen-loaded? (rf/sub [:shell/chat-screen-loaded?])
distance-from-list-top (reanimated/use-shared-value 0)
chat-list-scroll-y (reanimated/use-shared-value 0)
Expand All @@ -36,16 +38,21 @@
:chat-list-scroll-y chat-list-scroll-y
:chat-screen-layout-calculations-complete?
chat-screen-layout-calculations-complete?}]
(when-not screen-loaded?
(when screen-loaded-atom?
(rn/use-mount #(reset! screen-loaded-atom? true)))
(when-not (if screen-loaded-atom? @screen-loaded-atom? screen-loaded?)
(reanimated/set-shared-value chat-screen-layout-calculations-complete? false)
(reanimated/set-shared-value distance-from-list-top 0)
(reanimated/set-shared-value chat-list-scroll-y 0))
(when screen-loaded?
(when (if screen-loaded-atom? @screen-loaded-atom? screen-loaded?)
[chat-screen props])))

(defn chat
[]
(let [chat-screen-layout-calculations-complete? (reanimated/use-shared-value false)]
(let [chat-screen-layout-calculations-complete? (reanimated/use-shared-value false)
jump-to-enabled? (ff/enabled? ::ff/shell.jump-to)
screen-loaded-atom? (when-not jump-to-enabled?
(reagent/atom false))]
[:<>
[lazy-chat-screen chat-screen-layout-calculations-complete?]
[lazy-chat-screen chat-screen-layout-calculations-complete? screen-loaded-atom?]
[placeholder.view/view chat-screen-layout-calculations-complete?]]))
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[status-im.common.contact-list.view :as contact-list]
[status-im.common.home.actions.view :as home.actions]
[status-im.contexts.communities.actions.channel-view-details.style :as style]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -69,11 +70,12 @@
(rn/use-mount (fn []
(rf/dispatch [:pin-message/load-pin-messages chat-id])))
[:<>
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button]
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button])
[quo/gradient-cover {:customization-color color :opacity 0.4}]
[quo/page-nav
{:background :blur
Expand Down
12 changes: 7 additions & 5 deletions src/status_im/contexts/communities/discover/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[status-im.common.scroll-page.view :as scroll-page]
[status-im.contexts.communities.actions.community-options.view :as options]
[status-im.contexts.communities.discover.style :as style]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -238,8 +239,9 @@
colors/neutral-95
theme))}
[discover-screen-content featured-communities theme]
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button]]))
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button])]))
7 changes: 6 additions & 1 deletion src/status_im/contexts/communities/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
status-im.contexts.communities.actions.community-options.events
status-im.contexts.communities.actions.leave.events
[status-im.contexts.communities.utils :as utils]
[status-im.feature-flags :as ff]
[status-im.navigation.events :as navigation]
[status-im.navigation.transitions :as transitions]
[taoensso.timbre :as log]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -370,7 +372,10 @@
:update-last-opened-at? true}]])
(if pop-to-root?
[:dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]]
[:dispatch [:chat/navigate-to-chat chat-id]])]}
[:dispatch
[:chat/navigate-to-chat chat-id
(when-not (ff/enabled? ::ff/shell.jump-to)
transitions/stack-slide-animation)]])]}
(when-not (get-in db [:chats chat-id :community-id])
{:db (assoc-in db [:chats chat-id :community-id] community-id)}))))

Expand Down
12 changes: 7 additions & 5 deletions src/status_im/contexts/communities/overview/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
[status-im.contexts.communities.actions.community-options.view :as options]
[status-im.contexts.communities.overview.style :as style]
[status-im.contexts.communities.utils :as communities.utils]
[status-im.feature-flags :as ff]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
Expand Down Expand Up @@ -387,8 +388,9 @@
customization-color (rf/sub [:profile/customization-color])]
[rn/view {:style style/community-overview-container}
[community-card-page-view id]
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button]]))
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button])]))
11 changes: 9 additions & 2 deletions src/status_im/contexts/onboarding/enable_notifications/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[react-native.safe-area :as safe-area]
[status-im.common.resources :as resources]
[status-im.contexts.onboarding.enable-notifications.style :as style]
[status-im.contexts.shell.jump-to.constants :as shell.constants]
[status-im.contexts.shell.jump-to.utils :as shell.utils]
[taoensso.timbre :as log]
[utils.i18n :as i18n]
Expand All @@ -26,7 +27,10 @@
[rn/view {:style (style/buttons insets)}
[quo/button
{:on-press (fn []
(shell.utils/change-selected-stack-id :communities-stack true nil)
(shell.utils/change-selected-stack-id
shell.constants/default-selected-stack
true
nil)
(rf/dispatch
[:request-permissions
{:permissions [:post-notifications]
Expand All @@ -43,7 +47,10 @@
(i18n/label :t/intro-wizard-title6)]
[quo/button
{:on-press (fn []
(shell.utils/change-selected-stack-id :communities-stack true nil)
(shell.utils/change-selected-stack-id
shell.constants/default-selected-stack
true
nil)
(rf/dispatch [:navigate-to-within-stack
[:screen/onboarding.welcome
:screen/onboarding.enable-notifications]]))
Expand Down
16 changes: 9 additions & 7 deletions src/status_im/contexts/profile/contact/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[status-im.contexts.profile.contact.actions.view :as actions]
[status-im.contexts.profile.contact.header.view :as contact-header]
[status-im.contexts.shell.jump-to.constants :as jump-to.constants]
[status-im.feature-flags :as ff]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
Expand Down Expand Up @@ -40,10 +41,11 @@
:on-press on-show-actions
:accessibility-label :contact-actions}]}}
[contact-header/view {:scroll-y scroll-y}]]
[quo/floating-shell-button
{:jump-to
{:on-press on-jump-to
:customization-color profile-customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute
:bottom jump-to.constants/floating-shell-button-height}]]))
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to
{:on-press on-jump-to
:customization-color profile-customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute
:bottom jump-to.constants/floating-shell-button-height}])]))
13 changes: 7 additions & 6 deletions src/status_im/contexts/profile/settings/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@
:on-scroll on-scroll
:bounces false
:over-scroll-mode :never}]
[quo/floating-shell-button
{:jump-to
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
(style/floating-shell-button-style insets)]]))
(when (ff/enabled? ::ff/shell.jump-to)
[quo/floating-shell-button
{:jump-to
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
(style/floating-shell-button-style insets)])]))
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[status-im.contexts.shell.jump-to.constants :as shell.constants]
[status-im.contexts.shell.jump-to.state :as state]
[status-im.contexts.shell.jump-to.utils :as utils]
[status-im.feature-flags :as ff]
[utils.re-frame :as rf]))

(defn blur-overlay-params
Expand Down Expand Up @@ -43,7 +44,8 @@
(defn f-bottom-tabs
[]
(let [notifications-data (rf/sub [:shell/bottom-tabs-notifications-data])
pass-through? (rf/sub [:shell/shell-pass-through?])
pass-through? (and (ff/enabled? ::ff/shell.jump-to)
(rf/sub [:shell/shell-pass-through?]))
shared-values @state/shared-values-atom
communities-double-tab-gesture (-> (gesture/gesture-tap)
(gesture/number-of-taps 2)
Expand All @@ -57,7 +59,9 @@
(rf/dispatch [:messages-home/select-tab :tab/recent]))))
bottom-tabs-blur-overlay-style (style/bottom-tabs-blur-overlay (:bottom-tabs-height
shared-values))]
(utils/load-stack @state/selected-stack-id)
(utils/load-stack (if (ff/enabled? ::ff/shell.jump-to)
@state/selected-stack-id
shell.constants/default-selected-stack))
(reanimated/set-shared-value (:pass-through? shared-values) pass-through?)
[quo.theme/provider :dark
[reanimated/view
Expand Down
2 changes: 2 additions & 0 deletions src/status_im/contexts/shell/jump_to/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
(def ^:const switcher-card-size 160)
(def ^:const floating-shell-button-height 44)

(def ^:const default-selected-stack :communities-stack)

;; Bottom tabs
(def ^:const bottom-tabs-container-height-android 57)
(def ^:const bottom-tabs-container-height-ios 82)
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/shell/jump_to/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
(:current-chat-id db))
(conj [:chat/close]))})
{:db (assoc db :view-id go-to-view-id)
:navigate-to [go-to-view-id (:theme db)]}))
:navigate-to [go-to-view-id (:theme db) animation]}))

(rf/defn shell-navigate-back
{:events [:shell/navigate-back]}
Expand Down
8 changes: 6 additions & 2 deletions src/status_im/contexts/shell/jump_to/shared_values.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[status-im.contexts.shell.jump-to.constants :as shell.constants]
[status-im.contexts.shell.jump-to.state :as state]
[status-im.contexts.shell.jump-to.utils :as utils]
[status-im.feature-flags :as ff]
[utils.worklets.shell :as worklets.shell]))

(defn calculate-home-stack-position
Expand Down Expand Up @@ -109,8 +110,11 @@
switcher-card-top-position (+ (safe-area/get-top) 120)
shared-values
{:selected-stack-id (reanimated/use-shared-value
(name (or @state/selected-stack-id :communities-stack)))
:home-stack-state (reanimated/use-shared-value @state/home-stack-state)}]
(name (or @state/selected-stack-id shell.constants/default-selected-stack)))
:home-stack-state (reanimated/use-shared-value
(if (ff/enabled? ::ff/shell.jump-to)
@state/home-stack-state
shell.constants/open-without-animation))}]
;; Whenever shell stack is created, calculate shared values function is called
;; Means On login and on UI reloading (like changing theme)
;; So we are also resetting bottom tabs here (disabling loading of unselected tabs),
Expand Down
4 changes: 3 additions & 1 deletion src/status_im/contexts/shell/jump_to/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[react-native.safe-area :as safe-area]
[status-im.contexts.shell.jump-to.constants :as shell.constants]
[status-im.contexts.shell.jump-to.state :as state]
[status-im.feature-flags :as ff]
[utils.re-frame :as rf]))

;;;; Helper Functions
Expand Down Expand Up @@ -118,7 +119,8 @@
;;; Navigation
(defn shell-navigation?
[view-id]
(some #{view-id} shell.constants/floating-screens))
(and (ff/enabled? ::ff/shell.jump-to)
(some #{view-id} shell.constants/floating-screens)))

(defn calculate-view-id
[]
Expand Down
Loading

0 comments on commit 728f326

Please sign in to comment.