|
1 | 1 | (ns quo.components.wallet.address-text.view
|
2 |
| - (:require [quo.components.markdown.text :as text] |
| 2 | + (:require [clojure.string :as string] |
| 3 | + [quo.components.markdown.text :as text] |
3 | 4 | [quo.components.wallet.address-text.schema :as component-schema]
|
4 | 5 | [quo.components.wallet.address-text.style :as style]
|
5 | 6 | [quo.foundations.colors :as colors]
|
|
8 | 9 | [utils.address :as utils]))
|
9 | 10 |
|
10 | 11 | (defn- colored-network-text
|
11 |
| - [theme network] |
12 |
| - (let [{:keys [network-name short-name]} network] |
13 |
| - [text/text |
14 |
| - {:size :paragraph-2 |
15 |
| - :style {:color (colors/resolve-color network-name theme)}} |
16 |
| - (str short-name ":")])) |
| 12 | + [{:keys [theme network size weight]}] |
| 13 | + [text/text |
| 14 | + {:size size |
| 15 | + :weight weight |
| 16 | + :style {:color (colors/resolve-color (keyword network) theme)}} |
| 17 | + (str network ":")]) |
17 | 18 |
|
18 | 19 | (defn- view-internal
|
19 |
| - [{:keys [networks address blur? theme format]}] |
20 |
| - (let [network-text-xf (map #(colored-network-text theme %)) |
21 |
| - address-text [text/text |
22 |
| - {:size :paragraph-2 |
23 |
| - ;; TODO: monospace font |
24 |
| - ;; https://github.com/status-im/status-mobile/issues/17009 |
25 |
| - :weight :monospace |
26 |
| - :style (style/address-text format blur? theme)} |
27 |
| - (if (= format :short) |
28 |
| - (utils/get-short-wallet-address address) |
29 |
| - address)]] |
30 |
| - (as-> networks $ |
31 |
| - (into [text/text] network-text-xf $) |
| 20 | + [{:keys [networks address blur? theme format full-address? size weight] |
| 21 | + :or {size :paragraph-2}}] |
| 22 | + (let [network-colored-text (map #(colored-network-text {:theme theme |
| 23 | + :network % |
| 24 | + :weight weight |
| 25 | + :size size})) |
| 26 | + [splitted-networks splitted-address] (and full-address? |
| 27 | + (as-> address $ |
| 28 | + (string/split $ ":") |
| 29 | + [(butlast $) (last $)])) |
| 30 | + address-internal (if full-address? splitted-address address) |
| 31 | + networks-internal (if full-address? |
| 32 | + splitted-networks |
| 33 | + (map :short-name networks)) |
| 34 | + address-text [text/text |
| 35 | + {:size size |
| 36 | + ;; TODO: monospace font |
| 37 | + ;; https://github.com/status-im/status-mobile/issues/17009 |
| 38 | + :weight (or weight :monospace) |
| 39 | + :style (style/address-text format blur? theme)} |
| 40 | + (if (= format :short) |
| 41 | + (utils/get-short-wallet-address address-internal) |
| 42 | + address-internal)]] |
| 43 | + (as-> networks-internal $ |
| 44 | + (into [text/text] network-colored-text $) |
32 | 45 | (conj $ address-text))))
|
33 | 46 |
|
34 | 47 | (def view
|
|
0 commit comments