Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: activity centre animations #15262

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@
<item name="android:textColorPrimary">@color/alert_text</item>
<item name="android:background">@color/alert_background</item>
</style>

<style name="Theme.FullScreenDialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"react-native-linear-gradient": "^2.5.6",
"react-native-lottie-splash-screen": "^1.0.1",
"react-native-mail": "^6.1.1",
"react-native-modal": "^13.0.1",
"react-native-navigation": "^7.27.1",
"react-native-orientation-locker": "^1.5.0",
"react-native-permissions": "^2.1.5",
Expand Down
4 changes: 4 additions & 0 deletions src/mocks/js_dependencies.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ globalThis.__STATUS_MOBILE_JS_IDENTITY_PROXY__ = new Proxy({}, {get() { return (
(clj->js {:default #js {}
:useDeviceOrientationChange #js {}}))

(def react-native-modal
(clj->js {:default #js {}}))

(def wallet-connect-client
#js
{:default #js {}
Expand Down Expand Up @@ -404,6 +407,7 @@ globalThis.__STATUS_MOBILE_JS_IDENTITY_PROXY__ = new Proxy({}, {get() { return (
"@react-native-async-storage/async-storage" async-storage
"react-native-svg" react-native-svg
"react-native-orientation-locker" react-native-orientation-locker
"react-native-modal" react-native-modal
"../src/js/worklet_factory.js" worklet-factory
"../src/js/shell_worklets.js" shell-worklets
"../src/js/bottom_sheet.js" bottom-sheet
Expand Down
4 changes: 3 additions & 1 deletion src/react_native/core.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns react-native.core
(:require ["react" :as react]
["react-native" :as react-native]
["react-native-modal" :default Modal]
[cljs-bean.core :as bean]
[oops.core :as oops]
[react-native.flat-list :as flat-list]
Expand Down Expand Up @@ -31,7 +32,8 @@

(def activity-indicator (reagent/adapt-react-class (.-ActivityIndicator ^js react-native)))

(def modal (reagent/adapt-react-class (.-Modal ^js react-native)))
;; "react-native-modal" is a superset to the Modal component from RN, no need to define it separately
(def modal (reagent/adapt-react-class Modal))

(def keyboard ^js (.-Keyboard ^js react-native))

Expand Down
44 changes: 40 additions & 4 deletions src/status_im2/common/home/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.hole-view :as hole-view]
[react-native.navigation :as navigation]
[reagent.core :as reagent]
[status-im2.common.home.style :as style]
[status-im2.common.plus-button.view :as components.plus-button]
[status-im2.contexts.activity-center.view :as ac]
[status-im2.contexts.shell.animation :as shell]
[utils.re-frame :as rf]))

(defn title-column
Expand Down Expand Up @@ -39,6 +43,29 @@
button-common-props)
icon])


(defn ac-modal
[visible? view-id]
(let [status-bar-style (if (or (colors/dark?)
(not (shell/home-stack-open?)))
:light
:dark)
close-modal (fn []
(reset! visible? false)
(navigation/merge-options (clj->js view-id)
(clj->js {:statusBar {:style status-bar-style}})))]
[rn/modal
{:visible @visible?
:cover-screen true
:transparent true
:status-bar-translucent true
:hardware-accelerated true
:animation-type :slide
:style {:margin 0
:width "100%"}
:on-back-button-press close-modal}
[ac/view close-modal]]))

(defn top-nav
"[top-nav opts]
opts
Expand All @@ -51,8 +78,18 @@
notif-count (rf/sub [:activity-center/unread-count])
new-notifications? (pos? notif-count)
notification-indicator :unread-dot
counter-label "0"]
counter-label "0"
visible? (reagent/atom false)
view-id (rf/sub [:view-id])
open-ac (fn []
;; delaying status-bar style update looks nicer
(js/setTimeout
#(navigation/merge-options (clj->js view-id)
(clj->js {:statusBar {:style :light}}))
20)
(reset! visible? (not @visible?)))]
[rn/view {:style (assoc style :height 56)}
[ac-modal visible? view-id]
;; Left Section
[rn/touchable-without-feedback {:on-press #(rf/dispatch [:navigate-to :my-profile])}
[rn/view
Expand All @@ -75,7 +112,7 @@
[base-button :i/search #() :open-search-button button-common-props])
[base-button :i/scan #() :open-scanner-button button-common-props]
[base-button :i/qr-code #() :show-qr-button button-common-props]
[rn/view ;; Keep view instead of "[:<>" to make sure relative
[rn/view ;; Keep view instead of "[:<>" to make sure relative
;; position is calculated from this view instead of its parent
[hole-view/hole-view
{:key new-notifications? ;; Key is required to force removal of holes
Expand All @@ -88,8 +125,7 @@

:else
[{:x 33 :y -7 :width 18 :height 18 :borderRadius 7}])}
[base-button :i/activity-center #(rf/dispatch [:activity-center/open])
:open-activity-center-button button-common-props]]
[base-button :i/activity-center open-ac :open-activity-center-button button-common-props]]
(when new-notifications?
(if (= notification-indicator :counter)
[quo/counter
Expand Down
25 changes: 24 additions & 1 deletion src/status_im2/contexts/activity_center/style.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns status-im2.contexts.activity-center.style
(:require [quo2.foundations.colors :as colors]))
(:require [quo2.foundations.colors :as colors]
[react-native.platform :as platform]))

(def screen-padding 20)

Expand Down Expand Up @@ -60,3 +61,25 @@
:height 120
:background-color colors/danger-50
:margin-bottom 20})

(def blur-background
{:position :absolute
:background-color colors/neutral-80-opa-80
:top 0
:bottom 0
:left 0
:right 0})

(defn options-content-container
[bottom-inset]
{:background-color colors/neutral-100
:padding-bottom (if platform/ios? bottom-inset 20)
:padding-top 20
:border-top-left-radius 20
:border-top-right-radius 20})

(def options-modal-container
{:justify-content :flex-end
:margin 0
:width "100%"
:align-self :center})
74 changes: 48 additions & 26 deletions src/status_im2/contexts/activity_center/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im2.contexts.activity-center.notification-types :as types]
[status-im2.contexts.activity-center.notification.admin.view :as admin]
[status-im2.contexts.activity-center.notification.contact-requests.view :as contact-requests]
Expand All @@ -14,6 +15,7 @@
[status-im2.contexts.activity-center.notification.reply.view :as reply]
[status-im2.contexts.activity-center.style :as style]
[utils.i18n :as i18n]
[react-native.blur :as blur]
[utils.re-frame :as rf]))

(defn filter-selector-read-toggle
Expand All @@ -28,27 +30,44 @@
:all
:unread)}])}]))

(defn options-bottom-sheet-content
[]

(defn options-content
[bottom-inset]
(let [unread-count (rf/sub [:activity-center/unread-count])]
[quo/action-drawer
[[{:icon :i/check
:override-theme :dark
:label (i18n/label :t/mark-all-notifications-as-read)
:on-press (fn []
(if (pos? unread-count)
(rf/dispatch [:activity-center.notifications/mark-all-as-read-locally
(fn []
{:icon :up-to-date
:icon-color colors/success-50
:text (i18n/label :t/notifications-marked-as-read
{:count unread-count})
:override-theme :dark})])
;; Need design improvements if there is NO unread
;; notifications to mark as read
;; https://github.com/status-im/status-mobile/issues/14983
(js/alert "No unread notifications to mark as read"))
(rf/dispatch [:bottom-sheet/hide]))}]]]))
[rn/view
{:style (style/options-content-container bottom-inset)}
[quo/action-drawer
[[{:icon :i/check
:override-theme :dark
:label (i18n/label :t/mark-all-notifications-as-read)
:on-press (fn []
(if (pos? unread-count)
(rf/dispatch [:activity-center.notifications/mark-all-as-read-locally
(fn []
{:icon :up-to-date
:icon-color colors/success-50
:text (i18n/label :t/notifications-marked-as-read
{:count unread-count})
:override-theme :dark})])
;; Need design improvements if there is NO unread
;; notifications to mark as read
;; https://github.com/status-im/status-mobile/issues/14983
(js/alert "No unread notifications to mark as read"))
(rf/dispatch [:bottom-sheet/hide]))}]]]]))

(defn options-bottom-sheet
[visible? bottom-inset]
;; not using the `bottom-sheet` component as it renders behind the full screen `Modal` component on
;; Android
[rn/modal
{:is-visible @visible?
:use-native-driver true
:use-native-driver-for-backdrop true
:hide-modal-content-while-animating true
:backdrop-opacity 0.5
:on-backdrop-press #(reset! visible? false)
:style style/options-modal-container}
[options-content bottom-inset]])

(defn empty-tab
[]
Expand Down Expand Up @@ -134,7 +153,7 @@
(contains? types-with-unread types/system))}]}]))

(defn header
[request-close]
[request-close open-options]
[rn/view
[rn/view {:style style/header-container}
[quo/button
Expand All @@ -151,9 +170,7 @@
:size 32
:accessibility-label :activity-center-open-more
:override-theme :dark
:on-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content options-bottom-sheet-content
:override-theme :dark}])}
:on-press open-options}
:i/options]]
[quo/text
{:size :heading-1
Expand Down Expand Up @@ -203,7 +220,8 @@

(defn view
[request-close]
(let [active-swipeable (atom nil)]
(let [active-swipeable (atom nil)
visible? (reagent/atom false)]
[:f>
(fn []
(rn/use-effect-once #(rf/dispatch [:activity-center.notifications/fetch-first-page]))
Expand All @@ -212,7 +230,11 @@
(let [notifications (rf/sub [:activity-center/notifications])
window-width (rf/sub [:dimensions/window-width])]
[rn/view {:style (style/screen-container window-width top bottom)}
[header request-close]
[blur/view
{:blurAmount 5
:style style/blur-background}]
[options-bottom-sheet visible? bottom]
[header request-close #(reset! visible? true)]
[rn/flat-list
{:data notifications
:render-data active-swipeable
Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9330,6 +9330,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-2.0.0.tgz#71d9c4cde47114c4102454f76da055c2bc48c948"
integrity sha512-txfpPCQYiazVdcbMRhatqWKcAxJweUu2wDXvts5/7Wyp6+Y9cHojqXHsLPEckzutfHlxZhG8Oiundbmp8Fd6eQ==

[email protected]:
version "1.3.3"
resolved "https://registry.yarnpkg.com/react-native-animatable/-/react-native-animatable-1.3.3.tgz#a13a4af8258e3bb14d0a9d839917e9bb9274ec8a"
integrity sha512-2ckIxZQAsvWn25Ho+DK3d1mXIgj7tITkrS4pYDvx96WyOttSvzzFeQnM2od0+FUMzILbdHDsDEqZvnz1DYNQ1w==
dependencies:
prop-types "^15.7.2"

react-native-background-timer@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/react-native-background-timer/-/react-native-background-timer-2.2.0.tgz#ff82d30899209b924983cc00e6ce174b8de5054a"
Expand Down Expand Up @@ -9458,6 +9465,14 @@ react-native-mail@^6.1.1:
resolved "https://registry.yarnpkg.com/react-native-mail/-/react-native-mail-6.1.1.tgz#f1b1f8034c84d2510a93e4a2a795f0db5a13595e"
integrity sha512-pTs180wwyh7hN/iyTC9SfOX579U4YhDlHOLxi47IGvhPJENqO/QFdBq+wWKxyhNqdQuVSy+LoeIxLreWnIeYmg==

react-native-modal@^13.0.1:
version "13.0.1"
resolved "https://registry.yarnpkg.com/react-native-modal/-/react-native-modal-13.0.1.tgz#691f1e646abb96fa82c1788bf18a16d585da37cd"
integrity sha512-UB+mjmUtf+miaG/sDhOikRfBOv0gJdBU2ZE1HtFWp6UixW9jCk/bhGdHUgmZljbPpp0RaO/6YiMmQSSK3kkMaw==
dependencies:
prop-types "^15.6.2"
react-native-animatable "1.3.3"

react-native-navigation@^7.27.1:
version "7.27.1"
resolved "https://registry.yarnpkg.com/react-native-navigation/-/react-native-navigation-7.27.1.tgz#90bfac2a400109cc036394b4ee807a997da6a7b4"
Expand Down