Refactor tag preview screens to new api (#17549)

This commit is contained in:
Ajay Sivan 2023-10-25 03:19:37 -07:00 committed by GitHub
parent 8296bda85b
commit 3197adf855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 322 additions and 435 deletions

View File

@ -3,7 +3,7 @@
[clojure.string :as string] [clojure.string :as string]
[quo.components.community.style :as style] [quo.components.community.style :as style]
[quo.components.markdown.text :as text] [quo.components.markdown.text :as text]
[quo.components.tags.token-tag :as token-tag] [quo.components.tags.token-tag.view :as token-tag]
[quo.theme :as quo.theme] [quo.theme :as quo.theme]
[react-native.core :as rn] [react-native.core :as rn]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
@ -14,17 +14,17 @@
{:style (style/token-row padding?)} {:style (style/token-row padding?)}
(doall (doall
(map-indexed (fn [token-index token] (map-indexed (fn [token-index token]
(let [{:keys [img-src amount sufficient? purchasable? loading?]} token] (let [{:keys [img-src amount sufficient? purchasable?]} token]
^{:key token-index} ^{:key token-index}
[rn/view {:style style/token-tag-spacing} [rn/view {:style style/token-tag-spacing}
[token-tag/token-tag [token-tag/view
{:symbol (:symbol token) {:token-symbol (:symbol token)
:value amount :token-value amount
:size 24 :size :size-24
:sufficient? sufficient? :options (cond
:purchasable purchasable? sufficient? :hold
:loading? loading? purchasable? :add)
:img-src img-src}]])) :token-img-src img-src}]]))
tokens))]) tokens))])
(defn- internal-view (defn- internal-view

View File

@ -1,124 +0,0 @@
(ns quo.components.tags.token-tag
(:require
[quo.components.icon :as icons]
[quo.components.markdown.text :as text]
[quo.foundations.colors :as colors]
[quo.theme :as theme]
[react-native.core :as rn]))
(def themes
{:light {:background-color colors/neutral-20}
:dark {:background-color colors/neutral-80}})
(defn get-value-from-size
[size big-option small-option]
(if (= size :big) big-option small-option))
(def icon-container-styles
{:display :flex
:align-items :center
:justify-content :center
:position :absolute
:border-radius 20
:margin-left 2})
(defn tag-container
[size]
{:height (get-value-from-size size 32 24)
:align-items :center
:flex-direction :row
:border-radius 20})
(defn tag
"[tag opts \"label\"]]
opts
{
:size :small/:big
:token-img-src :token-img-src
:token-img-style {}
:border-color :color
:overlay child-elements
}"
[_ _]
(fn [{:keys [size img-src img-style border-color overlay]
:or {size :small}}
label]
[rn/view
{:style (when border-color
{:border-color border-color
:border-radius 20
:border-width 1})}
[rn/view
{:style (merge (tag-container size) (get themes (theme/get-theme)))}
[rn/image
{:src img-src
:style (merge
{:height (get-value-from-size size 28 20)
:width (get-value-from-size size 28 20)
:margin-left 2
:margin-right (get-value-from-size size 8 6)}
img-style)}]
[text/text
{:weight :medium
:number-of-lines 1
:style
{:margin-right (get-value-from-size size 12 11)}
:size (get-value-from-size size :paragraph-2 :label)} label]
overlay]]))
(defn loading-icon
[]
[rn/view
{:style {:align-items :center
:justify-content :center
:position :absolute
:right -8
:top -8}}
[icons/icon :t/checktoken
{:no-color true
:size 20}]])
(defn icon
[size border-color sufficient?]
[rn/view
{:style (merge
icon-container-styles
{:background-color border-color
:border-color (if (= (theme/get-theme) :dark) colors/neutral-100 colors/white)
:border-width 1
:right (get-value-from-size size -3.75 -5.75)
:bottom (get-value-from-size size (- 32 7.75 4) (- 24 7.75 2))})}
[icons/icon (if sufficient? :i/hold :i/add)
{:no-color true
:size 12}]])
(defn token-tag
"[token-tag opts]
opts
{
:symbol string
:value string
:size :small/:big
:token-img-src :token-img-src
:border-color :color
:sufficient? true/false
:purchasable? true/false
:loading? true/false
}"
[_ _]
(fn [{:keys [value size img-src border-color purchasable? sufficient? loading?]
:or {size :small}
:as props}]
(let [sym (:symbol props)
sufficient? (when-not loading? sufficient?)
border-color (if sufficient? colors/success-50 border-color)]
[tag
{:size size
:img-src img-src
:border-color (if sufficient? colors/success-50 border-color)
:overlay
(if loading?
[loading-icon]
(when (or purchasable? sufficient?)
[icon size border-color sufficient?]))}
(str value " " sym)])))

View File

@ -0,0 +1,49 @@
(ns quo.components.tags.token-tag.style
(:require [quo.foundations.colors :as colors]))
(defn container
[size options blur? theme]
(let [hold? (= options :hold)]
(merge {:background-color (if blur?
(colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5 theme)
(colors/theme-colors colors/neutral-10 colors/neutral-90 theme))
:flex-direction :row
:align-items :center
:padding-left 2
:border-width (if hold? 1 0)
:border-radius 20
:border-color (colors/theme-colors colors/success-50 colors/success-60 theme)}
(condp = size
:size-24 {:height (if hold? 26 24)
:padding-right 10
:border-radius (if hold? 13 12)}
:size-32 {:height (if hold? 34 32)
:padding-right 12
:border-radius (if hold? 17 16)}))))
(defn options-icon
[size]
(assoc
(condp = size
:size-24 {:right -8
:top -8}
:size-32 {:right -6
:top -6})
:position
:absolute))
(defn token-img
[size]
(condp = size
:size-24 {:width 20
:height 20
:margin-right 6
:border-radius 10}
:size-32 {:width 28
:height 28
:margin-right 8
:border-radius 14}))
(defn label
[theme]
{:color (colors/theme-colors colors/neutral-100 colors/white theme)})

View File

@ -0,0 +1,57 @@
(ns quo.components.tags.token-tag.view
(:require
[oops.core :refer [oget]]
[quo.components.icon :as icons]
[quo.components.markdown.text :as text]
[quo.components.tags.token-tag.style :as style]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[react-native.hole-view :as hole-view]
[reagent.core :as reagent]))
(defn- view-internal
"Options:
- :options - false / :add / :hold (default false)
- :size - :size-24 / :size-32 (default :size-24)
- :blur? - boolean (default false)
- :theme - :light / :dark
- :token-img-src - token image source
- :token-value - string - token value
- :token-symbol - string"
[]
(let [container-width (reagent/atom 0)]
(fn [{:keys [options size blur? theme token-img-src token-value token-symbol]
:or {size :size-24}}]
[rn/view
{:on-layout #(reset! container-width
(oget % :nativeEvent :layout :width))}
[hole-view/hole-view
{:holes (if options
[{:x (- @container-width
(condp = size
:size-24 10
:size-32 12))
:y (condp = size
:size-24 -6
:size-32 -4)
:width 16
:height 16
:borderRadius 8}]
[])}
[rn/view
{:style (style/container size options blur? theme)}
[rn/image
{:style (style/token-img size)
:source token-img-src}]
[text/text
{:size :paragraph-2
:weight :medium
:style (style/label theme)}
(str token-value " " token-symbol)]]]
(when options
[rn/view {:style (style/options-icon size)}
[icons/icon (if (= options :hold) :i/hold :i/add-token)
{:size 20
:no-color true}]])])))
(def view (quo.theme/with-theme view-internal))

View File

@ -132,7 +132,7 @@
quo.components.tags.tag quo.components.tags.tag
quo.components.tags.tags quo.components.tags.tags
quo.components.tags.tiny-tag.view quo.components.tags.tiny-tag.view
quo.components.tags.token-tag quo.components.tags.token-tag.view
quo.components.text-combinations.view quo.components.text-combinations.view
quo.components.wallet.account-card.view quo.components.wallet.account-card.view
quo.components.wallet.account-origin.view quo.components.wallet.account-origin.view
@ -360,7 +360,7 @@
(def tag quo.components.tags.tag/tag) (def tag quo.components.tags.tag/tag)
(def tags quo.components.tags.tags/tags) (def tags quo.components.tags.tags/tags)
(def tiny-tag quo.components.tags.tiny-tag.view/view) (def tiny-tag quo.components.tags.tiny-tag.view/view)
(def token-tag quo.components.tags.token-tag/tag) (def token-tag quo.components.tags.token-tag.view/view)
;;;; Text combinations ;;;; Text combinations
(def text-combinations quo.components.text-combinations.view/view) (def text-combinations quo.components.text-combinations.view/view)

View File

@ -42,8 +42,10 @@
[:<> [:<>
[quo/text {:style {:margin-right 4}} "Hold"] [quo/text {:style {:margin-right 4}} "Hold"]
[quo/token-tag [quo/token-tag
{:size :small {:size :size-24
:token-img-src (quo.resources/get-token :eth)} "ETH"] :token-img-src (quo.resources/get-token :eth)
:token-value 5
:token-symbol "ETH"}]
[quo/text {:style {:margin-left 4}} "To post"]]) [quo/text {:style {:margin-left 4}} "To post"]])
(defn example-3 (defn example-3

View File

@ -151,6 +151,7 @@
[status-im2.contexts.quo-preview.tags.number-tag :as number-tag] [status-im2.contexts.quo-preview.tags.number-tag :as number-tag]
[status-im2.contexts.quo-preview.tags.permission-tag :as permission-tag] [status-im2.contexts.quo-preview.tags.permission-tag :as permission-tag]
[status-im2.contexts.quo-preview.tags.status-tags :as status-tags] [status-im2.contexts.quo-preview.tags.status-tags :as status-tags]
[status-im2.contexts.quo-preview.tags.tag :as tag]
[status-im2.contexts.quo-preview.tags.tags :as tags] [status-im2.contexts.quo-preview.tags.tags :as tags]
[status-im2.contexts.quo-preview.tags.tiny-tag :as tiny-tag] [status-im2.contexts.quo-preview.tags.tiny-tag :as tiny-tag]
[status-im2.contexts.quo-preview.tags.token-tag :as token-tag] [status-im2.contexts.quo-preview.tags.token-tag :as token-tag]
@ -416,21 +417,23 @@
{:name :account-selector {:name :account-selector
:component account-selector/view}] :component account-selector/view}]
:tags [{:name :context-tags :tags [{:name :context-tags
:component context-tags/preview-context-tags} :component context-tags/view}
{:name :network-tags {:name :network-tags
:component network-tags/preview} :component network-tags/view}
{:name :number-tag {:name :number-tag
:component number-tag/preview} :component number-tag/view}
{:name :permission-tag {:name :permission-tag
:component permission-tag/preview-permission-tag} :component permission-tag/view}
{:name :status-tags {:name :status-tags
:component status-tags/preview-status-tags} :component status-tags/view}
{:name :tag
:component tag/view}
{:name :tags {:name :tags
:component tags/preview-tags} :component tags/view}
{:name :tiny-tag {:name :tiny-tag
:component tiny-tag/preview-tiny-tag} :component tiny-tag/preview-tiny-tag}
{:name :token-tag {:name :token-tag
:component token-tag/preview-token-tag}] :component token-tag/view}]
:text-combinations [{:name :text-combinations :text-combinations [{:name :text-combinations
:component text-combinations/view}] :component text-combinations/view}]
:wallet [{:name :account-card :component account-card/preview-account-card} :wallet [{:name :account-card :component account-card/preview-account-card}

View File

@ -21,15 +21,13 @@
:value "User pic female 2"}]) :value "User pic female 2"}])
(def size-descriptor (def size-descriptor
{:label "Size" {:key :size
:key :size
:type :select :type :select
:options [{:key 24} :options [{:key 24}
{:key 32}]}) {:key 32}]})
(def descriptor (def descriptor
[{:label "Type" [{:key :type
:key :type
:type :select :type :select
:options [{:key :default} :options [{:key :default}
{:key :multiuser} {:key :multiuser}
@ -66,8 +64,7 @@
nil nil
(resources/mock-images :user-picture-female2) (resources/mock-images :user-picture-female2)
nil]] nil]]
[{:label "users" [{:key :users
:key :users
:type :select :type :select
:options (map (fn [idx] :options (map (fn [idx]
{:key (mapv (fn [picture idx-name] {:key (mapv (fn [picture idx-name]
@ -81,44 +78,36 @@
(def group-descriptor (def group-descriptor
[size-descriptor [size-descriptor
{:label "Group" {:key :group-name
:key :group-name
:type :text}]) :type :text}])
(def channel-descriptor (def channel-descriptor
[size-descriptor [size-descriptor
{:label "Community name" {:key :community-name
:key :community-name
:type :text} :type :text}
{:label "Channel name" {:key :channel-name
:key :channel-name
:type :text}]) :type :text}])
(def community-descriptor (def community-descriptor
[size-descriptor [size-descriptor
{:label "Community name" {:key :community-name
:key :community-name
:type :text}]) :type :text}])
(def token-descriptor (def token-descriptor
[size-descriptor [size-descriptor
{:label "Amount" {:key :amount
:key :amount
:type :text} :type :text}
{:label "Token name" {:key :token-name
:key :token-name
:type :text}]) :type :text}])
(def network-descriptor (def network-descriptor
[size-descriptor [size-descriptor
{:label "Network name" {:key :network-name
:key :network-name
:type :text}]) :type :text}])
(def multinetwork-descriptor (def multinetwork-descriptor
(let [networks (cycle [(resources/mock-images :monkey) (resources/mock-images :diamond)])] (let [networks (cycle [(resources/mock-images :monkey) (resources/mock-images :diamond)])]
[{:label "Networks" [{:key :networks
:key :networks
:type :select :type :select
:options (map (fn [size] :options (map (fn [size]
{:key (take size networks) {:key (take size networks)
@ -127,11 +116,9 @@
(def account-descriptor (def account-descriptor
[size-descriptor [size-descriptor
{:label "Account name" {:key :account-name
:key :account-name
:type :text} :type :text}
{:label "Emoji" {:key :emoji
:key :emoji
:type :select :type :select
:options [{:key "🐷" :value "🐷"} :options [{:key "🐷" :value "🐷"}
{:key "🍇" :value "🍇"} {:key "🍇" :value "🍇"}
@ -139,11 +126,9 @@
(def collectible-descriptor (def collectible-descriptor
[size-descriptor [size-descriptor
{:label "Collectible name" {:key :collectible-name
:key :collectible-name
:type :text} :type :text}
{:label "Collectible number" {:key :collectible-number
:key :collectible-number
:type :text}]) :type :text}])
(def address-descriptor (def address-descriptor
@ -151,27 +136,53 @@
(def icon-descriptor (def icon-descriptor
[size-descriptor [size-descriptor
{:label "Context" {:key :context
:key :context
:type :text} :type :text}
{:label "Icon" {:key :icon
:key :icon
:type :select :type :select
:options [{:key :i/placeholder :value "Placeholder"} :options [{:key :i/placeholder :value "Placeholder"}
{:key :i/add :value "Add"} {:key :i/add :value "Add"}
{:key :i/alert :value "Alert"}]}]) {:key :i/alert :value "Alert"}]}])
(def audio-descriptor (def audio-descriptor
[{:label "Duration" [{:key :duration
:key :duration
:type :text}]) :type :text}])
(defn preview-context-tags (defn f-view
[state type]
(rn/use-effect (fn []
(when (#{:multiuser :multinetwork :audio} @type)
(swap! state assoc :size 24)))
[@type])
[preview/preview-container
{:state state
:descriptor (concat descriptor
(case (:type @state)
:default default-descriptor
:multiuser multiuser-descriptor
:group group-descriptor
:channel channel-descriptor
:community community-descriptor
:token token-descriptor
:network network-descriptor
:multinetwork multinetwork-descriptor
:account account-descriptor
:collectible collectible-descriptor
:address address-descriptor
:icon icon-descriptor
:audio audio-descriptor
default-descriptor))
:blur-height 80
:blur? (:blur? @state)
:show-blur-background? true}
[rn/view {:style {:align-items :center}}
[quo/context-tag @state]]])
(defn view
[] []
(let [state (let [state
(reagent/atom (reagent/atom
{:label "Name" {:size 32
:size 32
:type :group :type :group
:blur? false :blur? false
:state :selected :state :selected
@ -208,32 +219,4 @@
:context "Context" :context "Context"
:duration "00:32"}) :duration "00:32"})
type (reagent/cursor state [:type])] type (reagent/cursor state [:type])]
[:f> [:f> f-view state type]))
(fn []
(rn/use-effect (fn []
(when (#{:multiuser :multinetwork :audio} @type)
(swap! state assoc :size 24)))
[@type])
[preview/preview-container
{:state state
:descriptor (concat descriptor
(case (:type @state)
:default default-descriptor
:multiuser multiuser-descriptor
:group group-descriptor
:channel channel-descriptor
:community community-descriptor
:token token-descriptor
:network network-descriptor
:multinetwork multinetwork-descriptor
:account account-descriptor
:collectible collectible-descriptor
:address address-descriptor
:icon icon-descriptor
:audio audio-descriptor
default-descriptor))
:blur-height 80
:blur? true
:show-blur-background? (:blur? @state)}
[rn/view {:style {:align-items :center}}
[quo/context-tag @state]]])]))

View File

@ -30,7 +30,7 @@
:key :blur?}]) :key :blur?}])
(defn preview (defn view
[] []
(let [state (reagent/atom {:title "Tag" (let [state (reagent/atom {:title "Tag"
:status :default :status :default
@ -46,7 +46,6 @@
:justify-content :center :justify-content :center
:flex 1}} :flex 1}}
[quo/network-tags [quo/network-tags
{:networks (nth community-networks (dec (:networks @state))) (assoc @state
:status (:status @state) :networks
:title (:title @state) (nth community-networks (dec (:networks @state))))]]])))
:blur? (:blur? @state)}]]])))

View File

@ -1,7 +1,6 @@
(ns status-im2.contexts.quo-preview.tags.number-tag (ns status-im2.contexts.quo-preview.tags.number-tag
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im2.contexts.quo-preview.preview :as preview])) [status-im2.contexts.quo-preview.preview :as preview]))
@ -27,16 +26,16 @@
{:key :blur? {:key :blur?
:type :boolean}]) :type :boolean}])
(defn preview (defn view
[] []
(let [state (reagent/atom {:type :squared (let [state (reagent/atom {:type :squared
:number "148" :number "148"
:size :size-32 :size :size-32
:blur? false})] :blur? false})]
(fn [] (fn []
[preview/preview-container {:state state :descriptor descriptor} [preview/preview-container
[rn/view {:state state
{:padding-vertical 60 :descriptor descriptor
:flex-direction :row :blur? (:blur? @state)
:justify-content :center} :show-blur-background? true}
[quo/number-tag @state]]]))) [quo/number-tag @state]])))

View File

@ -1,6 +1,6 @@
(ns status-im2.contexts.quo-preview.tags.permission-tag (ns status-im2.contexts.quo-preview.tags.permission-tag
(:require (:require
[quo.components.tags.permission-tag :as permission-tag] [quo.core :as quo]
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
@ -8,15 +8,13 @@
[status-im2.contexts.quo-preview.preview :as preview])) [status-im2.contexts.quo-preview.preview :as preview]))
(def descriptor (def descriptor
[{:label "Size:" [{:key :size
:key :size
:type :select :type :select
:options [{:key 32 :options [{:key 32
:value "32"} :value "32"}
{:key 24 {:key 24
:value "24"}]} :value "24"}]}
{:label "Locked:" {:key :locked?
:key :locked?
:type :boolean}]) :type :boolean}])
(def community-tokens (def community-tokens
@ -168,27 +166,23 @@
{:id 5 :token-icon (resources/get-mock-image :status-logo)} {:id 5 :token-icon (resources/get-mock-image :status-logo)}
{:id 6 :token-icon (resources/get-mock-image :status-logo)}]}]}]) {:id 6 :token-icon (resources/get-mock-image :status-logo)}]}]}])
(defn preview-permission-tag (defn view
[] []
(let [state (reagent/atom {:size 32})] (let [state (reagent/atom {:size 32})]
(fn [] (fn []
[preview/preview-container [preview/preview-container
{:state state {:state state
:component-container-style {:margin-bottom 40}
:descriptor descriptor} :descriptor descriptor}
[rn/view {:padding-bottom 150}
[rn/view
{:padding-vertical 60
:align-self :center
:justify-content :center}
(when @state (when @state
(for [{:keys [tokens]} community-tokens] (for [{:keys [tokens]} community-tokens]
^{:key tokens} ^{:key tokens}
[rn/view [rn/view
{:margin-top 20 {:margin-top 20
:align-self :flex-end} :align-self :flex-end}
[permission-tag/tag [quo/permission-tag
(merge @state (merge @state
{:tokens tokens {:tokens tokens
:background-color (colors/theme-colors :background-color (colors/theme-colors
colors/neutral-10 colors/neutral-10
colors/neutral-80)})]]))]]]))) colors/neutral-80)})]]))])))

View File

@ -1,7 +1,6 @@
(ns status-im2.contexts.quo-preview.tags.status-tags (ns status-im2.contexts.quo-preview.tags.status-tags
(:require (:require
[quo.components.tags.status-tags :as quo] [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im2.contexts.quo-preview.preview :as preview] [status-im2.contexts.quo-preview.preview :as preview]
@ -31,7 +30,7 @@
:key :blur? :key :blur?
:type :boolean}]) :type :boolean}])
(defn preview-status-tags (defn view
[] []
(let [state (reagent/atom {:status :positive (let [state (reagent/atom {:status :positive
:size :small :size :small
@ -49,10 +48,8 @@
(assoc :label (i18n/label :t/pending))))] (assoc :label (i18n/label :t/pending))))]
[preview/preview-container [preview/preview-container
{:state state {:state state
:show-blur-background? true
:blur? (:blur? @state)
:descriptor descriptor} :descriptor descriptor}
[rn/view {:padding-bottom 150} [rn/view {:style {:flex-direction :row}}
[preview/blur-view [quo/status-tag props]]]))))
{:show-blur-background? (:blur? @state)
:blur-view-props {:blur-type :dark
:overlay-color colors/neutral-80-opa-80}
:style {:align-self :center}} [quo/status-tag props]]]]))))

View File

@ -1,23 +1,18 @@
(ns status-im2.contexts.quo-preview.tags.tag (ns status-im2.contexts.quo-preview.tags.tag
(:require (:require
[quo.components.tags.tag :as tag] [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.ui.components.react :as react]
[status-im2.common.resources :as resources] [status-im2.common.resources :as resources]
[status-im2.contexts.quo-preview.preview :as preview])) [status-im2.contexts.quo-preview.preview :as preview]))
(def descriptor (def descriptor
[{:label "Size:" [{:key :size
:key :size
:type :select :type :select
:options [{:key 32 :options [{:key 32
:value "32"} :value "32"}
{:key 24 {:key 24
:value "24"}]} :value "24"}]}
{:label "Type:" {:key :type
:key :type
:type :select :type :select
:options [{:key :emoji :options [{:key :emoji
:value "Emoji"} :value "Emoji"}
@ -25,17 +20,14 @@
:value "Icons"} :value "Icons"}
{:key :label {:key :label
:value "Label"}]} :value "Label"}]}
{:label "Labelled:" {:key :labelled?
:key :labelled?
:type :boolean} :type :boolean}
{:label "Disabled:" {:key :disabled?
:key :disabled?
:type :boolean} :type :boolean}
{:label "Blurred background:" {:key :blurred?
:key :blurred?
:type :boolean}]) :type :boolean}])
(defn preview-tag (defn view
[] []
(let [state (reagent/atom {:size 32 (let [state (reagent/atom {:size 32
:labelled? true :labelled? true
@ -43,39 +35,10 @@
(fn [] (fn []
[preview/preview-container [preview/preview-container
{:state state {:state state
:descriptor descriptor} :descriptor descriptor
[rn/view :show-blur-background? true
{:style {:padding-bottom 150 :blur? (:blurred? @state)}
:padding-top 60}} [quo/tag
[rn/view
{:style {:flex 1
:justify-content :center
:top 60
:padding-horizontal 16}}
(when (:blurred? @state)
[rn/view
{:style {:flex 1
:height 100}}
[react/image
{:source (resources/get-mock-image :community-cover)
:style {:flex 1
:width "100%"
:border-radius 16}}]
[react/blur-view
{:flex 1
:style {:border-radius 16
:height 100
:position :absolute
:left 0
:right 0}
:blur-amount 20
:overlay-color (colors/theme-colors
colors/white-opa-70
colors/neutral-80-opa-80)}]])
[rn/view
{:style {:position :absolute
:align-self :center}}
[tag/tag
(merge @state (merge @state
{:id 1 {:id 1
:label "Tag" :label "Tag"
@ -84,4 +47,4 @@
(:labelled? @state)) (:labelled? @state))
:resource (if (= :emoji (:type @state)) :resource (if (= :emoji (:type @state))
(resources/get-image :music) (resources/get-image :music)
:i/placeholder)})]]]]]))) :i/placeholder)})]])))

View File

@ -1,23 +1,18 @@
(ns status-im2.contexts.quo-preview.tags.tags (ns status-im2.contexts.quo-preview.tags.tags
(:require (:require
[quo.components.tags.tags :as tags] [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.ui.components.react :as react]
[status-im2.common.resources :as resources] [status-im2.common.resources :as resources]
[status-im2.contexts.quo-preview.preview :as preview])) [status-im2.contexts.quo-preview.preview :as preview]))
(def descriptor (def descriptor
[{:label "Size:" [{:key :size
:key :size
:type :select :type :select
:options [{:key 32 :options [{:key 32
:value "32"} :value "32"}
{:key 24 {:key 24
:value "24"}]} :value "24"}]}
{:label "Type:" {:key :type
:key :type
:type :select :type :select
:options [{:key :emoji :options [{:key :emoji
:value "Emoji"} :value "Emoji"}
@ -25,27 +20,22 @@
:value "Icons"} :value "Icons"}
{:key :label {:key :label
:value "Label"}]} :value "Label"}]}
{:label "Scrollable:" {:key :scrollable?
:key :scrollable?
:type :boolean} :type :boolean}
{:label "Fade Out:" {:key :fade-end-percentage
:key :fade-end-percentage
:type :select :type :select
:options [{:key 1 :options [{:key 1
:value "1%"} :value "1%"}
{:key 0.4 {:key 0.4
:value "0.4%"}]} :value "0.4%"}]}
{:label "Labelled:" {:key :labelled?
:key :labelled?
:type :boolean} :type :boolean}
{:label "Disabled:" {:key :disabled?
:key :disabled?
:type :boolean} :type :boolean}
{:label "Blurred background:" {:key :blurred?
:key :blurred?
:type :boolean}]) :type :boolean}])
(defn preview-tags (defn view
[] []
(let [state (reagent/atom {:size 32 (let [state (reagent/atom {:size 32
:labelled? true :labelled? true
@ -55,40 +45,10 @@
(fn [] (fn []
[preview/preview-container [preview/preview-container
{:state state {:state state
:descriptor descriptor} :descriptor descriptor
[rn/view :blur? (:blurred? @state)
{:style {:padding-bottom 150 :show-blur-background? true}
:padding-top 60}} [quo/tags
[rn/view
{:style {:flex 1
:justify-content :center
:top 60
:padding-horizontal 16}}
(when (:blurred? @state)
[rn/view
{:align-items :center
:height 100
:border-radius 16}
[react/image
{:source (resources/get-mock-image :community-cover)
:style {:flex 1
:width "100%"
:border-radius 16}}]
[react/blur-view
{:flex 1
:style {:border-radius 16
:height 100
:position :absolute
:left 0
:right 0}
:blur-amount 20
:overlay-color (colors/theme-colors
colors/white-opa-70
colors/neutral-80-opa-80)}]])
[rn/view
{:style {:position :absolute
:align-self :center}}
[tags/tags
(merge (merge
@state @state
{:default-active 1 {:default-active 1
@ -101,4 +61,4 @@
{:id 3 :label "Lifestyle" :resource (resources/get-image :lifestyle)}]} {:id 3 :label "Lifestyle" :resource (resources/get-image :lifestyle)}]}
(when (:scrollable? @state) (when (:scrollable? @state)
{:scroll-on-press? true {:scroll-on-press? true
:fade-end? true}))]]]]]))) :fade-end? true}))]])))

View File

@ -1,21 +1,19 @@
(ns status-im2.contexts.quo-preview.tags.token-tag (ns status-im2.contexts.quo-preview.tags.token-tag
(:require (:require
[quo.components.tags.token-tag :as quo] [quo.core :as quo]
[quo.foundations.resources :as resources] [quo.foundations.resources :as resources]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im2.contexts.quo-preview.preview :as preview])) [status-im2.contexts.quo-preview.preview :as preview]))
(def descriptor (def descriptor
[{:label "Size:" [{:key :size
:key :size
:type :select :type :select
:options [{:key :big :options [{:key :size-24
:value "big"} :value "Size 24"}
{:key :small {:key :size-32
:value "small"}]} :value "Size 32"}]}
{:label "Value:" {:key :token-value
:key :value
:type :select :type :select
:options [{:key 0 :options [{:key 0
:value "0"} :value "0"}
@ -27,14 +25,17 @@
:value "1000"} :value "1000"}
{:key 10000 {:key 10000
:value "10000"}]} :value "10000"}]}
{:label "Is Sufficient:" {:key :options
:key :sufficient? :type :select
:options [{:key false
:value false}
{:key :add
:value :add}
{:key :hold
:value :hold}]}
{:key :blur?
:type :boolean} :type :boolean}
{:label "Is Purchasable:" {:key :token-symbol
:key :purchasable?
:type :boolean}
{:label "Token:"
:key :token
:type :select :type :select
:options [{:key "ETH" :options [{:key "ETH"
:value "ETH"} :value "ETH"}
@ -44,17 +45,21 @@
(def eth-token (resources/get-token :eth)) (def eth-token (resources/get-token :eth))
(def snt-token (resources/get-token :snt)) (def snt-token (resources/get-token :snt))
(defn preview-token-tag (defn view
[] []
(let [state (reagent/atom {:size :big :value 10 :token "ETH" :sufficient? false :purchasable? false})] (let [state (reagent/atom {:size :size-24
:token-value 10
:token-symbol "ETH"
:options false
:blur? false})]
(fn [] (fn []
[preview/preview-container [preview/preview-container
{:state state {:state state
:blur? (:blur? @state)
:show-blur-background? true
:descriptor descriptor} :descriptor descriptor}
[rn/view {:padding-bottom 150} [rn/view {:style {:align-items :center}}
[rn/view
{:padding-vertical 60
:align-items :center}
[quo/token-tag [quo/token-tag
(merge @state (assoc @state
{:token-img-src (if (= (get-in @state [:token]) "ETH") eth-token snt-token)})]]]]))) :token-img-src
(if (= (get-in @state [:token-symbol]) "ETH") eth-token snt-token))]]])))