diff --git a/src/react_native/safe_area.cljs b/src/react_native/safe_area.cljs index 5c9309c641..2b5fc2ef1b 100644 --- a/src/react_native/safe_area.cljs +++ b/src/react_native/safe_area.cljs @@ -7,7 +7,7 @@ (defn consumer [component] [consumer-raw - (fn [insets] + (fn [^js insets] (reagent/as-element [component (js->clj insets :keywordize-keys true)]))]) diff --git a/src/status_im/chat/models/loading.cljs b/src/status_im/chat/models/loading.cljs index 878a38240d..b5edfe4147 100644 --- a/src/status_im/chat/models/loading.cljs +++ b/src/status_im/chat/models/loading.cljs @@ -7,7 +7,7 @@ [status-im.chat.models.message-list :as message-list] [taoensso.timbre :as log] [status-im.ethereum.json-rpc :as json-rpc] - [status-im.activity-center.core :as activity-center])) + [status-im2.contexts.activity-center.events :as activity-center])) (defn cursor->clock-value [^js cursor] diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index 3350d9057d..687f46811e 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -15,7 +15,7 @@ [status-im2.navigation.events :as navigation] [status-im.utils.handlers :refer [>evt]] [status-im.ui.components.emoji-thumbnail.styles :as emoji-thumbnail-styles] - [status-im.activity-center.core :as activity-center])) + [status-im2.contexts.activity-center.events :as activity-center])) (def crop-size 1000) diff --git a/src/status_im/contact/block.cljs b/src/status_im/contact/block.cljs index cc1993bc61..9dbf933c60 100644 --- a/src/status_im/contact/block.cljs +++ b/src/status_im/contact/block.cljs @@ -6,7 +6,7 @@ [status-im.data-store.contacts :as contacts-store] [status-im2.navigation.events :as navigation] [status-im.utils.types :as types] - [status-im.activity-center.core :as activity-center] + [status-im2.contexts.activity-center.events :as activity-center] [status-im.utils.fx :as fx])) (fx/defn clean-up-chat diff --git a/src/status_im/data_store/activities.cljs b/src/status_im/data_store/activities.cljs index bce20f403d..b681992dd4 100644 --- a/src/status_im/data_store/activities.cljs +++ b/src/status_im/data_store/activities.cljs @@ -1,7 +1,7 @@ (ns status-im.data-store.activities (:require [clojure.set :as set] [status-im.constants :as constants] - [status-im.activity-center.notification-types :as notification-types] + [status-im2.contexts.activity-center.notification-types :as notification-types] [status-im.data-store.messages :as messages])) (defn- rpc->type [{:keys [type name] :as chat}] diff --git a/src/status_im/data_store/activities_test.cljs b/src/status_im/data_store/activities_test.cljs index 7186ae8e37..22dbf55de8 100644 --- a/src/status_im/data_store/activities_test.cljs +++ b/src/status_im/data_store/activities_test.cljs @@ -1,7 +1,7 @@ (ns status-im.data-store.activities-test (:require [cljs.test :refer [deftest is testing]] [status-im.constants :as constants] - [status-im.activity-center.notification-types :as notification-types] + [status-im2.contexts.activity-center.notification-types :as notification-types] [status-im.data-store.activities :as store])) (def chat-id diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index 8076b2f1a5..d99e630096 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -32,7 +32,7 @@ status-im.multiaccounts.update.core [status-im.native-module.core :as status] [status-im2.navigation.events :as navigation] - status-im.activity-center.core + status-im2.contexts.activity-center.events status-im.pairing.core status-im.profile.core status-im.search.core diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index 6a8dfe4cc2..f5115865a7 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -9,7 +9,7 @@ [status-im.utils.fx :as fx] [status-im.constants :as constants] [status-im.i18n.i18n :as i18n] - [status-im.activity-center.core :as activity-center])) + [status-im2.contexts.activity-center.events :as activity-center])) (fx/defn navigate-chat-updated {:events [:navigate-chat-updated]} diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index 5e2b51a362..9b87818615 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -32,7 +32,7 @@ [status-im.chat.models.link-preview :as link-preview] [status-im.utils.mobile-sync :as utils.mobile-sync] [status-im.async-storage.core :as async-storage] - [status-im.activity-center.core :as activity-center] + [status-im2.contexts.activity-center.events :as activity-center] [status-im2.navigation.events :as navigation] [status-im.signing.eip1559 :as eip1559] [status-im.data-store.chats :as data-store.chats] diff --git a/src/status_im/transport/message/core.cljs b/src/status_im/transport/message/core.cljs index b7b2097763..2513405ce9 100644 --- a/src/status_im/transport/message/core.cljs +++ b/src/status_im/transport/message/core.cljs @@ -1,6 +1,6 @@ (ns ^{:doc "Definition of the StatusMessage protocol"} status-im.transport.message.core - (:require [status-im.activity-center.core :as activity-center] + (:require [status-im2.contexts.activity-center.events :as activity-center] [status-im.chat.models.message :as models.message] [status-im2.contexts.chat.messages.pin.events :as messages.pin] [status-im.chat.models :as models.chat] diff --git a/src/status_im/ui/screens/activity_center/notification/contact_request/view.cljs b/src/status_im/ui/screens/activity_center/notification/contact_request/view.cljs deleted file mode 100644 index b48b55e0e1..0000000000 --- a/src/status_im/ui/screens/activity_center/notification/contact_request/view.cljs +++ /dev/null @@ -1,53 +0,0 @@ -(ns status-im.ui.screens.activity-center.notification.contact-request.view - (:require [quo.components.animated.pressable :as animation] - [quo2.core :as quo2] - [status-im.constants :as constants] - [status-im.i18n.i18n :as i18n] - [status-im.ui.screens.activity-center.notification.common.view :as common] - [status-im.utils.datetime :as datetime] - [utils.re-frame :as rf])) - -(defn view - [{:keys [id author message last-message] :as notification}] - (let [message (or message last-message) - pressable (case (:contact-request-state message) - constants/contact-request-message-state-accepted - ;; NOTE(2022-09-21): We need to dispatch to - ;; `:contact.ui/send-message-pressed` instead of - ;; `:chat.ui/navigate-to-chat`, otherwise the chat screen - ;; looks completely broken if it has never been opened - ;; before for the accepted contact. - [animation/pressable {:on-press (fn [] - (rf/dispatch [:hide-popover]) - (rf/dispatch [:contact.ui/send-message-pressed {:public-key author}]))}] - [:<>])] - (conj pressable - [quo2/activity-log - (merge {:title (i18n/label :t/contact-request) - :icon :main-icons2/add-user - :timestamp (datetime/timestamp->relative (:timestamp notification)) - :unread? (not (:read notification)) - :context [[common/user-avatar-tag author] - (i18n/label :t/contact-request-sent)] - :message {:body (get-in message [:content :text])} - :status (case (:contact-request-state message) - constants/contact-request-message-state-accepted - {:type :positive :label (i18n/label :t/accepted)} - constants/contact-request-message-state-declined - {:type :negative :label (i18n/label :t/declined)} - nil)} - (case (:contact-request-state message) - constants/contact-request-state-mutual - {:button-1 {:label (i18n/label :t/decline) - :accessibility-label :decline-contact-request - :type :danger - :on-press (fn [] - (rf/dispatch [:contact-requests.ui/decline-request id]) - (rf/dispatch [:activity-center.notifications/mark-as-read id]))} - :button-2 {:label (i18n/label :t/accept) - :accessibility-label :accept-contact-request - :type :positive - :on-press (fn [] - (rf/dispatch [:contact-requests.ui/accept-request id]) - (rf/dispatch [:activity-center.notifications/mark-as-read id]))}} - nil))]))) diff --git a/src/status_im/ui/screens/activity_center/notification/mentions/view.cljs b/src/status_im/ui/screens/activity_center/notification/mentions/view.cljs deleted file mode 100644 index 8528116c34..0000000000 --- a/src/status_im/ui/screens/activity_center/notification/mentions/view.cljs +++ /dev/null @@ -1,48 +0,0 @@ -(ns status-im.ui.screens.activity-center.notification.mentions.view - (:require [quo.components.animated.pressable :as animation] - [quo2.core :as quo2] - [quo2.foundations.colors :as colors] - [status-im.i18n.i18n :as i18n] - [status-im.ui.screens.activity-center.notification.common.view :as common] - [status-im.ui.screens.activity-center.notification.mentions.style :as style] - [status-im.utils.datetime :as datetime] - [utils.re-frame :as rf] - [clojure.string :as string])) - -(defn message-body [message] - (let [parsed-text (get-in message [:content :parsed-text]) - parsed-text-children (:children (first parsed-text))] - (into [quo2/text {:number-of-lines 2 - :style style/tag-text - :accessibility-label :activity-message-body - :size :paragraph-1}] - (map-indexed (fn [index {:keys [type literal]}] - ^{:key index} - (case type - "mention" [quo2/text {:style style/mention-text - :size :paragraph-1} - (str "@" (rf/sub [:contacts/contact-name-by-identity literal]))] - literal)) parsed-text-children)))) - -(defn view - [{:keys [author chat-name chat-id message] :as notification}] - [animation/pressable - {:on-press (fn [] - (rf/dispatch [:hide-popover]) - (rf/dispatch [:chat.ui/navigate-to-chat chat-id]))} - [quo2/activity-log - {:title (i18n/label :t/mention) - :icon :i/mention - :timestamp (datetime/timestamp->relative (:timestamp notification)) - :unread? (not (:read notification)) - :context [[common/user-avatar-tag author] - [quo2/text {:style style/tag-text} (string/lower-case (i18n/label :t/on))] - ;; TODO (@smohamedjavid): The `group-avatar-tag` component - ;; does NOT support displaying channel name along with community/chat name. - ;; Need to update the component to support it. - [quo2/group-avatar-tag chat-name {:size :small - :override-theme :dark - :color colors/primary-50 - :style style/tag - :text-style style/tag-text}]] - :message {:body (message-body message)}}]]) diff --git a/src/status_im/ui/screens/activity_center/sheet/contact_verification.cljs b/src/status_im/ui/screens/activity_center/sheet/contact_verification.cljs deleted file mode 100644 index aab46f4eac..0000000000 --- a/src/status_im/ui/screens/activity_center/sheet/contact_verification.cljs +++ /dev/null @@ -1,9 +0,0 @@ -(ns status-im.ui.screens.activity-center.sheet.contact-verification - (:require [status-im.ui.screens.activity-center.notification.contact-verification.view :as contact-verification])) - -(defn- reply-view - [{:keys [notification replying?]}] - [contact-verification/view notification {:replying? replying?}]) - -(def reply - {:content reply-view}) diff --git a/src/status_im/ui/screens/activity_center/views.cljs b/src/status_im/ui/screens/activity_center/views.cljs deleted file mode 100644 index f0cf735094..0000000000 --- a/src/status_im/ui/screens/activity_center/views.cljs +++ /dev/null @@ -1,137 +0,0 @@ -(ns status-im.ui.screens.activity-center.views - (:require [quo.components.safe-area :as safe-area] - [quo.react :as react] - [quo.react-native :as rn] - [quo2.core :as quo2] - [quo2.foundations.colors :as colors] - [status-im.activity-center.notification-types :as types] - [status-im.i18n.i18n :as i18n] - [status-im.ui.screens.activity-center.notification.contact-request.view :as contact-request] - [status-im.ui.screens.activity-center.notification.contact-verification.view :as contact-verification] - [status-im.ui.screens.activity-center.notification.mentions.view :as mentions] - [status-im.ui.screens.activity-center.style :as style] - [utils.re-frame :as rf])) - -(defn filter-selector-read-toggle - [] - (let [unread-filter-enabled? (rf/sub [:activity-center/filter-status-unread-enabled?])] - ;; TODO(@ilmotta): Replace the button by a Filter Selector. - ;; https://github.com/status-im/status-mobile/issues/14355 - [quo2/button {:icon true - :type (if unread-filter-enabled? :primary :blur-bg-outline) - :size 32 - :override-theme :dark - :on-press #(rf/dispatch [:activity-center.notifications/fetch-first-page - {:filter-status (if unread-filter-enabled? - :all - :unread)}])} - :i/unread])) - -;; TODO(@ilmotta,2022-10-07): The empty state is still under design analysis, so we -;; shouldn't even care about translations at this point. A placeholder box is -;; used instead of an image. -(defn empty-tab - [] - [rn/view {:style {:align-items :center - :flex 1 - :justify-content :center - :padding-vertical 12}} - [rn/view {:style {:background-color colors/neutral-80 - :height 120 - :margin-bottom 20 - :width 120}}] - [quo2/text {:size :paragraph-1 - :style {:padding-bottom 2} - :weight :semi-bold} - "No notifications"] - [quo2/text {:size :paragraph-2} - "Your notifications will be here"]]) - -(defn tabs - [] - (let [filter-type (rf/sub [:activity-center/filter-type])] - [quo2/scrollable-tabs {:size 32 - :blur? true - :override-theme :dark - :style style/tabs - :fade-end-percentage 0.79 - :scroll-on-press? true - :fade-end? true - :on-change #(rf/dispatch [:activity-center.notifications/fetch-first-page {:filter-type %}]) - :default-active filter-type - :data [{:id types/no-type - :label (i18n/label :t/all)} - {:id types/admin - :label (i18n/label :t/admin)} - {:id types/mention - :label (i18n/label :t/mentions)} - {:id types/reply - :label (i18n/label :t/replies)} - {:id types/contact-request - :label (i18n/label :t/contact-requests)} - {:id types/contact-verification - :label (i18n/label :t/identity-verification)} - {:id types/tx - :label (i18n/label :t/transactions)} - {:id types/membership - :label (i18n/label :t/membership)} - {:id types/system - :label (i18n/label :t/system)}]}])) - -(defn header - [] - (let [screen-padding 20] - [rn/view - [quo2/button {:icon true - :type :blur-bg - :size 32 - :accessibility-label :close-activity-center - :override-theme :dark - :style style/header-button - :on-press #(rf/dispatch [:hide-popover])} - :i/close] - [quo2/text {:size :heading-1 - :weight :semi-bold - :style style/header-heading} - (i18n/label :t/notifications)] - [rn/view {:flex-direction :row - :padding-vertical 12} - [rn/view {:flex 1 - :align-self :stretch} - [tabs]] - [rn/view {:flex-grow 0 - :margin-left 16 - :padding-right screen-padding} - [filter-selector-read-toggle]]]])) - -(defn render-notification - [notification index] - [rn/view {:style (style/notification-container index)} - (case (:type notification) - types/contact-verification - [contact-verification/view notification {}] - - types/contact-request - [contact-request/view notification] - - types/mention - [mentions/view notification] - - nil)]) - -(defn activity-center - [] - [:f> - (fn [] - (let [notifications (rf/sub [:activity-center/filtered-notifications]) - window-width (rf/sub [:dimensions/window-width]) - {:keys [top bottom]} (safe-area/use-safe-area)] - (react/effect! #(rf/dispatch [:activity-center.notifications/fetch-first-page])) - [rn/view {:style (style/screen-container window-width top bottom)} - [header] - [rn/flat-list {:data notifications - :empty-component [empty-tab] - :key-fn :id - :on-scroll-to-index-failed identity - :on-end-reached #(rf/dispatch [:activity-center.notifications/fetch-next-page]) - :render-fn render-notification}]]))]) diff --git a/src/status_im/ui/screens/bottom_sheets/views.cljs b/src/status_im/ui/screens/bottom_sheets/views.cljs index a3782688a1..df9eed6dc0 100644 --- a/src/status_im/ui/screens/bottom_sheets/views.cljs +++ b/src/status_im/ui/screens/bottom_sheets/views.cljs @@ -2,7 +2,6 @@ (:require [quo.core :as quo] [re-frame.core :as re-frame] [status-im.ui.screens.about-app.views :as about-app] - [status-im.ui.screens.activity-center.sheet.contact-verification :as contact-verification.sheet] [status-im.ui.screens.home.sheet.views :as home.sheet] [status-im.ui.screens.keycard.views :as keycard] [status-im.ui.screens.mobile-network-settings.view :as mobile-network-settings] @@ -29,9 +28,6 @@ (= view :add-new) (merge home.sheet/add-new) - (= view :activity-center.contact-verification/reply) - (merge contact-verification.sheet/reply) - (= view :keycard.login/more) (merge keycard/more-sheet) diff --git a/src/status_im/ui/screens/popover/views.cljs b/src/status_im/ui/screens/popover/views.cljs index cde947f5a8..becb4f884b 100644 --- a/src/status_im/ui/screens/popover/views.cljs +++ b/src/status_im/ui/screens/popover/views.cljs @@ -20,7 +20,7 @@ [status-im.ui.screens.keycard.frozen-card.view :as frozen-card] [status-im.ui.screens.chat.message.pinned-message :as pinned-message] [status-im.ui.screens.signing.sheets :as signing-sheets] - [status-im.ui.screens.activity-center.views :as activity-center])) + [status-im2.contexts.activity-center.view :as activity-center])) (defn hide-panel-anim [bottom-anim-value alpha-value window-height] @@ -176,7 +176,7 @@ [signing-sheets/fees-warning] (= :activity-center view) - [activity-center/activity-center] + [activity-center/view] :else [view])]]]])))}))) diff --git a/src/status_im/ui/screens/screens.cljs b/src/status_im/ui/screens/screens.cljs index f5b80d8de6..9c202c4db1 100644 --- a/src/status_im/ui/screens/screens.cljs +++ b/src/status_im/ui/screens/screens.cljs @@ -74,7 +74,6 @@ [status-im.ui.screens.network.edit-network.views :as edit-network] [status-im.ui.screens.network.network-details.views :as network-details] [status-im.ui.screens.network.views :as network] - [status-im.ui.screens.activity-center.views :as activity-center] [status-im.ui.screens.notifications-settings.views :as notifications-settings] [status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :as @@ -232,9 +231,6 @@ {:name :stickers-pack :component stickers/pack} - {:name :activity-center - :options {:topBar {:visible false}} - :component activity-center/activity-center} ;; Community {:name :community ;;TODO custom diff --git a/src/status_im/activity_center/core.cljs b/src/status_im2/contexts/activity_center/events.cljs similarity index 99% rename from src/status_im/activity_center/core.cljs rename to src/status_im2/contexts/activity_center/events.cljs index 8a4c3b1674..13b5bd19f7 100644 --- a/src/status_im/activity_center/core.cljs +++ b/src/status_im2/contexts/activity_center/events.cljs @@ -1,9 +1,9 @@ -(ns status-im.activity-center.core +(ns status-im2.contexts.activity-center.events (:require [re-frame.core :as rf] - [status-im.activity-center.notification-types :as types] [status-im.data-store.activities :as data-store.activities] [status-im.ethereum.json-rpc :as json-rpc] [status-im.utils.fx :as fx] + [status-im2.contexts.activity-center.notification-types :as types] [taoensso.timbre :as log])) (def defaults diff --git a/src/status_im/activity_center/core_test.cljs b/src/status_im2/contexts/activity_center/events_test.cljs similarity index 99% rename from src/status_im/activity_center/core_test.cljs rename to src/status_im2/contexts/activity_center/events_test.cljs index 7c7325d0bd..eb2cf1dd0f 100644 --- a/src/status_im/activity_center/core_test.cljs +++ b/src/status_im2/contexts/activity_center/events_test.cljs @@ -1,13 +1,13 @@ -(ns status-im.activity-center.core-test +(ns status-im2.contexts.activity-center.events-test (:require [cljs.test :refer [deftest is testing]] [day8.re-frame.test :as rf-test] [re-frame.core :as rf] - [status-im.activity-center.core :as activity-center] - [status-im.activity-center.notification-types :as types] [status-im.constants :as constants] [status-im.ethereum.json-rpc :as json-rpc] status-im.events - [status-im.test-helpers :as h])) + [status-im.test-helpers :as h] + [status-im2.contexts.activity-center.events :as activity-center] + [status-im2.contexts.activity-center.notification-types :as types])) (def notification-id "0x1") diff --git a/src/status_im/ui/screens/activity_center/notification/common/style.cljs b/src/status_im2/contexts/activity_center/notification/common/style.cljs similarity index 61% rename from src/status_im/ui/screens/activity_center/notification/common/style.cljs rename to src/status_im2/contexts/activity_center/notification/common/style.cljs index 75c2c96dcc..ee2bd8c886 100644 --- a/src/status_im/ui/screens/activity_center/notification/common/style.cljs +++ b/src/status_im2/contexts/activity_center/notification/common/style.cljs @@ -1,8 +1,8 @@ -(ns status-im.ui.screens.activity-center.notification.common.style +(ns status-im2.contexts.activity-center.notification.common.style (:require [quo2.foundations.colors :as colors])) (def user-avatar-tag {:background-color colors/white-opa-10}) (def user-avatar-tag-text - {:color colors/white}) \ No newline at end of file + {:color colors/white}) diff --git a/src/status_im/ui/screens/activity_center/notification/common/view.cljs b/src/status_im2/contexts/activity_center/notification/common/view.cljs similarity index 50% rename from src/status_im/ui/screens/activity_center/notification/common/view.cljs rename to src/status_im2/contexts/activity_center/notification/common/view.cljs index 4f5ab4d6e1..d0f3458d7f 100644 --- a/src/status_im/ui/screens/activity_center/notification/common/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/common/view.cljs @@ -1,17 +1,17 @@ -(ns status-im.ui.screens.activity-center.notification.common.view - (:require [utils.re-frame :as rf] - [quo2.core :as quo2] +(ns status-im2.contexts.activity-center.notification.common.view + (:require [quo2.core :as quo] [status-im.multiaccounts.core :as multiaccounts] - [status-im.ui.screens.activity-center.notification.common.style :as style] - [status-im.ui.screens.activity-center.utils :as activity-center.utils])) + [status-im2.contexts.activity-center.notification.common.style :as style] + [status-im2.contexts.activity-center.utils :as activity-center.utils] + [utils.re-frame :as rf])) (defn user-avatar-tag [user] (let [contact (rf/sub [:contacts/contact-by-identity user])] - [quo2/user-avatar-tag + [quo/user-avatar-tag {:color :purple :override-theme :dark :size :small :style style/user-avatar-tag :text-style style/user-avatar-tag-text} (activity-center.utils/contact-name contact) - (multiaccounts/displayed-photo contact)])) \ No newline at end of file + (multiaccounts/displayed-photo contact)])) diff --git a/src/status_im2/contexts/activity_center/notification/contact_request/view.cljs b/src/status_im2/contexts/activity_center/notification/contact_request/view.cljs new file mode 100644 index 0000000000..e061f03298 --- /dev/null +++ b/src/status_im2/contexts/activity_center/notification/contact_request/view.cljs @@ -0,0 +1,55 @@ +(ns status-im2.contexts.activity-center.notification.contact-request.view + (:require [i18n.i18n :as i18n] + [quo2.core :as quo] + [react-native.core :as rn] + [status-im.constants :as constants] + [status-im.utils.datetime :as datetime] + [status-im2.contexts.activity-center.notification.common.view :as common] + [utils.re-frame :as rf])) + +(defn view + [{:keys [id author message last-message] :as notification}] + (let [message (or message last-message) + pressable (case (:contact-request-state message) + constants/contact-request-message-state-accepted + ;; NOTE(2022-09-21): We need to dispatch to + ;; `:contact.ui/send-message-pressed` instead of + ;; `:chat.ui/navigate-to-chat`, otherwise the chat screen + ;; looks completely broken if it has never been opened + ;; before for the accepted contact. + [rn/touchable-without-feedback + {:on-press (fn [] + (rf/dispatch [:hide-popover]) + (rf/dispatch [:contact.ui/send-message-pressed {:public-key author}]))}] + [:<>])] + (conj pressable + [rn/view + [quo/activity-log + (merge {:title (i18n/label :t/contact-request) + :icon :main-icons2/add-user + :timestamp (datetime/timestamp->relative (:timestamp notification)) + :unread? (not (:read notification)) + :context [[common/user-avatar-tag author] + (i18n/label :t/contact-request-sent)] + :message {:body (get-in message [:content :text])} + :status (case (:contact-request-state message) + constants/contact-request-message-state-accepted + {:type :positive :label (i18n/label :t/accepted)} + constants/contact-request-message-state-declined + {:type :negative :label (i18n/label :t/declined)} + nil)} + (case (:contact-request-state message) + constants/contact-request-state-mutual + {:button-1 {:label (i18n/label :t/decline) + :accessibility-label :decline-contact-request + :type :danger + :on-press (fn [] + (rf/dispatch [:contact-requests.ui/decline-request id]) + (rf/dispatch [:activity-center.notifications/mark-as-read id]))} + :button-2 {:label (i18n/label :t/accept) + :accessibility-label :accept-contact-request + :type :positive + :on-press (fn [] + (rf/dispatch [:contact-requests.ui/accept-request id]) + (rf/dispatch [:activity-center.notifications/mark-as-read id]))}} + nil))]]))) diff --git a/src/status_im/ui/screens/activity_center/notification/contact_verification/view.cljs b/src/status_im2/contexts/activity_center/notification/contact_verification/view.cljs similarity index 92% rename from src/status_im/ui/screens/activity_center/notification/contact_verification/view.cljs rename to src/status_im2/contexts/activity_center/notification/contact_verification/view.cljs index e18c463596..b7e7ee4f59 100644 --- a/src/status_im/ui/screens/activity_center/notification/contact_verification/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/contact_verification/view.cljs @@ -1,10 +1,10 @@ -(ns status-im.ui.screens.activity-center.notification.contact-verification.view +(ns status-im2.contexts.activity-center.notification.contact-verification.view (:require [clojure.string :as string] - [quo2.core :as quo2] + [i18n.i18n :as i18n] + [quo2.core :as quo] [status-im.constants :as constants] - [status-im.i18n.i18n :as i18n] - [status-im.ui.screens.activity-center.notification.common.view :as common] [status-im.utils.datetime :as datetime] + [status-im2.contexts.activity-center.notification.common.view :as common] [utils.re-frame :as rf])) (defn- hide-bottom-sheet-and-dispatch @@ -60,7 +60,7 @@ ;; challengee, not the challenger. ;; https://github.com/status-im/status-mobile/issues/14354 (when-not (and challenger? (= contact-verification-status constants/contact-verification-status-declined)) - [quo2/activity-log + [quo/activity-log (merge {:title (i18n/label :t/identity-verification-request) :icon :i/friend :timestamp (datetime/timestamp->relative (:timestamp notification)) @@ -101,7 +101,8 @@ {:label (i18n/label :t/message-reply) :accessibility-label :send-reply-to-contact-verification :type :primary - :on-press #(rf/dispatch [:bottom-sheet/show-sheet - :activity-center.contact-verification/reply - {:notification notification - :replying? true}])})})))]))))) + :on-press (fn [] + (rf/dispatch [:bottom-sheet/show-sheet + {:content view} + {:notification notification + :replying? true}]))})})))]))))) diff --git a/src/status_im/ui/screens/activity_center/notification/mentions/style.cljs b/src/status_im2/contexts/activity_center/notification/mentions/style.cljs similarity index 68% rename from src/status_im/ui/screens/activity_center/notification/mentions/style.cljs rename to src/status_im2/contexts/activity_center/notification/mentions/style.cljs index cea3b9a042..99ff7d7dc8 100644 --- a/src/status_im/ui/screens/activity_center/notification/mentions/style.cljs +++ b/src/status_im2/contexts/activity_center/notification/mentions/style.cljs @@ -1,4 +1,4 @@ -(ns status-im.ui.screens.activity-center.notification.mentions.style +(ns status-im2.contexts.activity-center.notification.mentions.style (:require [quo2.foundations.colors :as colors])) (def tag @@ -11,4 +11,4 @@ {:color colors/white :border-radius 6 :padding-horizontal 3 - :background-color colors/white-opa-10}) \ No newline at end of file + :background-color colors/white-opa-10}) diff --git a/src/status_im2/contexts/activity_center/notification/mentions/view.cljs b/src/status_im2/contexts/activity_center/notification/mentions/view.cljs new file mode 100644 index 0000000000..e72e5fa3b9 --- /dev/null +++ b/src/status_im2/contexts/activity_center/notification/mentions/view.cljs @@ -0,0 +1,48 @@ +(ns status-im2.contexts.activity-center.notification.mentions.view + (:require [clojure.string :as string] + [i18n.i18n :as i18n] + [quo2.core :as quo] + [quo2.foundations.colors :as colors] + [react-native.core :as rn] + [status-im.utils.datetime :as datetime] + [status-im2.contexts.activity-center.notification.common.view :as common] + [status-im2.contexts.activity-center.notification.mentions.style :as style] + [utils.re-frame :as rf])) + +(defn message-body [message] + (let [parsed-text (get-in message [:content :parsed-text]) + parsed-text-children (:children (first parsed-text))] + (into [quo/text {:number-of-lines 2 + :style style/tag-text + :accessibility-label :activity-message-body + :size :paragraph-1}] + (map-indexed (fn [index {:keys [type literal]}] + ^{:key index} + (case type + "mention" [quo/text {:style style/mention-text + :size :paragraph-1} + (str "@" (rf/sub [:contacts/contact-name-by-identity literal]))] + literal)) parsed-text-children)))) + +(defn view + [{:keys [author chat-name chat-id message] :as notification}] + [rn/touchable-without-feedback + {:on-press (fn [] + (rf/dispatch [:hide-popover]) + (rf/dispatch [:chat.ui/navigate-to-chat chat-id]))} + [quo/activity-log + {:title (i18n/label :t/mention) + :icon :i/mention + :timestamp (datetime/timestamp->relative (:timestamp notification)) + :unread? (not (:read notification)) + :context [[common/user-avatar-tag author] + [quo/text {:style style/tag-text} (string/lower-case (i18n/label :t/on))] + ;; TODO (@smohamedjavid): The `group-avatar-tag` component + ;; does NOT support displaying channel name along with community/chat name. + ;; Need to update the component to support it. + [quo/group-avatar-tag chat-name {:size :small + :override-theme :dark + :color colors/primary-50 + :style style/tag + :text-style style/tag-text}]] + :message {:body (message-body message)}}]]) diff --git a/src/status_im/activity_center/notification_types.cljs b/src/status_im2/contexts/activity_center/notification_types.cljs similarity index 59% rename from src/status_im/activity_center/notification_types.cljs rename to src/status_im2/contexts/activity_center/notification_types.cljs index da000a11db..eef259bc84 100644 --- a/src/status_im/activity_center/notification_types.cljs +++ b/src/status_im2/contexts/activity_center/notification_types.cljs @@ -1,4 +1,4 @@ -(ns status-im.activity-center.notification-types) +(ns status-im2.contexts.activity-center.notification-types) (def ^:const no-type 0) (def ^:const one-to-one-chat 1) @@ -8,11 +8,6 @@ (def ^:const contact-request 5) (def ^:const contact-verification 10) -;; TODO: Remove this constant once the old Notification Center code is removed. -;; Its value clashes with the new constant `-contact-verification` -;; used in status-go. -(def ^:const contact-request-retracted 6) - ;; TODO: Replace with correct enum values once status-go implements them. (def ^:const admin 66610) (def ^:const tx 66612) diff --git a/src/status_im/ui/screens/activity_center/style.cljs b/src/status_im2/contexts/activity_center/style.cljs similarity index 56% rename from src/status_im/ui/screens/activity_center/style.cljs rename to src/status_im2/contexts/activity_center/style.cljs index 4f688f1d81..4a1ba1c40d 100644 --- a/src/status_im/ui/screens/activity_center/style.cljs +++ b/src/status_im2/contexts/activity_center/style.cljs @@ -1,4 +1,4 @@ -(ns status-im.ui.screens.activity-center.style +(ns status-im2.contexts.activity-center.style (:require [quo2.foundations.colors :as colors])) (def screen-padding 20) @@ -26,3 +26,25 @@ (def tabs {:padding-left screen-padding}) + +(def tabs-container + {:flex 1 + :align-self :stretch}) + +(def filter-toggle-container + {:flex-grow 0 + :margin-left 16 + :padding-right screen-padding}) + +(def tabs-and-filter-container + {:flex-direction :row + :padding-vertical 12}) + +(def empty-container + {:align-items :center + :flex 1 + :justify-content :center + :padding-vertical 12}) + +(def empty-title + {:padding-bottom 2}) diff --git a/src/status_im/ui/screens/activity_center/utils.cljs b/src/status_im2/contexts/activity_center/utils.cljs similarity index 72% rename from src/status_im/ui/screens/activity_center/utils.cljs rename to src/status_im2/contexts/activity_center/utils.cljs index 60a443dbbf..c5bed982a8 100644 --- a/src/status_im/ui/screens/activity_center/utils.cljs +++ b/src/status_im2/contexts/activity_center/utils.cljs @@ -1,4 +1,4 @@ -(ns status-im.ui.screens.activity-center.utils) +(ns status-im2.contexts.activity-center.utils) (defn contact-name [contact] diff --git a/src/status_im2/contexts/activity_center/view.cljs b/src/status_im2/contexts/activity_center/view.cljs new file mode 100644 index 0000000000..6a9e54cd93 --- /dev/null +++ b/src/status_im2/contexts/activity_center/view.cljs @@ -0,0 +1,125 @@ +(ns status-im2.contexts.activity-center.view + (:require [i18n.i18n :as i18n] + [quo.react :as react] + [quo2.core :as quo] + [react-native.core :as rn] + [react-native.safe-area :as safe-area] + [status-im2.contexts.activity-center.notification-types :as types] + [status-im2.contexts.activity-center.notification.contact-request.view :as contact-request] + [status-im2.contexts.activity-center.notification.contact-verification.view :as contact-verification] + [status-im2.contexts.activity-center.notification.mentions.view :as mentions] + [status-im2.contexts.activity-center.style :as style] + [utils.re-frame :as rf])) + +(defn filter-selector-read-toggle + [] + (let [unread-filter-enabled? (rf/sub [:activity-center/filter-status-unread-enabled?])] + ;; TODO(@ilmotta): Replace the button by a Filter Selector. + ;; https://github.com/status-im/status-mobile/issues/14355 + [quo/button {:icon true + :type (if unread-filter-enabled? :primary :blur-bg-outline) + :size 32 + :override-theme :dark + :on-press #(rf/dispatch [:activity-center.notifications/fetch-first-page + {:filter-status (if unread-filter-enabled? + :all + :unread)}])} + :i/unread])) + +(defn empty-tab + [] + [rn/view {:style style/empty-container + :accessibility-label :empty-notifications} + [quo/icon :i/placeholder] + [quo/text {:size :paragraph-1 + :style style/empty-title + :weight :semi-bold} + (i18n/label :t/empty-notifications-title)] + [quo/text {:size :paragraph-2} + (i18n/label :t/empty-notifications-subtitle)]]) + +(defn tabs + [] + (let [filter-type (rf/sub [:activity-center/filter-type])] + [quo/scrollable-tabs {:size 32 + :blur? true + :override-theme :dark + :style style/tabs + :fade-end-percentage 0.79 + :scroll-on-press? true + :fade-end? true + :on-change #(rf/dispatch [:activity-center.notifications/fetch-first-page {:filter-type %}]) + :default-active filter-type + :data [{:id types/no-type + :label (i18n/label :t/all)} + {:id types/admin + :label (i18n/label :t/admin)} + {:id types/mention + :label (i18n/label :t/mentions)} + {:id types/reply + :label (i18n/label :t/replies)} + {:id types/contact-request + :label (i18n/label :t/contact-requests)} + {:id types/contact-verification + :label (i18n/label :t/identity-verification)} + {:id types/tx + :label (i18n/label :t/transactions)} + {:id types/membership + :label (i18n/label :t/membership)} + {:id types/system + :label (i18n/label :t/system)}]}])) + +(defn header + [] + [rn/view + [quo/button {:icon true + :type :blur-bg + :size 32 + :accessibility-label :close-activity-center + :override-theme :dark + :style style/header-button + :on-press #(rf/dispatch [:hide-popover])} + :i/close] + [quo/text {:size :heading-1 + :weight :semi-bold + :style style/header-heading} + (i18n/label :t/notifications)] + [rn/view {:style style/tabs-and-filter-container} + [rn/view {:style style/tabs-container} + [tabs]] + [rn/view {:style style/filter-toggle-container} + [filter-selector-read-toggle]]]]) + +(defn render-notification + [notification index] + [rn/view {:style (style/notification-container index)} + (case (:type notification) + types/contact-verification + [contact-verification/view notification {}] + + types/contact-request + [contact-request/view notification] + + types/mention + [mentions/view notification] + + nil)]) + +(defn view + [] + [:f> + (fn [] + (react/effect! #(rf/dispatch [:activity-center.notifications/fetch-first-page])) + [safe-area/consumer + (fn [{:keys [top bottom]}] + (let [notifications (rf/sub [:activity-center/filtered-notifications]) + window-width (rf/sub [:dimensions/window-width])] + [rn/view {:style (style/screen-container window-width top bottom)} + [header] + [rn/flat-list {:data notifications + :content-container-style {:flex-grow 1} + :empty-component [empty-tab] + :key-fn :id + :on-scroll-to-index-failed identity + :on-end-reached #(rf/dispatch [:activity-center.notifications/fetch-next-page]) + :render-fn render-notification}]]))])]) diff --git a/src/status_im2/navigation/screens.cljs b/src/status_im2/navigation/screens.cljs index bac7127bbf..924d3a48dc 100644 --- a/src/status_im2/navigation/screens.cljs +++ b/src/status_im2/navigation/screens.cljs @@ -3,6 +3,7 @@ [status-im2.contexts.communities.discover.view :as communities.discover] [status-im2.contexts.communities.overview.view :as communities.overview] [status-im2.contexts.shell.view :as shell] + [status-im2.contexts.activity-center.view :as activity-center] [status-im2.contexts.quo-preview.main :as quo.preview] [status-im2.contexts.chat.messages.view :as chat] [status-im2.contexts.syncing.view :as settings-syncing] @@ -15,8 +16,11 @@ (defn screens [] (concat (old-screens/screens) + [{:name :activity-center + :options {:topBar {:visible false}} + :component activity-center/view} - [{:name :shell-stack + {:name :shell-stack :insets {:top false} :component shell/shell-stack} diff --git a/src/status_im2/subs/activity_center.cljs b/src/status_im2/subs/activity_center.cljs index d5f677a16c..ddf9bce440 100644 --- a/src/status_im2/subs/activity_center.cljs +++ b/src/status_im2/subs/activity_center.cljs @@ -1,6 +1,6 @@ (ns status-im2.subs.activity-center (:require [re-frame.core :as re-frame] - [status-im.activity-center.notification-types :as types])) + [status-im2.contexts.activity-center.notification-types :as types])) (re-frame/reg-sub :activity-center/notifications diff --git a/translations/en.json b/translations/en.json index 0a794ed9ff..2b2b7c663e 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1889,6 +1889,8 @@ "bold": "Bold", "italic": "Italic", "strikethrough": "Strikethrough", + "empty-notifications-title": "No notifications", + "empty-notifications-subtitle": "Your notifications will be here", "add-text": "Add text", "send": "Send", "unmute-group": "Unmute group",