Skip to content

Commit ccbf998

Browse files
some refactor and fixes due to wallet user avatar component changes
1 parent 9cc5429 commit ccbf998

File tree

7 files changed

+68
-54
lines changed

7 files changed

+68
-54
lines changed

src/quo/components/avatars/wallet_user_avatar/style.cljs

+12-8
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@
22
(:require [quo.foundations.colors :as colors]))
33

44
(defn- circle-color
5-
[customization-color]
6-
(colors/custom-color customization-color 50 20))
5+
[customization-color theme]
6+
(if (= customization-color :neutral)
7+
(colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5 theme)
8+
(colors/custom-color customization-color 50 20)))
79

810
(defn- text-color
911
[customization-color theme]
10-
(colors/theme-colors
11-
(colors/custom-color customization-color 50)
12-
(colors/custom-color customization-color 60)
13-
theme))
12+
(if (= customization-color :neutral)
13+
(colors/theme-colors colors/neutral-80-opa-70 colors/white-opa-70 theme)
14+
(colors/theme-colors
15+
(colors/custom-color customization-color 50)
16+
(colors/custom-color customization-color 60)
17+
theme)))
1418

1519
(defn container
16-
[circle-size customization-color]
20+
[circle-size customization-color theme]
1721
{:width circle-size
1822
:height circle-size
1923
:border-radius circle-size
2024
:text-align :center
2125
:justify-content :center
2226
:align-items :center
23-
:background-color (circle-color customization-color)})
27+
:background-color (circle-color customization-color theme)})
2428

2529
(defn text
2630
[customization-color theme]

src/quo/components/avatars/wallet_user_avatar/view.cljs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns quo.components.avatars.wallet-user-avatar.view
2-
(:require [quo.components.avatars.wallet-user-avatar.style :as style]
2+
(:require [clojure.string :as string]
3+
[quo.components.avatars.wallet-user-avatar.style :as style]
34
[quo.components.markdown.text :as text]
45
[quo.theme :as quo.theme]
56
[react-native.core :as rn]
@@ -41,17 +42,18 @@
4142
:size - keyword (default: last element of properties object) - size of the
4243
avatar
4344
:monospace? - boolean (default: false) - use monospace font"
44-
[{:keys [full-name customization-color size theme monospace?]
45+
[{:keys [full-name customization-color size theme monospace? lowercase?]
4546
:or {size biggest-possible}}]
4647
(let [circle-size (:size (size properties))
47-
small? (check-if-size-small size)]
48+
small? (check-if-size-small size)
49+
initials (utils.string/get-initials full-name (if small? 1 2))]
4850
[rn/view
49-
{:style (style/container circle-size customization-color)}
51+
{:style (style/container circle-size customization-color theme)}
5052
[text/text
5153
{:accessibility-label :wallet-user-avatar
5254
:size (:font-size (size properties))
5355
:weight (if monospace? :monospace (:font-weight (size properties)))
5456
:style (style/text customization-color theme)}
55-
(utils.string/get-initials full-name (if small? 1 2))]]))
57+
(if lowercase? (string/lower-case initials) initials)]]))
5658

5759
(def wallet-user-avatar (quo.theme/with-theme view-internal))

