From e59e34d0da5d071575ef920bea4d2a88ae9ff20d Mon Sep 17 00:00:00 2001 From: Flavio Fraschetti Date: Thu, 21 Dec 2023 06:27:59 -0300 Subject: [PATCH] Communities: Present the list of airdrop addresses (#18189) Co-authored-by: Flavio Fraschetti Co-authored-by: Ajay Sivan --- .../actions/accounts_selection/view.cljs | 8 ++-- .../actions/airdrop_addresses/style.cljs | 6 +++ .../actions/airdrop_addresses/view.cljs | 46 +++++++++++++++++++ src/status_im/navigation/screens.cljs | 5 ++ translations/en.json | 1 + 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 src/status_im/contexts/communities/actions/airdrop_addresses/style.cljs create mode 100644 src/status_im/contexts/communities/actions/airdrop_addresses/view.cljs diff --git a/src/status_im/contexts/communities/actions/accounts_selection/view.cljs b/src/status_im/contexts/communities/actions/accounts_selection/view.cljs index 1727fb56e5..bb3f6bac90 100644 --- a/src/status_im/contexts/communities/actions/accounts_selection/view.cljs +++ b/src/status_im/contexts/communities/actions/accounts_selection/view.cljs @@ -3,7 +3,6 @@ [quo.core :as quo] [react-native.core :as rn] [react-native.gesture :as gesture] - [status-im.common.not-implemented :as not-implemented] [status-im.common.password-authentication.view :as password-authentication] [status-im.contexts.communities.actions.accounts-selection.style :as style] [status-im.contexts.communities.actions.community-rules.view :as community-rules] @@ -58,7 +57,6 @@ :weight :semi-bold :size :paragraph-1} (i18n/label :t/address-to-share)] - [quo/category {:list-type :settings :data [{:title (i18n/label :t/join-as-a-member) @@ -71,14 +69,14 @@ :data accounts} :description-props {:text (i18n/label :t/all-addresses)}} {:title (i18n/label :t/for-airdrops) - :on-press not-implemented/alert + :on-press #(rf/dispatch [:open-modal :airdrop-addresses + {:community-id id}]) :description :text :action :arrow :label :preview :label-props {:type :accounts - :data (take 1 accounts)} + :data [(first accounts)]} :description-props {:text (-> accounts first :name)}}]}] - [quo/text {:style style/section-title :accessibility-label :community-rules-title diff --git a/src/status_im/contexts/communities/actions/airdrop_addresses/style.cljs b/src/status_im/contexts/communities/actions/airdrop_addresses/style.cljs new file mode 100644 index 0000000000..b02c75f07e --- /dev/null +++ b/src/status_im/contexts/communities/actions/airdrop_addresses/style.cljs @@ -0,0 +1,6 @@ +(ns status-im.contexts.communities.actions.airdrop-addresses.style) + +(def account-list-container + {:flex 1 + :padding-top 12 + :padding-bottom 8}) diff --git a/src/status_im/contexts/communities/actions/airdrop_addresses/view.cljs b/src/status_im/contexts/communities/actions/airdrop_addresses/view.cljs new file mode 100644 index 0000000000..7052c42075 --- /dev/null +++ b/src/status_im/contexts/communities/actions/airdrop_addresses/view.cljs @@ -0,0 +1,46 @@ +(ns status-im.contexts.communities.actions.airdrop-addresses.view + (:require + [quo.core :as quo] + [react-native.core :as rn] + [status-im.common.not-implemented :as not-implemented] + [status-im.contexts.communities.actions.airdrop-addresses.style :as style] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) + +(defn- render-item + [item] + [quo/account-item + {:account-props item + :emoji (:emoji item)}]) + +(defn- accounts-list + [{:keys [accounts]}] + [rn/view {:style style/account-list-container} + (when (seq accounts) + [rn/flat-list + {:data accounts + :render-fn render-item + :key-fn :address}])]) + +(defn view + [] + (let [{id :community-id} (rf/sub [:get-screen-params]) + {:keys [name images color]} (rf/sub [:communities/community id]) + logo-uri (get-in images [:thumbnail :uri]) + accounts (->> (rf/sub [:wallet]) + :accounts + vals + (map #(assoc % :customization-color (:color %))))] + [:<> + [quo/drawer-top + {:type :context-tag + :title (i18n/label :t/airdrop-addresses) + :community-name name + :button-icon :i/info + :on-button-press not-implemented/alert + :community-logo (get-in images [:thumbnail :uri]) + :customization-color color}] + [accounts-list + {:accounts accounts + :logo-uri logo-uri + :community-name name}]])) diff --git a/src/status_im/navigation/screens.cljs b/src/status_im/navigation/screens.cljs index f80d39ecf7..c208c66a23 100644 --- a/src/status_im/navigation/screens.cljs +++ b/src/status_im/navigation/screens.cljs @@ -13,6 +13,7 @@ [status-im.contexts.communities.actions.accounts-selection.view :as communities.accounts-selection] [status-im.contexts.communities.actions.addresses-for-permissions.view :as addresses-for-permissions] + [status-im.contexts.communities.actions.airdrop-addresses.view :as airdrop-addresses] [status-im.contexts.communities.actions.request-to-join.view :as join-menu] [status-im.contexts.communities.discover.view :as communities.discover] [status-im.contexts.communities.overview.view :as communities.overview] @@ -104,6 +105,10 @@ :options {:sheet? true} :component addresses-for-permissions/view} + {:name :airdrop-addresses + :options {:sheet? true} + :component airdrop-addresses/view} + {:name :lightbox :options options/lightbox :component lightbox/lightbox} diff --git a/translations/en.json b/translations/en.json index cd3de152b5..9d29f95987 100644 --- a/translations/en.json +++ b/translations/en.json @@ -180,6 +180,7 @@ "address-to-share": "Addresses to share", "addresses-for-permissions": "Addresses for permissions", "confirm-changes": "Confirm changes", + "airdrop-addresses": "Address for airdrops", "join-as-a-member": "Join as a Member", "all-addresses": "All addresses", "for-airdrops": "For airdrops",