Skip to content

Commit 5f4729f

Browse files
committed
[#22404] [News Feed] Implement News AC component
1 parent dd1a675 commit 5f4729f

File tree

8 files changed

+109
-2
lines changed

8 files changed

+109
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(ns status-im.contexts.shell.activity-center.notification.news.style)
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
(ns status-im.contexts.shell.activity-center.notification.news.view
2+
(:require [promesa.core :as promesa]
3+
[quo.core :as quo]
4+
[react-native.core :as rn]
5+
[status-im.contexts.shell.activity-center.notification.common.view :as common]
6+
[utils.datetime :as datetime]
7+
[utils.i18n :as i18n]
8+
[utils.re-frame :as rf]))
9+
10+
(defn auto-resized-image
11+
[{:keys [url]}]
12+
(let [[height set-height] (rn/use-state nil)
13+
window-width (- (:width (rn/get-window)) 40)]
14+
(rn/use-effect #(-> (rn/image-get-size url)
15+
(promesa/then (fn [[w h]]
16+
(let [scale (/ window-width w)
17+
new-height (* h scale)]
18+
(set-height new-height))))))
19+
(if height
20+
[rn/image
21+
{:resize-mode :contain
22+
:style {:width window-width
23+
:height height
24+
:align-self :center
25+
:border-radius 12}
26+
:source url}]
27+
[rn/view {:style {:height 200 :align-items :center :justify-content :center}}
28+
[rn/activity-indicator]])))
29+
30+
(defn sheet
31+
[{:keys [image title content link link-label]} timestamp]
32+
(let [customization-color (rf/sub [:profile/customization-color])]
33+
[:<>
34+
[quo/drawer-top {:title title :description timestamp}]
35+
[rn/scroll-view {:style {:flex 1}}
36+
(when image
37+
[auto-resized-image image])
38+
[quo/text
39+
{:style {:padding-horizontal 20
40+
:padding-vertical 8}}
41+
content]]
42+
(when (and link link-label)
43+
[quo/bottom-actions
44+
{:button-one-label link-label
45+
:button-one-props {:customization-color
46+
customization-color
47+
:icon-right :i/external
48+
:on-press
49+
(fn []
50+
(rf/dispatch [:hide-bottom-sheet]))}}])]))
51+
52+
;;TODO REMOVE
53+
#_(rf/dispatch
54+
[:activity-center.notifications/reconcile
55+
[{:id 0x1
56+
:timestamp (datetime/timestamp)
57+
:type types/news-feed
58+
:title "Swaps around the corner! Loooong Looong TITLE"
59+
:description
60+
"Status Mobile's next release brings the app up-to-speed with Status Desktop.\u2028That means: SWAPS!"
61+
:content
62+
"Philosophers meticulously investigate existential dilemmas, scrutinizing metaphysical concepts and epistemological theories, seeking profound insights into consciousness, morality, and the enigmatic nature of existence through rigorous intellectual contemplation and debate."
63+
:link "https://our.status.im/"
64+
:link-label "Let's go"
65+
:image {:url "https://our.status.im/content/images/2025/03/Blog_-_cover_-_32.png"}}]])
66+
67+
(defn view
68+
[{:keys [notification extra-fn]}]
69+
(let [customization-color (rf/sub [:profile/customization-color])
70+
{:keys [title description timestamp]} notification
71+
timestamp (datetime/timestamp->relative timestamp)]
72+
[common/swipeable
73+
{:left-button common/swipe-button-read-or-unread
74+
:left-on-press common/swipe-on-press-toggle-read
75+
:right-button common/swipe-button-delete
76+
:right-on-press common/swipe-on-press-delete
77+
:extra-fn extra-fn}
78+
[quo/activity-log
79+
{:title title
80+
:customization-color customization-color
81+
:icon :i/status-logo-bw
82+
:timestamp timestamp
83+
:context [[quo/text {} description]]
84+
:items [{:type :button
85+
:subtype :primary
86+
:key :button-reply
87+
:customization-color customization-color
88+
:label (i18n/label :t/read-more)
89+
:accessibility-label :read-more
90+
:on-press #(rf/dispatch
91+
[:show-bottom-sheet
92+
{:theme :dark
93+
:content
94+
(fn []
95+
[sheet notification timestamp])}])}]}]]))

src/status_im/contexts/shell/activity_center/notification_types.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
(def ^:const contact-verification 10)
1313
(def ^:const new-installation-received 23)
1414
(def ^:const new-installation-created 24)
15+
(def ^:const news-feed 29)
1516

1617
(def ^:const all-supported
1718
#{one-to-one-chat
@@ -24,7 +25,8 @@
2425
community-kicked
2526
contact-verification
2627
new-installation-received
27-
new-installation-created})
28+
new-installation-created
29+
news-feed})
2830

2931
;; TODO: Replace with correct enum values once status-go implements them.
3032
(def ^:const tx 66612)

src/status_im/contexts/shell/activity_center/tabs/view.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
:default-active filter-type
3030
:data [{:id types/no-type
3131
:label (i18n/label :t/all)}
32+
{:id types/news-feed
33+
:label (i18n/label :t/news)
34+
:accessibility-label :tab-news
35+
:notification-dot? (when-not is-mark-all-as-read-undoable?
36+
(contains? types-with-unread types/news-feed))}
3237
{:id types/admin
3338
:label (i18n/label :t/admin)
3439
:accessibility-label :tab-admin

src/status_im/contexts/shell/activity_center/view.cljs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
contact-verification]
1919
[status-im.contexts.shell.activity-center.notification.membership.view :as membership]
2020
[status-im.contexts.shell.activity-center.notification.mentions.view :as mentions]
21+
[status-im.contexts.shell.activity-center.notification.news.view :as news]
2122
[status-im.contexts.shell.activity-center.notification.reply.view :as reply]
2223
[status-im.contexts.shell.activity-center.notification.syncing.view :as syncing]
2324
[status-im.contexts.shell.activity-center.style :as style]
@@ -55,6 +56,9 @@
5556
(= notification-type types/new-installation-created)
5657
[syncing/installation-created-view props]
5758

59+
(= notification-type types/news-feed)
60+
[news/view props]
61+
5862
(types/membership notification-type)
5963
(condp = notification-type
6064
types/private-group-chat [membership/view props]
@@ -69,7 +73,6 @@
6973
(defn view
7074
[]
7175
(let [notifications (rf/sub [:activity-center/notifications])
72-
7376
;; We globally control the active swipeable for all notifications
7477
;; because when a swipe left/right gesture initiates, the previously
7578
;; active swiped notification (if any) must be removed & closed with

translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,7 @@
17931793
"new-tab": "New tab",
17941794
"new-to-status": "I’m new to Status",
17951795
"new-ui": "New UI",
1796+
"news": "News",
17961797
"next": "Next",
17971798
"next-you-will": "Next, you will be asked to confirm the position of certain words in your recovery phrase",
17981799
"NFT": "NFT",

0 commit comments

Comments
 (0)