Skip to content

Commit b85ecb0

Browse files
committed
wip: adjust notification settings screen with nested ui
1 parent 0baa717 commit b85ecb0

File tree

2 files changed

+86
-34
lines changed
  • src/status_im/contexts/profile/settings/screens/notifications
  • translations

2 files changed

+86
-34
lines changed

src/status_im/contexts/profile/settings/screens/notifications/view.cljs

Lines changed: 79 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns status-im.contexts.profile.settings.screens.notifications.view
22
(:require
33
[quo.core :as quo]
4+
[quo.foundations.colors :as colors]
45
[react-native.core :as rn]
56
[react-native.platform :as platform]
67
[status-im.common.events-helper :as events-helper]
@@ -51,13 +52,15 @@
5152
on-change (rn/use-callback
5253
#(toggle-non-contact-notifications non-contact-notifications-enabled?)
5354
[non-contact-notifications-enabled?])]
54-
{:blur? true
55-
:title (i18n/label :t/notifications-non-contacts)
56-
:action :selector
57-
:action-props {:on-change (when-not disabled? on-change)
58-
:disabled? disabled?
59-
:checked? (and (not disabled?)
60-
non-contact-notifications-enabled?)}}))
55+
{:blur? true
56+
:title (i18n/label :t/notifications-non-contacts)
57+
:description :text
58+
:description-props {:text (i18n/label :t/notifications-non-contacts-description)}
59+
:action :selector
60+
:action-props {:on-change (when-not disabled? on-change)
61+
:disabled? disabled?
62+
:checked? (and (not disabled?)
63+
non-contact-notifications-enabled?)}}))
6164

6265
(defn chat-community-mentions-notifications-setting
6366
[{:keys [notifications-enabled?
@@ -68,39 +71,87 @@
6871
on-change (rn/use-callback
6972
#(toggle-community-mentions-notifications community-mentions-notifications-enabled?)
7073
[community-mentions-notifications-enabled?])]
71-
{:blur? true
72-
:title (i18n/label :t/allow-mention-notifications)
73-
:action :selector
74-
:action-props {:on-change (when-not disabled? on-change)
75-
:disabled? disabled?
76-
:checked? (and (not disabled?)
77-
community-mentions-notifications-enabled?)}}))
74+
{:blur? true
75+
:title (i18n/label :t/communities)
76+
:description :text
77+
:description-props {:text (i18n/label :t/allow-community-mentions-notifications-description)}
78+
:action :selector
79+
:action-props {:on-change (when-not disabled? on-change)
80+
:disabled? disabled?
81+
:checked? (and (not disabled?)
82+
community-mentions-notifications-enabled?)}}))
7883

7984
(defn messenger-notifications-setting
8085
[{:keys [notifications-enabled? messenger-notifications-enabled?]}]
8186
(let [disabled? (not notifications-enabled?)
8287
on-change (rn/use-callback
8388
#(toggle-messenger-notifications messenger-notifications-enabled?)
8489
[messenger-notifications-enabled?])]
85-
{:blur? true
86-
:title (i18n/label :t/allow-messenger-notifications)
87-
:action :selector
88-
:action-props {:on-change (when-not disabled? on-change)
89-
:disabled? disabled?
90-
:checked? messenger-notifications-enabled?}}))
90+
(cond-> {:blur? true
91+
:title (i18n/label :t/allow-messenger-notifications)
92+
:action :selector
93+
:action-props {:on-change (when-not disabled? on-change)
94+
:disabled? disabled?
95+
:checked? messenger-notifications-enabled?}}
96+
platform/android?
97+
(assoc :title (i18n/label :t/allow-messages-and-communities-notifications)
98+
:description :text
99+
:description-props {:text (i18n/label
100+
:t/allow-messages-and-communities-notifications-description)}))))
91101

