-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Communities: Share Selective Account
- Loading branch information
1 parent
5a83287
commit 4e93be5
Showing
8 changed files
with
99 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 7 additions & 14 deletions
21
src/status_im/contexts/communities/actions/addresses_for_permissions/style.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
(ns status-im.contexts.communities.actions.addresses-for-permissions.style | ||
(:require [quo.foundations.colors :as colors])) | ||
(ns status-im.contexts.communities.actions.addresses-for-permissions.style) | ||
|
||
(def container {:flex 1}) | ||
|
||
(def account-item-container | ||
{:font-size 30 | ||
:border-radius 16 | ||
:flex-direction :row | ||
:border-width 1 | ||
:height 56 | ||
:padding-horizontal 12 | ||
:align-items :center | ||
:margin-bottom 8 | ||
:gap 8 | ||
:border-color colors/neutral-90}) | ||
|
||
(def buttons | ||
{:flex-direction :row | ||
:gap 12 | ||
:padding-horizontal 20 | ||
:padding-vertical 12}) | ||
|
||
(def error-message | ||
{:flex-direction :row | ||
:gap 4 | ||
:justify-content :center | ||
:margin-bottom 8}) |
97 changes: 59 additions & 38 deletions
97
src/status_im/contexts/communities/actions/addresses_for_permissions/view.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,76 @@ | ||
(ns status-im.contexts.communities.actions.addresses-for-permissions.view | ||
(:require [quo.core :as quo] | ||
[quo.foundations.colors :as colors] | ||
[react-native.core :as rn] | ||
[reagent.core :as reagent] | ||
[status-im.common.not-implemented :as not-implemented] | ||
[status-im.contexts.communities.actions.addresses-for-permissions.style :as style] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(defn- account-item | ||
[item] | ||
[rn/view | ||
{:style style/account-item-container} | ||
[quo/account-avatar (assoc item :size 32)] | ||
[rn/view | ||
[quo/text | ||
{:size :paragraph-1 | ||
:weight :semi-bold} | ||
(:name item)] | ||
[quo/address-text | ||
{:address (:address item) | ||
:format :short}]]]) | ||
[item _ _ selected-addresses] | ||
[quo/account-permissions | ||
{:account {:name (:name item) | ||
:address (:address item) | ||
:emoji (:emoji item) | ||
:customization-color (:customization-color item)} | ||
:token-details [] | ||
:checked? (contains? @selected-addresses (:address item)) | ||
:on-change (fn [checked?] | ||
(if checked? | ||
(swap! selected-addresses conj (:address item)) | ||
(swap! selected-addresses disj (:address item)))) | ||
:container-style {:margin-bottom 8}}]) | ||
|
||
(defn view | ||
[] | ||
(let [{id :community-id} (rf/sub [:get-screen-params]) | ||
{:keys [name color images]} (rf/sub [:communities/community id]) | ||
accounts (rf/sub [:wallet/accounts-with-customization-color])] | ||
[rn/safe-area-view {:style style/container} | ||
accounts (rf/sub [:wallet/accounts-with-customization-color]) | ||
selected-addresses (reagent/atom (rf/sub [:communities/addresses-for-permissions]))] | ||
(fn [] | ||
[rn/safe-area-view {:style style/container} | ||
[quo/drawer-top | ||
{:type :context-tag | ||
:title (i18n/label :t/addresses-for-permissions) | ||
:community-name name | ||
:button-icon :i/info | ||
:on-button-press not-implemented/alert | ||
:community-logo (get-in images [:thumbnail :uri]) | ||
:customization-color color}] | ||
|
||
[quo/drawer-top | ||
{:type :context-tag | ||
:title (i18n/label :t/addresses-for-permissions) | ||
:community-name name | ||
:button-icon :i/info | ||
:on-button-press not-implemented/alert | ||
:community-logo (get-in images [:thumbnail :uri]) | ||
:customization-color color}] | ||
[rn/flat-list | ||
{:render-fn account-item | ||
:render-data selected-addresses | ||
:content-container-style {:padding 20} | ||
:key-fn :address | ||
:data accounts}] | ||
|
||
[rn/flat-list | ||
{:render-fn account-item | ||
:content-container-style {:padding 20} | ||
:key-fn :address | ||
:data accounts}] | ||
(when (empty? @selected-addresses) | ||
[rn/view | ||
{:style style/error-message} | ||
[quo/icon | ||
:i/info | ||
{:color colors/danger-50 | ||
:size 16}] | ||
[quo/text | ||
{:size :paragraph-2 | ||
:style {:color colors/danger-50}} | ||
(i18n/label :t/no-addresses-selected)]]) | ||
|
||
[rn/view {:style style/buttons} | ||
[quo/button | ||
{:type :grey | ||
:container-style {:flex 1} | ||
:on-press #(rf/dispatch [:navigate-back])} | ||
(i18n/label :t/cancel)] | ||
[quo/button | ||
{:container-style {:flex 1} | ||
:customization-color color | ||
:on-press #(rf/dispatch [:navigate-back])} | ||
(i18n/label :t/confirm-changes)]]])) | ||
[rn/view {:style style/buttons} | ||
[quo/button | ||
{:type :grey | ||
:container-style {:flex 1} | ||
:on-press #(rf/dispatch [:navigate-back])} | ||
(i18n/label :t/cancel)] | ||
[quo/button | ||
{:container-style {:flex 1} | ||
:customization-color color | ||
:disabled? (empty? @selected-addresses) | ||
:on-press (fn [] | ||
(rf/dispatch [:communities/set-addresses-for-permissions | ||
@selected-addresses]) | ||
(rf/dispatch [:navigate-back]))} | ||
(i18n/label :t/confirm-changes)]]]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters