Skip to content

Commit 5dc18a4

Browse files
committed
[Fixes: #13596] Add status-tags component
1 parent 2fcade5 commit 5dc18a4

18 files changed

+146
-5
lines changed
253 Bytes
Loading
296 Bytes
Loading
255 Bytes
Loading
306 Bytes
Loading
542 Bytes
Loading
748 Bytes
Loading
549 Bytes
Loading
753 Bytes
Loading
734 Bytes
Loading
962 Bytes
Loading
746 Bytes
Loading
989 Bytes
Loading

src/quo2/components/icon.cljs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
(ns quo2.components.icon
2-
(:require [status-im.ui.components.icons.icons :as icons]))
2+
(:require
3+
[quo.theme :as theme]
4+
[status-im.ui.components.icons.icons :as icons]))
35

46
(defn icon
57
([icon-name] (icon icon-name nil))
68
([icon-name {:keys [size] :as props}]
79
(let [size (or size 20)]
810
[icons/icon (str (name icon-name) size) (merge props
911
{:width size
10-
:height size})])))
12+
:height size})])))
13+
(defn theme-icon
14+
([icon-name]
15+
(theme-icon icon-name nil))
16+
([icon-name props]
17+
(let [theme-icon-name (if (theme/dark?)
18+
(str (name icon-name) "-dark")
19+
icon-name)]
20+
(icon theme-icon-name props))))

src/quo2/components/status_tags.cljs

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
(ns quo2.components.status-tags
2+
(:require [status-im.i18n.i18n :as i18n]
3+
[quo2.foundations.colors :as colors]
4+
[quo2.components.icon :as icon]
5+
[quo2.components.text :as text]
6+
[quo.react-native :as rn]))
7+
8+
(def default-container-style
9+
{:border-radius 20
10+
:border-width 1})
11+
12+
(def small-container-style
13+
(merge default-container-style
14+
{:padding-horizontal 7
15+
:padding-vertical 3}))
16+
17+
(def large-container-style
18+
(merge default-container-style
19+
{:padding-horizontal 11
20+
:padding-vertical 4}))
21+
22+
(defn base-tag [_]
23+
(fn [{:keys [size
24+
border-color
25+
background-color
26+
icon
27+
text-color
28+
label]}]
29+
(let [paragraph-size (if (= size :small) :paragraph-2 :paragraph-1)]
30+
[rn/view
31+
(assoc (if (= size :small)
32+
small-container-style
33+
large-container-style)
34+
:border-color border-color
35+
:background-color background-color)
36+
[text/text {:size paragraph-size}
37+
[icon/theme-icon icon {:color :none
38+
:size 12}]
39+
[text/text {:size paragraph-size
40+
:style {:color text-color}} (str " " label)]]])))
41+
42+
(defn positive [_]
43+
(fn [size]
44+
[base-tag {:size size
45+
:background-color colors/success-50-opa-10
46+
:icon :verified
47+
:border-color colors/success-50-opa-20
48+
:text-color (colors/theme-colors colors/success-50
49+
colors/success-60)
50+
:label (i18n/label :positive)}]))
51+
52+
(defn negative [_]
53+
(fn [size]
54+
[base-tag {:size size
55+
:icon :untrustworthy
56+
:background-color colors/danger-50-opa-10
57+
:border-color colors/danger-50-opa-20
58+
:text-color (colors/theme-colors colors/danger-50
59+
colors/danger-60)
60+
:label (i18n/label :negative)}]))
61+
62+
(defn pending [_]
63+
(fn [size]
64+
[base-tag {:size size
65+
:icon :pending
66+
:background-color (colors/theme-colors colors/neutral-10
67+
colors/neutral-80)
68+
:border-color (colors/theme-colors colors/neutral-20
69+
colors/neutral-70)
70+
:text-color colors/neutral-50
71+
:label (i18n/label :pending)}]))
72+
73+
(defn status-tag [_]
74+
(fn [{:keys [status size]}]
75+
[(case status
76+
:positive positive
77+
:negative negative
78+
:pending pending
79+
nil) size]))

