|
1 | 1 | (ns status-im.contexts.profile.settings.screens.notifications.view
|
2 | 2 | (:require
|
3 | 3 | [quo.core :as quo]
|
| 4 | + [quo.foundations.colors :as colors] |
4 | 5 | [react-native.core :as rn]
|
5 | 6 | [react-native.platform :as platform]
|
6 | 7 | [status-im.common.events-helper :as events-helper]
|
|
51 | 52 | on-change (rn/use-callback
|
52 | 53 | #(toggle-non-contact-notifications non-contact-notifications-enabled?)
|
53 | 54 | [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?)}})) |
61 | 64 |
|
62 | 65 | (defn chat-community-mentions-notifications-setting
|
63 | 66 | [{:keys [notifications-enabled?
|
|
68 | 71 | on-change (rn/use-callback
|
69 | 72 | #(toggle-community-mentions-notifications community-mentions-notifications-enabled?)
|
70 | 73 | [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?)}})) |
78 | 83 |
|
79 | 84 | (defn messenger-notifications-setting
|
80 | 85 | [{:keys [notifications-enabled? messenger-notifications-enabled?]}]
|
81 | 86 | (let [disabled? (not notifications-enabled?)
|
82 | 87 | on-change (rn/use-callback
|
83 | 88 | #(toggle-messenger-notifications messenger-notifications-enabled?)
|
84 | 89 | [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)})))) |
91 | 101 |
|
92 | 102 | (defn news-notifications-setting
|
93 | 103 | [{:keys [notifications-enabled? news-notifications-enabled?]}]
|
94 | 104 | (let [disabled? (not notifications-enabled?)
|
95 | 105 | on-change (rn/use-callback
|
96 | 106 | #(toggle-news-notifications news-notifications-enabled?)
|
97 | 107 | [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}}]}]]])) |
104 | 155 |
|
105 | 156 | (defn view
|
106 | 157 | []
|
|
136 | 187 | [:<>
|
137 | 188 | (cond
|
138 | 189 | 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 | + |
145 | 192 | platform/android?
|
146 | 193 | [quo/category
|
147 | 194 | {:blur? true
|
|
0 commit comments