Skip to content

Commit

Permalink
[#19048] feat: show contact QR code
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Mar 8, 2024
1 parent 3145ecd commit 01cb867
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 12 deletions.
24 changes: 13 additions & 11 deletions src/status_im/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,17 @@
(fn [{:keys [db]} [public-key ens-name]]
(let [my-public-key (get-in db [:profile/profile :public-key])]
(if (not= my-public-key public-key)
{:db (-> db
(assoc :contacts/identity public-key)
(assoc :contacts/ens-name ens-name))
:dispatch [:contacts/build-contact
{:pubkey public-key
:ens ens-name
:success-fn (fn [_]
{:dispatch [:open-modal
(if (ff/enabled? ::ff/profile.new-contact-ui)
:contact-profile
:profile)]})}]}
{:db (-> db
(assoc :contacts/identity public-key)
(assoc :contacts/ens-name ens-name))
:fx [[:dispatch
[:contacts/build-contact
{:pubkey public-key
:ens ens-name
:success-fn (fn [_]
{:dispatch [:open-modal
(if (ff/enabled? ::ff/profile.new-contact-ui)
:contact-profile
:profile)]})}]]
[:dispatch [:universal-links/generate-profile-url {:public-key public-key}]]]}
{:dispatch [:navigate-to :my-profile]}))))
2 changes: 1 addition & 1 deletion src/status_im/contexts/profile/contact/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
:accessibility-label (if nickname :edit-nickname :add-nickname)}
{:icon :i/qr-code
:label (i18n/label :t/show-qr)
:on-press not-implemented/alert
:on-press #(rf/dispatch [:open-modal :share-contact])
:accessibility-label :show-qr-code}
{:icon :i/share
:label (i18n/label :t/share-profile)
Expand Down
9 changes: 9 additions & 0 deletions src/status_im/contexts/profile/contact/share/style.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns status-im.contexts.profile.contact.share.style)

(def header-heading
{:padding-top 2
:padding-bottom 1})

(def qr-code-container
{:margin-horizontal 20
:margin-top 8})
45 changes: 45 additions & 0 deletions src/status_im/contexts/profile/contact/share/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
(ns status-im.contexts.profile.contact.share.view
(:require [legacy.status-im.ui.components.list-selection :as list-selection]
[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.profile.contact.share.style :as style]
[status-im.contexts.profile.utils :as profile.utils]
[utils.address :as address]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn view
[]
(let [{:keys [universal-profile-url customization-color]
:as profile} (rf/sub [:contacts/current-contact])
abbreviated-url (address/get-abbreviated-profile-url universal-profile-url)]
[quo/overlay {:type :shell}
[rn/view
{:style {:padding-top (safe-area/get-top)}
:key :share-community}
[quo/page-nav
{:icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])
:background :blur
:accessibility-label :top-bar}]
[quo/page-top
{:container-style style/header-heading
:title (i18n/label :t/share-profile)}]
[rn/view {:style style/qr-code-container}
[qr-codes/share-qr-code
{:type :profile
:qr-data universal-profile-url
:qr-data-label-shown abbreviated-url
:on-share-press #(list-selection/open-share {:message universal-profile-url})
:on-text-press #(rf/dispatch [:share/copy-text-and-show-toast
{:text-to-copy universal-profile-url
:post-copy-message (i18n/label
:t/link-to-profile-copied)}])
:on-text-long-press #(rf/dispatch [:share/copy-text-and-show-toast
{:text-to-copy universal-profile-url
:post-copy-message (i18n/label
:t/link-to-profile-copied)}])
:profile-picture (profile.utils/photo profile)
:full-name (profile.utils/displayed-name profile)
:customization-color (or customization-color :blue)}]]]]))
5 changes: 5 additions & 0 deletions src/status_im/navigation/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
[status-im.contexts.preview.quo.component-preview.view :as component-preview]
[status-im.contexts.preview.quo.main :as quo.preview]
[status-im.contexts.preview.status-im.main :as status-im-preview]
[status-im.contexts.profile.contact.share.view :as share-contact]
[status-im.contexts.profile.contact.view :as contact-profile]
[status-im.contexts.profile.edit.accent-colour.view :as edit-accent-colour]
[status-im.contexts.profile.edit.bio.view :as edit-bio]
Expand Down Expand Up @@ -198,6 +199,10 @@
:options {:modalPresentationStyle :overCurrentContext}
:component contact-profile/view}

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

{:name :new-to-status
:options {:theme :dark
:layout options/onboarding-transparent-layout
Expand Down

0 comments on commit 01cb867

Please sign in to comment.