Compare commits

...
8 changed files with 149 additions and 40 deletions
@@ -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])
@@ -8,6 +8,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.community-rules.view :as community-rules]
[status-im.contexts.communities.actions.detail-token-gating.view :as detail-token-gating]
[status-im.contexts.communities.utils :as communities.utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@@ -34,19 +35,29 @@
{:community-id id :password %}])}])
(navigate-back))]
(fn []
(let [{:keys [name color images]} (rf/sub [:communities/community id])
(let [{:keys [name color images
membership-permissions?]} (rf/sub [:communities/community id])
airdrop-account (rf/sub [:communities/airdrop-account id])
selected-accounts (rf/sub [:communities/selected-permission-accounts id])
{:keys [highest-permission-role]} (rf/sub [:community/token-gated-overview id])
{:keys [highest-permission-role
no-member-permission?]} (rf/sub [:community/token-gated-overview id])
highest-role-text (i18n/label (communities.utils/role->translation-key
highest-permission-role
:t/member))]
[rn/safe-area-view {:style style/container}
[quo/page-nav
{:text-align :left
:icon-name :i/close
:on-press navigate-back
:accessibility-label :back-button}]
(cond-> {:text-align :left
:icon-name :i/close
:on-press navigate-back
:accessibility-label :back-button}
(or membership-permissions? (and highest-permission-role (not no-member-permission?)))
(assoc :right-side
[{:icon-left :i/unlocked
:on-press #(rf/dispatch
[:show-bottom-sheet
{:content (fn [] [detail-token-gating/view
id])}])
:label (i18n/label :t/permissions)}]))]
[quo/page-top
{:title (i18n/label :t/request-to-join)
:description :context-tag
@@ -1,8 +1,8 @@
(ns status-im.contexts.communities.actions.addresses-for-permissions.view
(:require [quo.core :as quo]
[react-native.gesture :as gesture]
[status-im.common.not-implemented :as not-implemented]
[status-im.constants :as constants]
[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]))
@@ -66,24 +66,28 @@
(rf/dispatch [:hide-bottom-sheet]))]
(rf/dispatch [:communities/get-permissioned-balances id])
(fn []
(let [{:keys [name color images]} (rf/sub [:communities/community id])
(let [{:keys [name color images
membership-permissions?]} (rf/sub [:communities/community id])
{:keys [checking?
highest-permission-role]} (rf/sub [:community/token-gated-overview id])
highest-permission-role
no-member-permission?]} (rf/sub [:community/token-gated-overview id])
accounts (rf/sub [:wallet/accounts-without-watched-accounts])
selected-addresses (rf/sub [:communities/selected-permission-addresses id])
share-all-addresses? (rf/sub [:communities/share-all-addresses? id])
unsaved-address-changes? (rf/sub [:communities/unsaved-address-changes? id])]
[:<>
[quo/drawer-top
{:type :context-tag
:title (i18n/label :t/addresses-for-permissions)
:context-tag-type :community
:community-name name
:button-icon :i/info
:button-type :grey
:on-button-press not-implemented/alert
:community-logo (get-in images [:thumbnail :uri])
:customization-color color}]
(cond-> {:type :context-tag
:title (i18n/label :t/addresses-for-permissions)
:context-tag-type :community
:community-name name
:community-logo (get-in images [:thumbnail :uri])
:customization-color color}
(or membership-permissions? (and highest-permission-role (not no-member-permission?)))
(assoc
:button-icon :i/info
:on-button-press #(rf/dispatch [:show-bottom-sheet
{:content (fn [] [detail-token-gating/view id])}])))]
[gesture/flat-list
{:render-fn account-item
@@ -0,0 +1,14 @@
(ns status-im.contexts.communities.actions.detail-token-gating.style)
(def container
{:flex 1
:padding-horizontal 20})
(def role-container
{:flex-direction :row
:padding-horizontal 22
:margin-bottom 8})
(def permission-text
{:flex-direction :column
:margin-top 12})
@@ -0,0 +1,32 @@
(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
[id]
(let [permissions (rf/sub [:community/token-permissions id])
role-text (fn [role]
(i18n/label
(communities.utils/role->translation-key role
:t/token-master)))]
[rn/view {:style style/container}
(map (fn [{:keys [tokens role satisfied?]}]
^{:key role}
[rn/view {:style {:margin-bottom 20}}
[quo/text {:weight :medium}
(if satisfied?
(i18n/label :t/you-eligible-to-join-as {:role (role-text role)})
(i18n/label :t/you-not-eligible-to-join))]
[quo/text {:size :paragraph-2 :style {:padding-bottom 8}}
(if satisfied?
(i18n/label :t/you-hodl)
(i18n/label :t/you-must-hold))]
[quo/token-requirement-list
{:tokens tokens
:container-style {:padding-horizontal 20}}]])
permissions)]))
@@ -3,6 +3,7 @@
[oops.core :as oops]
[quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme :as theme]
[react-native.blur :as blur]
[react-native.core :as rn]
[reagent.core :as reagent]
@@ -14,6 +15,7 @@
[status-im.constants :as constants]
[status-im.contexts.communities.actions.chat.view :as chat-actions]
[status-im.contexts.communities.actions.community-options.view :as options]
[status-im.contexts.communities.actions.detail-token-gating.view :as detail-token-gating]
[status-im.contexts.communities.overview.style :as style]
[status-im.contexts.communities.utils :as communities.utils]
[utils.debounce :as debounce]
@@ -96,21 +98,12 @@
:unknown-access))
(defn- info-button
[]
[rn/pressable
{:on-press
#(rf/dispatch
[:show-bottom-sheet
{:content
(fn []
[quo/documentation-drawers
{:title (i18n/label :t/token-gated-communities)
:show-button? true
:button-label (i18n/label :t/read-more)
:button-icon :info}
[quo/text (i18n/label :t/token-gated-communities-info)]])}])}
[rn/view
[quo/icon :i/info {:no-color true}]]])
[on-press]
(let [theme (theme/use-theme)]
[rn/pressable
{:on-press on-press}
[rn/view
[quo/icon :i/info {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}]]]))
(defn- network-not-supported
[]
@@ -158,7 +151,9 @@
(if (and can-request-access? highest-permission-role)
(i18n/label :t/you-eligible-to-join-as {:role highest-role-text})
(i18n/label :t/you-not-eligible-to-join))]
[info-button]]
[info-button
#(rf/dispatch [:show-bottom-sheet
{:content (fn [] [detail-token-gating/view id])}])]]
[quo/text {:style {:padding-horizontal 12 :padding-bottom 18} :size :paragraph-2}
(if can-request-access?
(i18n/label :t/you-hodl)
+57 -2
View File
@@ -3,6 +3,7 @@
[clojure.string :as string]
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[re-frame.core :as re-frame]
[status-im.common.resources :as resources]
[status-im.constants :as constants]
[status-im.contexts.wallet.common.utils :as wallet.utils]
[utils.i18n :as i18n]))
@@ -258,8 +259,8 @@
:position position
:mentions-count (or unviewed-mentions-count 0)
:can-post? can-post?
;; NOTE: this is a troolean nil->no permissions, true->no access, false ->
;; has access
;; NOTE: this is a troolean nil->no permissions, true->no access, false
;; -> has access
:locked? (when token-gated?
(not can-post?))
:id id}]
@@ -410,3 +411,57 @@
(map (fn [{sym :symbol image :image}]
{sym image}))
(into {}))))
(re-frame/reg-sub :community/token-permissions-old
(fn [[_ community-id]]
[(re-frame/subscribe [:communities/community community-id])
(re-frame/subscribe [:communities/checking-permissions-by-id community-id])])
(fn [[{:keys [token-permissions token-images]} permissions-check] _]
(let [mock-images (when (and (contains? token-permissions 5)
(contains? token-permissions 6))
(resources/mock-images :collectible))
permissions (get-in permissions-check [:check :permissions])]
(->> token-permissions
(map second)
(map
(fn [token-permission]
(let [token-id (keyword (:id token-permission))
token-requirements (get permissions token-id)
satisfied-criteria (get token-requirements :tokenRequirement)]
(map-indexed (fn [idx criterion]
(let [sym (:symbol criterion)
type (:type token-permission)]
{:symbol sym
:permission-type type
:amount (wallet.utils/remove-trailing-zeroes (:amount
criterion))
:sufficient? (get-in satisfied-criteria [idx :satisfied] false)
:img-src (if (= type 2)
(or (get mock-images sym)
(get token-images sym))
(get token-images sym))}))
(:token_criteria token-permission)))))
(group-by (comp :permission-type first))))))
(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 [[{:keys [token-images]}
{:keys [checking? check]}] _]
(let [roles (:roles check)
member-and-satisifed-roles (filter #(or (= (:type %) 2) (:satisfied %)) roles)]
(into []
(map (fn [role]
{:role (:type role)
:satisfied? (:satisfied role)
:tokens (map (fn [{:keys [tokenRequirement]}]
(map
(partial token-requirement->token
checking?
token-images)
tokenRequirement))
(:criteria role))})
member-and-satisifed-roles)))))
-2
View File
@@ -2287,9 +2287,7 @@
"addresses-dont-contain-tokens-needed": "These addresses dont contain tokens needed to join",
"you-hodl": "You hodl:",
"network-not-supported": "Networks not supported",
"token-gated-communities": "Token gated communities",
"read-more": "Read more",
"token-gated-communities-info": "Here will be something relevant about this topic. This will help the user get more context and therefore have a better understanding of it.",
"dont-yell-at-me": "Dont yell at me",
"unmute-channel": "Unmute channel",
"all-messages": "All messages",