92102
(defn news-notifications-setting
93103
[{:keys [notifications-enabled? news-notifications-enabled?]}]
94104
(let [disabled? (not notifications-enabled?)
95105
on-change (rn/use-callback
96106
#(toggle-news-notifications news-notifications-enabled?)
97107
[news-notifications-enabled?])]
98-
{:blur? true
99-
:title (i18n/label :t/allow-news-notifications)
100-
:action :selector
101-
:action-props {:on-change (when-not disabled? on-change)
102-
:disabled? disabled?
103-
:checked? news-notifications-enabled?}}))
108+
(cond-> {:blur? true
109+
:title (i18n/label :t/allow-news-notifications)
110+
:action :selector
111+
:action-props {:on-change (when-not disabled? on-change)
112+
:disabled? disabled?
113+
:checked? news-notifications-enabled?}}
114+
platform/android?
115+
(assoc :description :text
116+
:description-props {:text (i18n/label :t/allow-news-notifications-description)}))))
117+
118+
(defn- nested-setting
119+
[item & _rest]
120+
[quo/category
121+
{:blur? true
122+
:list-type :settings
123+
:container-style {:padding-horizontal 8
124+
:padding-top 0
125+
:paddong-bottom 0}
126+
:data [item]}])
127+
128+
(defn- messenger-notifications-settings
129+
[notifications-settings]
130+
(let [{:keys [action-props title]} (messenger-notifications-setting notifications-settings)]
131+
[rn/pressable
132+
{:on-press (:on-change action-props)
133+
:style {:margin-horizontal 20
134+
:margin-vertical 8
135+
:border-width 1
136+
:border-radius 20
137+
:border-color colors/white-opa-5}}
138+
[rn/view
139+
{:style {:flex-direction :row
140+
:padding-left 16
141+
:padding-right 12
142+
:padding-vertical 13
143+
:gap 12}}
144+
[quo/text {:style {:flex 1}} title]
145+
[quo/selectors
146+
{:type :toggle
147+
:checked? (:checked? action-props)
148+
:on-change (:on-change action-props)}]]
149+
[rn/view {}
150+
[rn/flat-list
151+
{:data [(chat-non-contacts-notifications-setting notifications-settings)
152+
(chat-community-mentions-notifications-setting notifications-settings)]
153+
:render-fn nested-setting
154+
:separator [rn/view {:style {:height 0}}]}]]]))
104155

105156
(defn view
106157
[]
@@ -136,12 +187,8 @@
136187
[:<>
137188
(cond
138189
platform/ios?
139-
[quo/category
140-
{:blur? true
141-
:list-type :settings
142-
:data [(messenger-notifications-setting notifications-settings)
143-
(chat-non-contacts-notifications-setting notifications-settings)
144-
(chat-community-mentions-notifications-setting notifications-settings)]}]
190+
[messenger-notifications-settings notifications-settings]
191+
145192
platform/android?
146193
[quo/category
147194
{:blur? true

translations/en.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@
132132
"all-time": "All time",
133133
"allow": "Allow",
134134
"allow-and-send": "Allow and send",
135+
"allow-community-mentions-notifications-description": "Mentions and replies",
135136
"allow-mention-notifications": "Show @ mentions",
137+
"allow-messages-and-communities-notifications": "Messages and communities",
138+
"allow-messages-and-communities-notifications-description": "1-1 and group messages, replies and mentions in communities. Possible high battery usage.",
136139
"allow-messenger-notifications": "Show messenger notifications",
137140
"allow-new-contact-requests": "Allow new contact requests",
138-
"allow-news-notifications": "Show news notifications",
141+
"allow-news-notifications": "News from Status",
142+
"allow-news-notifications-description": "Uses Google services, and works even when the app is closed.",
139143
"allowing-authorizes-this-dapp": "Allowing authorizes this DApp to retrieve your wallet address and enable Web3",
140144
"alphabetically": "Alphabetically",
141145
"already-have-asset": "You already have this asset",
@@ -1895,7 +1899,8 @@
18951899
"notification-settings": "Notification settings",
18961900
"notifications": "Notifications",
18971901
"notifications-marked-as-read": "{{count}} notifications marked as read",
1898-
"notifications-non-contacts": "Notifications from non-contacts",
1902+
"notifications-non-contacts": "From non-contacts",
1903+
"notifications-non-contacts-description": "Contact requests and group messages",
18991904
"notifications-preferences": "Notification preferences",
19001905
"notifications-servers": "Notification servers",
19011906
"notifications-switch": "Show notifications",

0 commit comments

Comments
 (0)