Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share community channel qr code #18807

Merged
merged 49 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8931dc3
first commit
Pau1fitz Feb 8, 2024
5e27158
add share qr code
Pau1fitz Feb 8, 2024
b66d510
update to channel
Pau1fitz Feb 8, 2024
4ef2407
retrieve channel qr code url
Pau1fitz Feb 8, 2024
cbda90d
update component
Pau1fitz Feb 8, 2024
7f65c84
add text below
Pau1fitz Feb 13, 2024
fedaa36
update to use color
Pau1fitz Feb 13, 2024
450cbcc
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 13, 2024
e04f7d5
lint
Pau1fitz Feb 13, 2024
e39175f
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 14, 2024
24586f6
feedback
Pau1fitz Feb 14, 2024
ed38451
feedback
Pau1fitz Feb 14, 2024
8ff7367
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 14, 2024
a4825c9
lint
Pau1fitz Feb 14, 2024
4e4feed
remove theme
Pau1fitz Feb 14, 2024
c504237
lint
Pau1fitz Feb 14, 2024
fe16e60
lint
Pau1fitz Feb 14, 2024
366ab3a
lint
Pau1fitz Feb 14, 2024
3e5f4af
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 14, 2024
a17c11c
format
Pau1fitz Feb 14, 2024
8681b0a
lint
Pau1fitz Feb 14, 2024
cede632
move to style fil
Pau1fitz Feb 14, 2024
998e37d
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 14, 2024
97dac76
lint
Pau1fitz Feb 14, 2024
cea9a7e
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 15, 2024
bd4ef53
style
Pau1fitz Feb 15, 2024
0d13e66
style
Pau1fitz Feb 15, 2024
25bfb9e
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 15, 2024
118a0db
use color
Pau1fitz Feb 15, 2024
03df6f9
use vars
Pau1fitz Feb 15, 2024
0759094
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 15, 2024
eebdfe2
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 15, 2024
5dce30d
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 15, 2024
78a87e6
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 15, 2024
d4073bd
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 16, 2024
711f4b0
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 16, 2024
483b597
move to different folder
Pau1fitz Feb 16, 2024
589ea99
update imports
Pau1fitz Feb 16, 2024
9a6be80
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 16, 2024
3635108
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 16, 2024
9879f97
updates
Pau1fitz Feb 16, 2024
becae37
update events
Pau1fitz Feb 16, 2024
cdcc09f
Merge branch 'develop' into share-community-qr-17993
J-Son89 Feb 19, 2024
ee07a14
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 19, 2024
0ecbdf2
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 20, 2024
a869336
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 20, 2024
5a4748c
Merge branch 'develop' into share-community-qr-17993
Pau1fitz Feb 21, 2024
4877785
remove print
Pau1fitz Feb 21, 2024
fcabffc
Merge branch 'develop' into share-community-qr-17993
J-Son89 Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/status_im/contexts/communities/actions/chat/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
:label (i18n/label :t/invite-people-from-contacts)})

(defn- action-qr-code
[]
[chat-id]
{:icon :i/qr-code
:accessibility-label :chat-show-qr-code
:on-press not-implemented/alert
:on-press #(rf/dispatch [:communities/community-channel-url-qr-code-with-data chat-id])
:label (i18n/label :t/show-qr)})

(defn- action-share
Expand All @@ -115,7 +115,7 @@
[quo/action-drawer
[[(action-invite-people)
(action-token-requirements)
(action-qr-code)
(action-qr-code chat-id)
(action-share chat-id)]]]

(and (not inside-chat?) (not locked?))
Expand All @@ -126,7 +126,7 @@
(action-notification-settings)
(action-pinned-messages)
(action-invite-people)
(action-qr-code)
(action-qr-code chat-id)
(action-share chat-id)]]]

(and inside-chat? (not locked?))
Expand All @@ -139,7 +139,7 @@
(when config/fetch-messages-enabled?
(chat-actions/fetch-messages chat-id))
(action-invite-people)
(action-qr-code)
(action-qr-code chat-id)
(action-share chat-id)]]]

:else nil)))
14 changes: 14 additions & 0 deletions src/status_im/contexts/communities/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@
:chat-id chat-id
:event "share-community-channel-url-with-data"}))}]})))

(rf/reg-event-fx :communities/community-channel-url-qr-code-with-data
(fn [_ [chat-id]]
(let [{:keys [community-id channel-id]} (data-store.chats/decode-chat-id chat-id)]
{:json-rpc/call
[{:method "wakuext_shareCommunityChannelURLWithData"
:params [{:CommunityID community-id :ChannelID channel-id}]
:on-success (fn [url]
(rf/dispatch [:open-modal :share-community-channel {:url url}]))
:on-error (fn [err]
(log/error "failed to retrieve community channel url with data"
{:error err
:chat-id chat-id
:event [:communities/community-channel-url-qr-code-with-data]}))}]})))

(rf/reg-event-fx :communities/set-airdrop-address
(fn [{:keys [db]} [address community-id]]
{:db (assoc-in db [:communities community-id :airdrop-address] address)}))
Expand Down
12 changes: 12 additions & 0 deletions src/status_im/contexts/wallet/share_community_channel/style.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns status-im.contexts.wallet.share-community-channel.style
(:require [quo.foundations.colors :as colors]))

(def header-container
{:padding-horizontal 20
:padding-vertical 12})

(def scan-notice
{:color colors/neutral-40
:margin-top 12
:margin-left :auto
:margin-right :auto})
75 changes: 75 additions & 0 deletions src/status_im/contexts/wallet/share_community_channel/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
(ns status-im.contexts.wallet.share-community-channel.view
(:require
[quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.qr-codes.view :as qr-codes]
[status-im.contexts.wallet.share-community-channel.style :as style]
[utils.i18n :as i18n]
[utils.image-server :as image-server]
[utils.re-frame :as rf]))

(def qr-size 500)

(def ^:private padding 32)

(defn qr-code-size
[total-width]
(- total-width (* 2 padding)))

(defn gradient-size
[total-width]
(- total-width (* 2 20)))

(defn view
[]
(let [padding-top (:top (safe-area/get-insets))]
(fn []
(let [chat (rf/sub [:chats/current-chat-chat-view])
mediaserver-port (rf/sub [:mediaserver/port])
window-width (rf/sub [:dimensions/window-width])
{:keys [url]} (rf/sub [:get-screen-params])
qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
{:url url
:port mediaserver-port
:qr-size qr-size
:error-level :highest})
title (i18n/label :t/share-channel)]
[quo/overlay {:type :shell}
(print qr-media-server-uri)
[rn/view
{:flex 1
:padding-top padding-top
:key :share-community}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The styles are passed as props by mistake I guess. I remember that you can pass flex as a prop, but better extract the flex and padding styles into the style ns.

[quo/page-nav
{:icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])
:background :blur
:right-side [{:icon-name :i/scan
:on-press #(js/alert "To be implemented")}]
:accessibility-label :top-bar}]
[quo/text-combinations
{:container-style style/header-container
:title title}]
[rn/view {:style {:padding-horizontal 20 :align-items :center}}
[quo/gradient-cover
{:container-style
{:width (gradient-size window-width)
:position :absolute
:border-radius 12
:z-index -1}
:customization-color (:color chat)}]
[rn/view
{:style {:padding-vertical 12}}
[qr-codes/qr-code
{:size (qr-code-size window-width)
:qr-image-uri qr-media-server-uri
:avatar :channel
:customization-color (:color chat)
:emoji (:emoji chat)
:full-name (:chat-name chat)}]]]
[quo/text
{:size :paragraph-2
:weight :regular
:style style/scan-notice}
(i18n/label :t/scan-with-status-app)]]]))))
5 changes: 5 additions & 0 deletions src/status_im/navigation/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
[status-im.contexts.wallet.send.transaction-confirmation.view :as wallet-transaction-confirmation]
[status-im.contexts.wallet.send.transaction-progress.view :as wallet-transaction-progress]
[status-im.contexts.wallet.share-address.view :as wallet-share-address]
[status-im.contexts.wallet.share-community-channel.view :as share-community-channel]
[status-im.navigation.options :as options]
[status-im.navigation.transitions :as transitions]))

Expand Down Expand Up @@ -108,6 +109,10 @@
:options {:sheet? true}
:component join-menu/view}

{:name :share-community-channel
:options options/transparent-screen-options
:component share-community-channel/view}

{:name :community-account-selection
:options {:sheet? true}
:component communities.accounts-selection/view}
Expand Down
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@
"scan-or-enter-sync-code": "Scan or enter sync code",
"scan-qr": "Scan QR",
"scan-qr-code": "Scan QR code",
"scan-with-status-app": "Scan with the Status app on another device",
"search": "Search",
"search-discover-communities": "Search communities or categories",
"secret-keys-confirmation-text": "You will need them to continue to use your Keycard in case you ever lose your phone.",
Expand Down