-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into milad/18597-disable-long-press-on-tokens-…
…in-watch-only-accounts
- Loading branch information
Showing
10 changed files
with
216 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/quo/components/list_items/network_list/component_spec.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(ns quo.components.list-items.network-list.component-spec | ||
(:require [quo.components.list-items.network-list.view :as network-list] | ||
[quo.foundations.colors :as colors] | ||
[test-helpers.component :as h])) | ||
|
||
(defn- render | ||
[component] | ||
(h/render-with-theme-provider component :light)) | ||
|
||
(def props | ||
{:theme :light | ||
:state :default | ||
:label "Mainnet" | ||
:network-image 873 | ||
:customization-color :blue | ||
:token-value "100.00 ETH" | ||
:fiat-value "€100.00"}) | ||
|
||
|
||
(h/describe "List items: Network List" | ||
(h/test "default state explicit" | ||
(render [network-list/view props]) | ||
(h/is-truthy (h/get-by-text "Mainnet"))) | ||
|
||
(h/test "Pressed state" | ||
(render [network-list/view props]) | ||
(h/fire-event :on-press-in (h/get-by-label-text ::network-list)) | ||
(h/wait-for #(h/has-style (h/query-by-label-text ::network-list) | ||
{:backgroundColor (colors/resolve-color :blue :light 5)}))) | ||
|
||
(h/test "Active state" | ||
(render [network-list/view (assoc props :state :active)]) | ||
(h/has-style (h/query-by-label-text ::network-list) | ||
{:backgroundColor (colors/resolve-color :blue :light 10)})) | ||
|
||
(h/test "Call on-press" | ||
(let [on-press (h/mock-fn)] | ||
(render [network-list/view (assoc props :on-press on-press)]) | ||
(h/fire-event :on-press (h/get-by-label-text ::network-list)) | ||
(h/was-called on-press)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
(ns quo.components.list-items.network-list.style | ||
(:require [quo.foundations.colors :as colors])) | ||
|
||
(defn- background-color | ||
[state customization-color theme] | ||
(case state | ||
:pressed (colors/resolve-color customization-color theme 5) | ||
:active (colors/resolve-color customization-color theme 10) | ||
:transparent)) | ||
|
||
(defn container | ||
[state customization-color theme] | ||
{:flex-direction :row | ||
:justify-content :space-between | ||
:align-items :center | ||
:padding-horizontal 12 | ||
:padding-vertical 8 | ||
:border-radius 12 | ||
:height 56 | ||
:background-color (background-color state customization-color theme)}) | ||
|
||
(def info | ||
{:flex-direction :row | ||
:align-items :center | ||
:gap 2}) | ||
|
||
(def network-image | ||
{:border-width 1 | ||
:border-radius 16 | ||
:border-color colors/neutral-80-opa-5 | ||
:margin-right 8 | ||
:background-color colors/neutral-80-opa-5 | ||
:height 32 | ||
:width 32}) | ||
|
||
(def values-container | ||
{:align-items :flex-end}) | ||
|
||
(defn fiat-value | ||
[theme] | ||
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
(ns quo.components.list-items.network-list.view | ||
(:require | ||
[clojure.string :as string] | ||
[quo.components.list-items.network-list.style :as style] | ||
[quo.components.markdown.text :as text] | ||
[quo.theme :as quo.theme] | ||
[react-native.core :as rn] | ||
[reagent.core :as reagent] | ||
[schema.core :as schema])) | ||
|
||
(defn- info | ||
[{:keys [network-image label]}] | ||
[rn/view {:style style/info} | ||
[rn/image | ||
{:source network-image | ||
:style style/network-image}] | ||
[rn/view | ||
[text/text | ||
{:weight :semi-bold | ||
:style {:text-transform :capitalize} | ||
:number-of-lines 1} | ||
(if (string/blank? label) "-" label)]]]) | ||
|
||
(defn- values | ||
[{:keys [token-value fiat-value theme]}] | ||
[rn/view {:style style/values-container} | ||
[text/text | ||
{:weight :medium | ||
:size :paragraph-2 | ||
:number-of-lines 1} | ||
token-value] | ||
[text/text | ||
{:style (style/fiat-value theme) | ||
:size :paragraph-2 | ||
:number-of-lines 1} | ||
fiat-value]]) | ||
|
||
(def ?schema | ||
[:=> | ||
[:catn | ||
[:props | ||
[:map {:closed true} | ||
[:network-image :int] | ||
[:label :string] | ||
[:fiat-value :string] | ||
[:token-value :string] | ||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]] | ||
[:state [:enum :pressed :active :default]] | ||
[:on-press {:optional true} [:maybe fn?]] | ||
[:theme :schema.common/theme]]]] | ||
:any]) | ||
|
||
(defn- view-internal | ||
[] | ||
(let [pressed? (reagent/atom false) | ||
on-press-in #(reset! pressed? true) | ||
on-press-out #(reset! pressed? false)] | ||
(fn [{:keys [on-press state customization-color theme] | ||
:as props | ||
:or {customization-color :blue}}] | ||
(let [internal-state (if @pressed? | ||
:pressed | ||
state)] | ||
|
||
[rn/pressable | ||
{:style (style/container internal-state customization-color theme) | ||
:on-press-in on-press-in | ||
:on-press-out on-press-out | ||
:on-press on-press | ||
:accessibility-label :network-list} | ||
[info props] | ||
[values props]])))) | ||
|
||
(def view | ||
(quo.theme/with-theme | ||
(schema/instrument #'view-internal ?schema))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/status_im/contexts/preview/quo/list_items/network_list.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(ns status-im.contexts.preview.quo.list-items.network-list | ||
(:require | ||
[quo.core :as quo] | ||
[quo.foundations.resources :as quo.resources] | ||
[reagent.core :as reagent] | ||
[status-im.contexts.preview.quo.preview :as preview])) | ||
|
||
(def descriptor | ||
[{:key :state | ||
:type :select | ||
:options [{:key :default} | ||
{:key :active} | ||
{:key :pressed}]} | ||
{:key :network-image | ||
:type :select | ||
:options [{:key (quo.resources/get-network :ethereum) | ||
:value :ethereum} | ||
{:key (quo.resources/get-network :arbitrum) | ||
:value :arbitrum} | ||
{:key (quo.resources/get-network :optimism) | ||
:value :optimism}]} | ||
{:key :label | ||
:type :text} | ||
{:key :token-value | ||
:type :text} | ||
{:key :fiat-value | ||
:type :text} | ||
{:key :show-alert-on-press? | ||
:type :boolean}]) | ||
|
||
(defn view | ||
[] | ||
(let [state (reagent/atom {:network-image (quo.resources/get-network :ethereum) | ||
:label "Mainnet" | ||
:token-value "0.00 ETH" | ||
:fiat-value "€0.00" | ||
:state :default | ||
:customization-color :blue})] | ||
(fn [] | ||
[preview/preview-container | ||
{:state state | ||
:descriptor descriptor} | ||
[quo/network-list | ||
(merge @state | ||
(when (:show-alert-on-press? @state) | ||
{:on-press #(js/alert "Pressed!")}))]]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters