Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8abc93f250 | ||
|
|
c3ef8729d0 | ||
|
|
145432860a | ||
|
|
5de5b3e225 | ||
|
|
3f74c0f930 | ||
|
|
b2ce99c4ae | ||
|
|
efa9d9c7e4 | ||
|
|
ecfd80f6fc | ||
|
|
ce798ecafe | ||
|
|
a02cf6993e | ||
|
|
5cc1685619 |
@@ -9,7 +9,7 @@
|
||||
[:size {:optional true} [:maybe [:enum :size-24 :size-32]]]
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:theme :schema.common/theme]
|
||||
[:collectible-img-src :schema.common/image-source]
|
||||
[:collectible-img-src [:maybe :schema.common/image-source :string]]
|
||||
[:collectible-name :string]
|
||||
[:collectible-id :string]]]]
|
||||
[:collectible-id {:optional true} [:maybe :string]]]]]
|
||||
:any])
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
(:require [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.resources :as resources]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.communities.actions.addresses-for-permissions.style :as style]
|
||||
[status-im.contexts.communities.actions.detail-token-gating.view :as detail-token-gating]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.money :as money]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -74,8 +74,7 @@
|
||||
:context-tag-type :community
|
||||
:community-name name
|
||||
:button-icon :i/info
|
||||
:button-type :grey
|
||||
:on-button-press not-implemented/alert
|
||||
:on-button-press #(rf/dispatch [:show-bottom-sheet {:content detail-token-gating/view}])
|
||||
:community-logo (get-in images [:thumbnail :uri])
|
||||
:customization-color color}]
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
(ns status-im.contexts.communities.actions.detail-token-gating.style)
|
||||
|
||||
(def container
|
||||
{:flex 1
|
||||
:background-color :white})
|
||||
|
||||
(def highest-role
|
||||
{:flex-direction :row
|
||||
:padding-horizontal 22
|
||||
:margin-bottom 8})
|
||||
@@ -0,0 +1,56 @@
|
||||
(ns status-im.contexts.communities.actions.detail-token-gating.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.contexts.communities.actions.detail-token-gating.style :as style]
|
||||
[status-im.contexts.communities.utils :as communities.utils]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [{id :community-id} (rf/sub [:get-screen-params])
|
||||
{:keys [highest-permission-role can-request-access?]}
|
||||
(rf/sub [:community/token-gated-overview id])
|
||||
token-permissions (rf/sub [:community/token-permissions id])
|
||||
tokens (get token-permissions 2)
|
||||
token-master (get token-permissions 6)
|
||||
token-master-name (:symbol (first (first token-master)))
|
||||
token-master-img (:img-src (first (first token-master)))
|
||||
highest-role-text
|
||||
(i18n/label
|
||||
(communities.utils/role->translation-key highest-permission-role :t/member))
|
||||
member-role-text (communities.utils/role->translation-key (contains? token-permissions 2)
|
||||
:t/member)
|
||||
selected-addresses (rf/sub [:communities/selected-permission-addresses id])]
|
||||
|
||||
(tap> ["token master" token-master])
|
||||
|
||||
[rn/view {:style style/container}
|
||||
(when (and highest-permission-role (seq selected-addresses))
|
||||
[rn/view
|
||||
{:style style/highest-role}
|
||||
[rn/view {:style {:flex-direction :column}}
|
||||
[quo/text {:weight :medium}
|
||||
(i18n/label :t/you-eligible-to-join-as {:role highest-role-text})]
|
||||
[quo/text {:style {:padding-bottom 18} :size :paragraph-2}
|
||||
(if can-request-access?
|
||||
(i18n/label :t/you-hodl)
|
||||
(i18n/label :t/you-must-hold))]
|
||||
[rn/view {:style {:align-items :flex-start}}
|
||||
(when token-master
|
||||
[quo/collectible-tag
|
||||
{:size :size-24
|
||||
:collectible-name token-master-name
|
||||
:options :hold
|
||||
:collectible-img-src token-master-img}])]]])
|
||||
[rn/view
|
||||
{:style style/highest-role}
|
||||
[rn/view {:style {:flex-direction :column :margin-top 12}}
|
||||
[quo/text {:weight :medium}
|
||||
(i18n/label :t/you-eligible-to-join-as {:role member-role-text})]
|
||||
[quo/text {:style {:padding-bottom 18} :size :paragraph-2}
|
||||
(if can-request-access?
|
||||
(i18n/label :t/you-hodl)
|
||||
(i18n/label :t/you-must-hold))]
|
||||
[quo/token-requirement-list {:tokens tokens}]]]]))
|
||||
@@ -15,6 +15,7 @@
|
||||
[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.detail-token-gating.view :as detail-token-gating]
|
||||
[status-im.contexts.communities.actions.request-to-join.view :as join-menu]
|
||||
[status-im.contexts.communities.actions.share-community-channel.view :as share-community-channel]
|
||||
[status-im.contexts.communities.discover.view :as communities.discover]
|
||||
@@ -132,6 +133,10 @@
|
||||
:options {:sheet? true}
|
||||
:component airdrop-addresses/view}
|
||||
|
||||
{:name :detail-token-gating
|
||||
:options {:sheet? true}
|
||||
:component detail-token-gating/view}
|
||||
|
||||
{:name :lightbox
|
||||
:options options/lightbox
|
||||
:component lightbox/lightbox}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[re-frame.db :as rf-db]
|
||||
[status-im.common.resources :as resources]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils :as wallet.utils]
|
||||
[utils.i18n :as i18n]))
|
||||
@@ -406,3 +408,75 @@
|
||||
(re-frame/subscribe [:communities/airdrop-address community-id])])
|
||||
(fn [[accounts airdrop-address]]
|
||||
(first (filter #(= (:address %) airdrop-address) accounts))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/checking-all-channels-permissions?
|
||||
(fn [db [_ community-id]]
|
||||
(get-in db [:communities community-id])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:community/token-permissions
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])
|
||||
(re-frame/subscribe [:communities/checking-permissions-by-id community-id])])
|
||||
|
||||
(fn [[community permissions-check] _]
|
||||
(let [token-permissions (:token-permissions community)
|
||||
token-images (:token-images community)
|
||||
grouped-by-type (group-by (comp :type second) token-permissions)
|
||||
mock-images (when (and (contains? token-permissions 5)
|
||||
(contains? token-permissions 6))
|
||||
(resources/mock-images :collectible))
|
||||
permissions (:check permissions-check)
|
||||
sufficient (mapcat (fn [[_ permission]]
|
||||
(mapcat (fn [token-req]
|
||||
[(get token-req :satisfied)])
|
||||
(:tokenRequirement permission)))
|
||||
(:permissions permissions))]
|
||||
|
||||
(tap> ["sufficient" sufficient])
|
||||
(tap> ["token images" token-images])
|
||||
(js/console.log ["sufficient" (clj->js sufficient)])
|
||||
(tap> ["database" @rf-db/app-db])
|
||||
(into {}
|
||||
(map (fn [[type tokens]]
|
||||
[type
|
||||
(map (fn [token]
|
||||
(map-indexed (fn [i criteria]
|
||||
(let [sym (:symbol criteria)]
|
||||
(-> criteria
|
||||
(assoc :amount
|
||||
(wallet.utils/remove-trailing-zeroes (:amount
|
||||
criteria)))
|
||||
(assoc :sufficient? (nth sufficient i true)
|
||||
:img-src
|
||||
(if (= type 2)
|
||||
(or mock-images
|
||||
(get token-images sym))
|
||||
(get token-images sym))))))
|
||||
(:token_criteria (second token))))
|
||||
tokens)])
|
||||
grouped-by-type)))))
|
||||
|
||||
(re-frame/reg-sub :community/token-permissions-2
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])
|
||||
(re-frame/subscribe [:communities/checking-permissions-by-id community-id])])
|
||||
(fn [[{:keys [token-permissions]} permissions-check] _]
|
||||
(tap> {:permissions-check permissions-check})
|
||||
(->> token-permissions
|
||||
(map second)
|
||||
(map (fn [token-permission]
|
||||
(let [satisfied-criteria (into []
|
||||
(get-in permissions-check
|
||||
[:check :permissions (:id token-permission)
|
||||
:tokenRequirement]))]
|
||||
(map-indexed (fn [idx criterion]
|
||||
{:symbol (:symbol criterion)
|
||||
:permission-type (:type token-permission)
|
||||
:amount (wallet.utils/remove-trailing-zeroes (:amount
|
||||
criterion))
|
||||
:sufficient? (get-in satisfied-criteria [idx :satisfied] false)
|
||||
:img-src "path/to/jpeg"})
|
||||
(:token_criteria token-permission)))))
|
||||
(group-by (comp :permission-type first)))))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user