Skip to content

Commit

Permalink
airdop-addresses refactor and code review
Browse files Browse the repository at this point in the history
  • Loading branch information
FFFra committed Dec 20, 2023
1 parent 40c45e3 commit 45eb276
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -41,7 +40,6 @@
:accounts
vals
(map #(assoc % :customization-color (:color %))))]

[rn/view {:style style/container}
[quo/page-nav
{:text-align :left
Expand All @@ -59,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)
Expand All @@ -72,22 +69,14 @@
:data accounts}
:description-props {:text (i18n/label :t/all-addresses)}}
{:title (i18n/label :t/for-airdrops)
:on-press #(rf/dispatch
[:show-bottom-sheet
{:content (fn [] [airdrop-addresses/view
{:accounts accounts
:logo-uri (get-in images
[:thumbnail :uri])
:community-name name}])}])
:on-press #(rf/dispatch [:open-modal :airdrop-addresses
{:community-id id}])
:description :text
:action :arrow
:label :preview
:label-props {:type :accounts
;; TODO: Substitute the provided data with the selected airdrop
;; account.
:data [(first accounts)]}
:description-props {:text (-> accounts first :name)}}]}]

:description-props {:text (-> accounts first :name)}}]}]
[quo/text
{:style style/section-title
:accessibility-label :community-rules-title
Expand Down
Original file line number Diff line number Diff line change
@@ -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})
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(ns status-im.contexts.communities.actions.airdrop-addresses.view
(:require
[quo.components.list-items.account.view :as account-view]
[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]
[account-view/view
{: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}]]))
5 changes: 5 additions & 0 deletions src/status_im/navigation/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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}
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2438,4 +2438,4 @@
"copy-all-details": "Copy all details",
"share-details": "Share details",
"what-are-you-waiting-for": "What are you waiting for?"
}
}

0 comments on commit 45eb276

Please sign in to comment.