File tree 10 files changed +148
-19
lines changed
quo/components/avatars/channel_avatar
10 files changed +148
-19
lines changed Original file line number Diff line number Diff line change 12
12
(defn- initials
13
13
[{:keys [full-name size customization-color theme]}]
14
14
(let [amount-initials (if (#{:size-32 :size-64 } size) 2 1 )
15
- channel-name (string/replace full-name " #" " " )]
15
+ channel-name (utils. string/safe- replace full-name " #" " " )]
16
16
[text/text
17
17
(cond-> {:accessibility-label :initials
18
18
:style {:color (colors/resolve-color customization-color theme)}
Original file line number Diff line number Diff line change 33
33
(let [qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
34
34
{:url url
35
35
:port (rf/sub [:mediaserver/port ])
36
- :qr-size (or 400 (int size))
36
+ :qr-size (or (int size) 400 )
37
37
:error-level :highest })]
38
- [quo/qr-code (assoc props :qr-image-uri qr-media-server-uri)]))
38
+ [quo/qr-code
39
+ (assoc props
40
+ :qr-image-uri
41
+ qr-media-server-uri)]))
39
42
40
43
(defn get-network-short-name-url
41
44
[network]
Original file line number Diff line number Diff line change 94
94
:label (i18n/label :t/invite-people-from-contacts )})
95
95
96
96
(defn- action-qr-code
97
- []
97
+ [chat-id ]
98
98
{:icon :i/qr-code
99
99
:accessibility-label :chat-show-qr-code
100
- :on-press not-implemented/alert
100
+ :on-press #( rf/dispatch [ :communities/share-community-channel-url-qr-code chat-id])
101
101
:label (i18n/label :t/show-qr )})
102
102
103
103
(defn- action-share
115
115
[quo/action-drawer
116
116
[[(action-invite-people )
117
117
(action-token-requirements )
118
- (action-qr-code )
118
+ (action-qr-code chat-id )
119
119
(action-share chat-id)]]]
120
120
121
121
(and (not inside-chat?) (not locked?))
126
126
(action-notification-settings )
127
127
(action-pinned-messages )
128
128
(action-invite-people )
129
- (action-qr-code )
129
+ (action-qr-code chat-id )
130
130
(action-share chat-id)]]]
131
131
132
132
(and inside-chat? (not locked?))
139
139
(when config/fetch-messages-enabled?
140
140
(chat-actions/fetch-messages chat-id))
141
141
(action-invite-people )
142
- (action-qr-code )
142
+ (action-qr-code chat-id )
143
143
(action-share chat-id)]]]
144
144
145
145
:else nil )))
Original file line number Diff line number Diff line change
1
+ (ns status-im.contexts.communities.actions.share-community-channel.style
2
+ (:require [quo.foundations.colors :as colors]))
3
+
4
+ (def header-container
5
+ {:padding-horizontal 20
6
+ :padding-vertical 12 })
7
+
8
+ (def scan-notice
9
+ {:color colors/white-70-blur
10
+ :margin-top 16
11
+ :margin-left :auto
12
+ :margin-right :auto })
13
+
14
+ (def qr-code-wrapper
15
+ {:padding-horizontal 20
16
+ :margin-top 8
17
+ :align-items :center })
18
+
19
+ (def gradient-cover-padding 20 )
20
+ (def qr-code-padding 12 )
21
+
22
+ (defn qr-code-size
23
+ [total-width]
24
+ (- total-width (* gradient-cover-padding 2 ) (* qr-code-padding 2 )))
25
+
26
+ (defn gradient-cover-size
27
+ [total-width]
28
+ (- total-width (* gradient-cover-padding 2 )))
29
+
30
+ (defn gradient-cover-wrapper
31
+ [width]
32
+ {:width (gradient-cover-size width)
33
+ :position :absolute
34
+ :border-radius 12
35
+ :z-index -1 })
Original file line number Diff line number Diff line change
1
+ (ns status-im.contexts.communities.actions.share-community-channel.view
2
+ (:require
3
+ [quo.core :as quo]
4
+ [react-native.core :as rn]
5
+ [react-native.safe-area :as safe-area]
6
+ [status-im.common.qr-codes.view :as qr-codes]
7
+ [status-im.contexts.communities.actions.share-community-channel.style :as style]
8
+ [utils.i18n :as i18n]
9
+ [utils.re-frame :as rf]))
10
+
11
+ (defn view
12
+ []
13
+ (fn []
14
+ (let [{:keys [url chat-id]} (rf/sub [:get-screen-params ])
15
+ {:keys [color emoji chat-name]} (rf/sub [:chats/community-channel-ui-details-by-id chat-id])
16
+ window-width (rf/sub [:dimensions/window-width ])]
17
+ [quo/overlay {:type :shell }
18
+ [rn/view
19
+ {:style {:padding-top (safe-area/get-top )}
20
+ :key :share-community }
21
+ [quo/page-nav
22
+ {:icon-name :i/close
23
+ :on-press #(rf/dispatch [:navigate-back ])
24
+ :background :blur
25
+ :accessibility-label :top-bar }]
26
+ [quo/text-combinations
27
+ {:container-style style/header-container
28
+ :title (i18n/label :t/share-channel )}]
29
+ [rn/view {:style style/qr-code-wrapper}
30
+ [quo/gradient-cover
31
+ {:container-style
32
+ (style/gradient-cover-wrapper window-width)
33
+ :customization-color color}]
34
+ [rn/view
35
+ {:style {:padding-vertical 12 }}
36
+ [qr-codes/qr-code
37
+ {:size (style/qr-code-size window-width)
38
+ :url url
39
+ :avatar :channel
40
+ :customization-color color
41
+ :emoji emoji
42
+ :full-name chat-name}]]]
43
+ [quo/text
44
+ {:size :paragraph-2
45
+ :weight :regular
46
+ :style style/scan-notice}
47
+ (i18n/label :t/scan-with-status-app )]]])))
Original file line number Diff line number Diff line change 252
252
(get-in db [:communities community-id :previous-share-all-addresses? ]))
253
253
:fx [[:dispatch [:communities/check-permissions-to-join-community community-id]]]})))
254
254
255
- (rf/reg-event-fx :communities/share-community-channel-url-with-data
256
- (fn [_ [chat-id]]
257
- (let [{:keys [community-id channel-id]} (data-store.chats/decode-chat-id chat-id)
258
- title (i18n/label :t/channel-on-status )]
255
+ (rf/reg-event-fx :communities/get-community-channel-share-data
256
+ (fn [_ [chat-id on-success]]
257
+ (let [{:keys [community-id channel-id]} (data-store.chats/decode-chat-id chat-id)]
259
258
{:json-rpc/call
260
259
[{:method " wakuext_shareCommunityChannelURLWithData"
261
260
:params [{:CommunityID community-id :ChannelID channel-id}]
262
- :on-success (fn [url]
261
+ :on-success on-success
262
+ :on-error (fn [err]
263
+ (log/error " failed to retrieve community channel url with data"
264
+ {:error err
265
+ :chat-id chat-id
266
+ :event :communities/get-community-channel-share-data }))}]})))
267
+
268
+ (rf/reg-event-fx :communities/share-community-channel-url-with-data
269
+ (fn [_ [chat-id]]
270
+ (let [title (i18n/label :t/channel-on-status )
271
+ on-success (fn [url]
263
272
(share/open
264
273
(if platform/ios?
265
274
{:activityItemSources [{:placeholderItem {:type " text"
271
280
:subject title
272
281
:message url
273
282
:url url
274
- :isNewTask true })))
275
- :on-error (fn [err]
276
- (log/error " failed to retrieve community channel url with data"
277
- {:error err
278
- :chat-id chat-id
279
- :event " share-community-channel-url-with-data" }))}]})))
283
+ :isNewTask true })))]
284
+ {:fx [[:dispatch [:communities/get-community-channel-share-data chat-id on-success]]]})))
285
+
286
+ (rf/reg-event-fx :communities/share-community-channel-url-qr-code
287
+ (fn [_ [chat-id]]
288
+ (let [on-success #(rf/dispatch [:open-modal :share-community-channel
289
+ {:chat-id chat-id
290
+ :url %}])]
291
+ {:fx [[:dispatch [:communities/get-community-channel-share-data chat-id on-success]]]})))
280
292
281
293
(rf/reg-event-fx :communities/set-airdrop-address
282
294
(fn [{:keys [db]} [address community-id]]
Original file line number Diff line number Diff line change 16
16
addresses-for-permissions]
17
17
[status-im.contexts.communities.actions.airdrop-addresses.view :as airdrop-addresses]
18
18
[status-im.contexts.communities.actions.request-to-join.view :as join-menu]
19
+ [status-im.contexts.communities.actions.share-community-channel.view :as share-community-channel]
19
20
[status-im.contexts.communities.discover.view :as communities.discover]
20
21
[status-im.contexts.communities.overview.view :as communities.overview]
21
22
[status-im.contexts.onboarding.create-password.view :as create-password]
115
116
:options {:sheet? true }
116
117
:component join-menu/view}
117
118
119
+ {:name :share-community-channel
120
+ :options options/transparent-screen-options
121
+ :component share-community-channel/view}
122
+
118
123
{:name :community-account-selection
119
124
:options {:sheet? true }
120
125
:component communities.accounts-selection/view}
Original file line number Diff line number Diff line change 221
221
:community-id
222
222
:emoji ])))
223
223
224
+ (re-frame/reg-sub
225
+ :chats/community-channel-ui-details-by-id
226
+ :<- [:chats/chats ]
227
+ (fn [chats [_ chat-id]]
228
+ (select-keys
229
+ (get chats chat-id)
230
+ [:chat-name
231
+ :color
232
+ :emoji ])))
233
+
224
234
(re-frame/reg-sub
225
235
:chats/current-chat-message-list-view-context
226
236
:<- [:chats/current-chat-chat-view ]
Original file line number Diff line number Diff line change 161
161
(is (not (:can-delete-message-for-everyone? (rf/sub [sub-name]))))
162
162
(is (not (:group-admin? (rf/sub [sub-name]))))
163
163
(is (not (:message-pin-enabled (rf/sub [sub-name])))))))
164
+
165
+ (h/deftest-sub :chats/community-channel-ui-details-by-id
166
+ [sub-name]
167
+ (testing " returns specific ui details of a given community channel chat id"
168
+ (let [chats {chat-id (assoc community-chat
169
+ :color :army
170
+ :emoji " 🍑"
171
+ :chat-name " test" )}]
172
+ (swap! rf-db/app-db assoc
173
+ :chats
174
+ chats)
175
+ (let [result (rf/sub [sub-name chat-id])]
176
+ (is (= 3 (count (keys result))))
177
+ (is (= :army (:color result)))
178
+ (is (= " test" (:chat-name result)))
179
+ (is (= " 🍑" (:emoji result)))))))
Original file line number Diff line number Diff line change 1260
1260
"scan-or-enter-sync-code" : " Scan or enter sync code" ,
1261
1261
"scan-qr" : " Scan QR" ,
1262
1262
"scan-qr-code" : " Scan QR code" ,
1263
+ "scan-with-status-app" : " Scan with the Status app on another device" ,
1263
1264
"invalid-qr" : " Oops! This QR doesn’t work with Status" ,
1264
1265
"search" : " Search" ,
1265
1266
"search-discover-communities" : " Search communities or categories" ,
You can’t perform that action at this time.
0 commit comments