Skip to content

Commit 8393351

Browse files
committed
[#22404] [News Feed] Implement News AC component
1 parent e50c49b commit 8393351

File tree

11 files changed

+125
-6
lines changed

11 files changed

+125
-6
lines changed

src/status_im/contexts/settings/privacy_and_security/view.cljs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
(let [customization-color (rf/sub [:profile/customization-color])
3030

3131
preview-privacy? (rf/sub [:profile/preview-privacy?])
32+
news-feed-enabled? (rf/sub [:profile/news-feed-enabled?])
3233
see-profile-pictures-from (rf/sub [:profile/pictures-visibility])
3334
show-profile-pictures-to (rf/sub [:multiaccount/profile-pictures-show-to])
3435

@@ -38,6 +39,14 @@
3839
(not preview-privacy?)]))
3940
[preview-privacy?])
4041

42+
toggle-news-feed
43+
(rn/use-callback (fn []
44+
(rf/dispatch [:profile.settings/profile-update :news-feed-enabled?
45+
(not news-feed-enabled?)])
46+
(rf/dispatch [:profile.settings/profile-update :news-rss-enabled?
47+
(not news-feed-enabled?)]))
48+
[news-feed-enabled?])
49+
4150
open-see-profile-pictures-from-options
4251
(rn/use-callback (fn []
4352
(rf/dispatch
@@ -89,6 +98,15 @@
8998
:blur? true
9099
:action :arrow
91100
:action-props {:on-change #(rf/dispatch [:open-modal
92-
:screen/settings.share-usage-data])}}]
101+
:screen/settings.share-usage-data])}}
102+
{:title (i18n/label :t/status-news-rss)
103+
:description :text
104+
:description-props {:text (i18n/label :t/rss-privacy-warning)}
105+
:blur? true
106+
:action :selector
107+
:action-props {:on-change toggle-news-feed
108+
:checked? news-feed-enabled?
109+
:id :news-feed
110+
:customization-color customization-color}}]
93111
:blur? true
94112
:list-type :settings}]]))
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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
(ns status-im.contexts.shell.activity-center.notification.news.view
2+
(:require [clojure.string :as string]
3+
[promesa.core :as promesa]
4+
[quo.core :as quo]
5+
[react-native.core :as rn]
6+
[status-im.contexts.shell.activity-center.notification.common.view :as common]
7+
[utils.datetime :as datetime]
8+
[utils.i18n :as i18n]
9+
[utils.re-frame :as rf]))
10+
11+
(defn auto-resized-image
12+
[url]
13+
(let [[height set-height] (rn/use-state nil)
14+
window-width (- (:width (rn/get-window)) 40)]
15+
(rn/use-effect #(-> (rn/image-get-size url)
16+
(promesa/then (fn [[w h]]
17+
(let [scale (/ window-width w)
18+
new-height (* h scale)]
19+
(set-height new-height))))))
20+
(if height
21+
[rn/image
22+
{:resize-mode :contain
23+
:style {:width window-width
24+
:height height
25+
:align-self :center
26+
:border-radius 12}
27+
:source url}]
28+
[rn/view {:style {:height 200 :align-items :center :justify-content :center}}
29+
[rn/activity-indicator]])))
30+
31+
(defn sheet
32+
[{:keys [newsImageUrl newsTitle newsContent newsLink newsLinkLabel]} timestamp]
33+
(let [customization-color (rf/sub [:profile/customization-color])]
34+
[:<>
35+
[quo/drawer-top {:title newsTitle :description timestamp}]
36+
[rn/scroll-view {:style {:flex 1}}
37+
(when (not (string/blank? newsImageUrl))
38+
[auto-resized-image newsImageUrl])
39+
[quo/text
40+
{:style {:padding-horizontal 20
41+
:padding-vertical 8}}
42+
newsContent]]
43+
(when (and (not (string/blank? newsLink)) (not (string/blank? newsLinkLabel)))
44+
[quo/bottom-actions
45+
{:button-one-label newsLinkLabel
46+
:button-one-props {:customization-color
47+
customization-color
48+
:icon-right :i/external
49+
:on-press
50+
(fn []
51+
(rf/dispatch [:browser.ui/open-url newsLink])
52+
(rf/dispatch [:hide-bottom-sheet]))}}])]))
53+
54+
(defn view
55+
[{:keys [notification extra-fn]}]
56+
(let [customization-color (rf/sub [:profile/customization-color])
57+
{:keys [newsTitle newsDescription timestamp]} notification
58+
timestamp (datetime/timestamp->relative timestamp)]
59+
[common/swipeable
60+
{:left-button common/swipe-button-read-or-unread
61+
:left-on-press common/swipe-on-press-toggle-read
62+
:right-button common/swipe-button-delete
63+
:right-on-press common/swipe-on-press-delete
64+
:extra-fn extra-fn}
65+
[quo/activity-log
66+
{:title newsTitle
67+
:customization-color customization-color
68+
:icon :i/status-logo-bw
69+
:timestamp timestamp
70+
:context [[quo/text {} newsDescription]]
71+
:items [{:type :button
72+
:subtype :primary
73+
:key :button-reply
74+
:customization-color customization-color
75+
:label (i18n/label :t/read-more)
76+
:accessibility-label :read-more
77+
:on-press #(rf/dispatch
78+
[:show-bottom-sheet
79+
{:theme :dark
80+
:content
81+
(fn []
82+
[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

src/status_im/subs/profile.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@
234234
(fn [{:keys [preview-privacy?]}]
235235
(boolean preview-privacy?)))
236236

237+
(re-frame/reg-sub :profile/news-feed-enabled?
238+
:<- [:profile/profile]
239+
(fn [{:keys [news-feed-enabled?]}]
240+
(boolean news-feed-enabled?)))
241+
237242
(defn- replace-multiaccount-image-uri
238243
[profile port font-file avatar-opts theme]
239244
(let [{:keys [key-uid images

status-go-version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
44
"owner": "status-im",
55
"repo": "status-go",
6-
"version": "v10.27.0",
7-
"commit-sha1": "f5fe88d8b31a287e66a48fe90ef613c7617279b6",
8-
"src-sha256": "01cn2f9f3sq5dmygh4gqpip5zp9f61383xix7rfwxr2nazbqrka3"
6+
"version": "feat/news-feed-mobile",
7+
"commit-sha1": "6ded349455d121039625961cec23fdbb403fb175",
8+
"src-sha256": "1rvnvmzvq9g4rnc3mvbyk63m8v6zv8bvim586p2l4x02p2ywha29"
99
}

0 commit comments

Comments
 (0)