src/quo/components/list_items/address/view.cljs

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
[{:keys [theme address networks blur?]}]
1414
[rn/view {:style style/left-container}
1515
[wallet-user-avatar/wallet-user-avatar
16-
{:size :medium
17-
:f-name "0"
18-
:l-name "x"
19-
:monospace? true
20-
:uppercase? false}]
16+
{:size :size-32
17+
:full-name "0 x"
18+
:monospace? true
19+
:lowercase? true
20+
:customization-color :neutral}]
2121
[rn/view {:style style/account-container}
2222
[text/text {:size :paragraph-1}
2323
(map (fn [network]
2424
^{:key (str network)}
2525
[text/text
2626
{:size :paragraph-1
2727
:weight :semi-bold
28-
:style {:color (colors/resolve-color network theme)}}
29-
(str (subs (name network) 0 3) ":")])
28+
:style {:color (colors/resolve-color (:network-name network) theme)}}
29+
(str (:short-name network) ":")])
3030
networks)
3131
[text/text
3232
{:size :paragraph-1

src/quo/components/list_items/saved_address/view.cljs

+17-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns quo.components.list-items.saved-address.view
22
(:require
3-
[clojure.string :as string]
43
[quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
54
[quo.components.icon :as icon]
65
[quo.components.list-items.saved-address.style :as style]
@@ -13,27 +12,23 @@
1312

1413
(defn- left-container
1514
[{:keys [blur? theme name ens address customization-color]}]
16-
(let [names (remove string/blank? (string/split name " "))
17-
first-name (if (> (count names) 0) (first names) "")
18-
last-name (if (> (count names) 1) (last names) "")]
19-
[rn/view {:style style/left-container}
20-
[wallet-user-avatar/wallet-user-avatar
21-
{:size :medium
22-
:f-name first-name
23-
:l-name last-name
24-
:customization-color customization-color}]
25-
[rn/view {:style style/account-container}
26-
[text/text
27-
{:weight :semi-bold
28-
:size :paragraph-1
29-
:style style/name-text}
30-
name]
31-
[text/text {:size :paragraph-2}
32-
[text/text
33-
{:size :paragraph-2
34-
:weight :monospace
35-
:style (style/account-address blur? theme)}
36-
(or ens (address/get-shortened-key address))]]]]))
15+
[rn/view {:style style/left-container}
16+
[wallet-user-avatar/wallet-user-avatar
17+
{:size :size-32
18+
:full-name name
19+
:customization-color customization-color}]
20+
[rn/view {:style style/account-container}
21+
[text/text
22+
{:weight :semi-bold
23+
:size :paragraph-1
24+
:style style/name-text}
25+
name]
26+
[text/text {:size :paragraph-2}
27+
[text/text
28+
{:size :paragraph-2
29+
:weight :monospace
30+
:style (style/account-address blur? theme)}
31+
(or ens (address/get-shortened-key address))]]]])
3732

3833
(defn- internal-view
3934
[]

src/status_im2/constants.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
(def regx-address #"^0x[a-fA-F0-9]{40}$")
194194
(def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}")
195195
(def regx-starts-with-uuid #"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")
196-
(def regx-address-fragment #"^0x[a-fA-F0-9]{1,40}$")
196+
(def regx-full-or-partial-address #"^0x[a-fA-F0-9]{1,40}$")
197197

198198
(def ^:const dapp-permission-contact-code "contact-code")
199199
(def ^:const dapp-permission-web3 "web3")

src/status_im2/contexts/wallet/send/select_address/view.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
300)
7070
:on-change-text (fn [text]
7171
(let [starts-like-eth-address (re-matches
72-
constants/regx-address-fragment
72+
constants/regx-full-or-partial-address
7373
text)]
7474
(when-not (= scanned-address text)
7575
(rf/dispatch [:wallet/clean-scanned-address]))
@@ -89,8 +89,8 @@
8989
^{:key (str network)}
9090
[quo/text
9191
{:size :paragraph-2
92-
:style {:color (colors/resolve-color network theme)}}
93-
(str (subs (name network) 0 3) ":")])
92+
:style {:color (colors/resolve-color (:network-name network) theme)}}
93+
(str (:short-name network) ":")])
9494
networks)
9595
[quo/text
9696
{:size :paragraph-2

src/status_im2/contexts/wallet/temp.cljs

+21-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@
44
[status-im2.contexts.wallet.item-types :as types]))
55

66
(def ens-local-suggestion-saved-address-mock
7-
{:type types/saved-address
8-
:name "Pedro"
9-
:ens "pedro.eth"
10-
:address "0x4732894732894738294783294723894723984"
11-
:networks [:ethereum :optimism]})
7+
{:type types/saved-address
8+
:name "Pedro"
9+
:ens "pedro.eth"
10+
:address "0x4732894732894738294783294723894723984"
11+
:customization-color :purple
12+
:networks [{:network-name :ethereum
13+
:short-name "eth"}
14+
{:network-name :optimism
15+
:short-name "opt"}]})
1216

1317
(def ens-local-suggestion-mock
1418
{:type types/address
1519
:ens "pedro.eth"
1620
:address "0x4732894732894738294783294723894723984"
17-
:networks [:ethereum :optimism]})
21+
:networks [{:network-name :ethereum
22+
:short-name "eth"}
23+
{:network-name :optimism
24+
:short-name "opt"}]})
1825

1926
(def address-local-suggestion-saved-contact-address-mock
2027
{:type types/saved-contact-address
@@ -32,12 +39,18 @@
3239
:name "Peter Lamborginski"
3340
:address "0x12FaBc34De56Ef78A9B0Cd12Ef3456AbC7D8E9F0"
3441
:customization-color :magenta
35-
:networks [:ethereum :optimism]})
42+
:networks [{:network-name :ethereum
43+
:short-name "eth"}
44+
{:network-name :optimism
45+
:short-name "opt"}]})
3646

3747
(def address-local-suggestion-mock
3848
{:type types/address
3949
:address "0x1233cD34De56Ef78A9B0Cd12Ef3456AbC7123dee"
40-
:networks [:ethereum :optimism]})
50+
:networks [{:network-name :ethereum
51+
:short-name "eth"}
52+
{:network-name :optimism
53+
:short-name "opt"}]})
4154

4255
(defn find-matching-addresses
4356
[substring]

0 commit comments

Comments
 (0)