Quo2: Account list card blur (#17271)

* Quo2: account list card blur
This commit is contained in:
Omar Basem 2023-09-15 07:43:48 +04:00 committed by GitHub
parent e2f837fcbc
commit 4d9ebdb9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 52 deletions

View File

@ -2,19 +2,23 @@
(:require [quo2.foundations.colors :as colors])) (:require [quo2.foundations.colors :as colors]))
(defn container (defn container
[state theme] [{:keys [state blur? theme]}]
(let [light-bg (if (= state :default) colors/neutral-2_5 colors/neutral-5) (let [light-bg (if (= state :default) colors/neutral-2_5 colors/neutral-5)
dark-bg (if (= state :default) colors/neutral-80-opa-40 colors/neutral-80-opa-60) dark-bg (if (= state :default) colors/neutral-80-opa-40 colors/neutral-80-opa-60)
blur-bg (if (= state :default) colors/white-opa-5 colors/white-opa-10)
light-border (if (= state :default) colors/neutral-10 colors/neutral-20) light-border (if (= state :default) colors/neutral-10 colors/neutral-20)
dark-border (if (= state :default) colors/neutral-80 colors/neutral-70)] dark-border (if (= state :default) colors/neutral-80 colors/neutral-70)]
{:width 319 {:height 48
:height 48
:border-radius 12 :border-radius 12
:background-color (colors/theme-colors light-bg dark-bg theme) :background-color (if blur? blur-bg (colors/theme-colors light-bg dark-bg theme))
:border-width 1 :border-width (if blur? 0 1)
:border-color (colors/theme-colors light-border dark-border theme) :border-color (colors/theme-colors light-border dark-border theme)
:flex-direction :row :flex-direction :row
:align-items :center :align-items :center
:padding-horizontal 8 :padding-horizontal 8
:padding-vertical 6 :padding-vertical 6
:justify-content :space-between})) :justify-content :space-between}))
(def left-container
{:flex-direction :row
:align-items :center})

View File

@ -6,16 +6,20 @@
[quo2.foundations.colors :as colors] [quo2.foundations.colors :as colors]
[quo2.theme :as quo.theme] [quo2.theme :as quo.theme]
[react-native.core :as rn] [react-native.core :as rn]
[quo2.components.list-items.account-list-card.style :as style])) [quo2.components.list-items.account-list-card.style :as style]
[reagent.core :as reagent]))
(defn- internal-view (defn- internal-view
[{:keys [theme account-props networks state action on-press]}] []
[rn/view (let [state (reagent/atom :default)]
{:style (style/container state theme) (fn [{:keys [action blur? account-props networks on-press on-options-press theme]}]
[rn/pressable
{:style (style/container {:state @state :blur? blur? :theme theme})
:on-press-in #(reset! state :pressed)
:on-press-out #(reset! state :default)
:on-press on-press
:accessibility-label :container} :accessibility-label :container}
[rn/view [rn/view {:style style/left-container}
{:style {:flex-direction :row
:align-items :center}}
[account-avatar/view account-props] [account-avatar/view account-props]
[rn/view {:style {:margin-left 8}} [rn/view {:style {:margin-left 8}}
[text/text [text/text
@ -31,12 +35,16 @@
networks) networks)
[text/text [text/text
{:size :paragraph-2 {:size :paragraph-2
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} :style {:color (if blur?
colors/white-opa-40
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))}}
(:address account-props)]]]] (:address account-props)]]]]
(when (= action :icon) (when (= action :icon)
[rn/pressable {:on-press on-press} [rn/pressable {:on-press on-options-press}
[icon/icon :i/options [icon/icon :i/options
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme) {:color (if blur?
:accessibility-label :icon}]])]) colors/white-opa-70
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))
:accessibility-label :icon}]])])))
(def view (quo.theme/with-theme internal-view)) (def view (quo.theme/with-theme internal-view))

View File

@ -4,14 +4,12 @@
[status-im2.contexts.quo-preview.preview :as preview])) [status-im2.contexts.quo-preview.preview :as preview]))
(def descriptor (def descriptor
[{:key :state [{:key :action
:type :select
:options [{:key :default}
{:key :pressed}]}
{:key :action
:type :select :type :select
:options [{:key :none} :options [{:key :none}
{:key :icon}]}]) {:key :icon}]}
{:key :blur?
:type :boolean}])
(defn view (defn view
[] []
@ -22,9 +20,15 @@
:name "Trip to Vegas" :name "Trip to Vegas"
:address "0x0ah...78b"} :address "0x0ah...78b"}
:networks [:ethereum :optimism] :networks [:ethereum :optimism]
:state :default
:action :none :action :none
:on-press (fn [] (js/alert "Button pressed"))})] :on-press (fn [] (js/alert "Item pressed"))
:on-options-press (fn [] (js/alert "Options pressed"))
:blur? false})]
(fn [] (fn []
[preview/preview-container {:state state :descriptor descriptor} [preview/preview-container
{:state state
:descriptor descriptor
:blur? (:blur? @state)
:show-blur-background? true
:blur-dark-only? true}
[quo/account-list-card @state]]))) [quo/account-list-card @state]])))