Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawer/Bottom Actions - context-tag-props #20388

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/quo/components/drawers/bottom_actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[quo.components.drawers.bottom-actions.style :as style]
[quo.components.icon :as icon]
[quo.components.markdown.text :as text]
[quo.components.tags.context-tag.schema :as context-tag.schema]
[quo.components.tags.context-tag.view :as context-tag]
[quo.foundations.colors :as colors]
[quo.theme :as quo.theme]
Expand All @@ -22,6 +23,7 @@
[:description-top-text {:optional true} [:maybe :string]]
[:error-message {:optional true} [:maybe :string]]
[:role {:optional true} [:maybe [:enum :admin :member :token-master :owner]]]
[:context-tag-props {:optional true} [:maybe context-tag.schema/?schema]]
[:button-one-label {:optional true} [:maybe :string]]
[:button-two-label {:optional true} [:maybe :string]]
[:button-one-props {:optional true} [:maybe :map]]
Expand All @@ -39,7 +41,8 @@

(defn- view-internal
[{:keys [actions description description-text description-top-text error-message role button-one-label
button-two-label blur? button-one-props button-two-props scroll? container-style]}]
button-two-label blur? button-one-props button-two-props scroll? container-style
context-tag-props]}]
(let [theme (quo.theme/use-theme)]
[rn/view
{:style (merge (style/container scroll? blur? theme) container-style)}
Expand All @@ -54,18 +57,20 @@
:style {:color (colors/theme-colors colors/danger-50 colors/danger-60 theme)}}
error-message]])

(when (and (= description :top) role)
(when (and (= description :top) (or role context-tag-props))
[rn/view {:style style/description-top}
[text/text
{:size :paragraph-2
:style (style/description-top-text scroll? blur? theme)}
(or description-top-text (i18n/label :t/eligible-to-join-as))]
[context-tag/view
{:type :icon
:size 24
:icon (role role-icon)
:blur? blur?
:context (i18n/label (keyword "t" role))}]])
(if role
{:type :icon
:size 24
:icon (role role-icon)
:blur? blur?
:context (i18n/label (keyword "t" role))}
context-tag-props)]])

[rn/view {:style style/buttons-container}
(when (= actions :two-actions)
Expand Down
71 changes: 39 additions & 32 deletions src/status_im/contexts/preview/quo/drawers/bottom_actions.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns status-im.contexts.preview.quo.drawers.bottom-actions
(:require
[quo.core :as quo]
[reagent.core :as reagent]
[react-native.core :as rn]
[status-im.contexts.preview.quo.preview :as preview]))

(def button-two "Cancel")
Expand Down Expand Up @@ -58,7 +58,9 @@
(def role-descriptor
{:key :role
:type :select
:options [{:key :owner}
:options [{:key nil
:value :none}
{:key :owner}
{:key :token-master}
{:key :admin}
{:key :member}]})
Expand All @@ -77,35 +79,40 @@

(defn view
[]
(let [state (reagent/atom {:actions :two-actions
:description :bottom
:description-text description
:description-top-text "Eligible to join as"
:error-message "Error message"
:button-one-label button-one
:button-two-label button-two
:button-one-props {:on-press (button-press 1)
:type :primary}
:button-two-props {:on-press (button-press 2)
:type :grey}
:blur? false
:role :owner
:scroll? false})]
(fn []
[preview/preview-container
{:state state
:descriptor (cond-> descriptor
(= (:description @state) :top)
(conj role-descriptor description-top-descriptor)
(let [[state set-state] (rn/use-state
{:actions :two-actions
:description :bottom
:description-text description
:description-top-text "Eligible to join as"
:error-message "Error message"
:button-one-label button-one
:button-two-label button-two
:button-one-props {:on-press (button-press 1)
:type :primary}
:button-two-props {:on-press (button-press 2)
:type :grey}
:blur? false
:role nil
:context-tag-props {:size 24
:type :token
:token "USDT"
:amount "99.97"}
:scroll? false})]
[preview/preview-container
{:state state
:set-state set-state
:descriptor (cond-> descriptor
(= (:description state) :top)
(conj role-descriptor description-top-descriptor)

(= (:description @state) :bottom)
(conj description-descriptor)
(= (:description state) :bottom)
(conj description-descriptor)

(= (:description @state) :top-error)
(conj error-descriptor))
:blur? (:blur? @state)
:show-blur-background? true
:blur-dark-only? true
:component-container-style {:margin-top 40
:padding-horizontal 0}}
[quo/bottom-actions @state]])))
(= (:description state) :top-error)
(conj error-descriptor))
:blur? (:blur? state)
:show-blur-background? true
:blur-dark-only? true
:component-container-style {:margin-top 40
:padding-horizontal 0}}
[quo/bottom-actions state]]))