src/quo2/screens/main.cljs

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[quo2.screens.button :as button]
77
[quo2.screens.text :as text]
88
[quo2.screens.tabs :as tabs]
9+
[quo2.screens.status-tags :as status-tags]
910
[quo2.screens.counter :as counter]
1011
[quo2.screens.segmented :as segmented]
1112
[quo.core :as quo]))
@@ -16,6 +17,9 @@
1617
{:name :quo2-button
1718
:insets {:top false}
1819
:component button/preview-button}
20+
{:name :quo2-status-tags
21+
:insets {:top false}
22+
:component status-tags/preview-status-tags}
1923
{:name :quo2-tabs
2024
:insets {:top false}
2125
:component tabs/preview-tabs}

src/quo2/screens/status_tags.cljs

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
(ns quo2.screens.status-tags
2+
(:require [reagent.core :as reagent]
3+
[quo.react-native :as rn]
4+
[quo.previews.preview :as preview]
5+
[quo2.foundations.colors :as colors]
6+
[quo2.components.status-tags :as quo2]))
7+
8+
(def descriptor [{:label "Status"
9+
:key :status
10+
:type :select
11+
:options [{:value "Positive"
12+
:key :positive}
13+
{:value "Negative"
14+
:key :negative}
15+
{:value "Pending"
16+
:key :pending}]}
17+
{:label "Size"
18+
:key :size
19+
:type :select
20+
:options [{:value "Small"
21+
:key :small}
22+
{:value "Large"
23+
:key :large}]}])
24+
25+
(defn cool-preview []
26+
(let [state (reagent/atom {:status :positive
27+
:size :small})]
28+
(fn []
29+
[rn/view {:margin-bottom 50
30+
:padding 16}
31+
[rn/view {:flex 1}
32+
[preview/customizer state descriptor]]
33+
[rn/view {:padding-vertical 60
34+
:flex-direction :row
35+
:justify-content :center}
36+
[quo2/status-tag @state]]])))
37+
38+
(defn preview-status-tags []
39+
[rn/view {:background-color (colors/theme-colors colors/white
40+
colors/neutral-90)
41+
:flex 1}
42+
[rn/flat-list {:flex 1
43+
:keyboardShouldPersistTaps :always
44+
:header [cool-preview]
45+
:key-fn str}]])

src/status_im/multiaccounts/create/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
:color colors/blue-persist
145145
:wallet true
146146
:path constants/path-default-wallet
147-
:name (i18n/label :t/ethereum-account)})
147+
:name (i18n/label :t/main-account)})
148148
(let [{:keys [public-key address name identicon]}
149149
(get-in multiaccount [:derived constants/path-whisper-keyword])]
150150
{:public-key public-key

translations/en.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@
15131513
"once-enabled-share-metadata": "Once enabled, links posted in the chat may share your metadata with the site",
15141514
"external-storage-denied": "Access to external storage is denied",
15151515
"timeline": "Timeline",
1516-
"ethereum-account": "Ethereum account",
1516+
"main-account": "Main account",
15171517
"ethereum-address":"Ethereum address",
15181518
"default-assets": "Default ERC20 and ERC721",
15191519
"increase-gas": "Increase Gas",
@@ -1753,5 +1753,8 @@
17531753
"contact-request-accepted": "Accepted ✓",
17541754
"contact-request-pending": "Pending...",
17551755
"removed-from-contacts": "Removed from contacts",
1756-
"mutual-contact-requests": "Mutual contact requests"
1756+
"mutual-contact-requests": "Mutual contact requests",
1757+
"pending": "Pending",
1758+
"negative": "Negative",
1759+
"positive": "Positive"
17571760
}

0 commit comments

Comments
 (0)