|
| 1 | +(ns quo2.components.list-items.token-value.view |
| 2 | + (:require |
| 3 | + [clojure.string :as string] |
| 4 | + [quo2.components.icon :as icon] |
| 5 | + [quo2.components.markdown.text :as text] |
| 6 | + [quo2.foundations.colors :as colors] |
| 7 | + [quo2.foundations.resources :as resources] |
| 8 | + [quo2.theme :as quo.theme] |
| 9 | + [react-native.core :as rn] |
| 10 | + [quo2.foundations.common :as common] |
| 11 | + [quo2.components.list-items.token-value.style :as style])) |
| 12 | + |
| 13 | +(defn- internal-view |
| 14 | + [{:keys [theme customization-color state status token metrics? values]}] |
| 15 | + (let [bg-opacity (case state |
| 16 | + :active 10 |
| 17 | + :pressed 5 |
| 18 | + 0) |
| 19 | + {:keys [crypto-value fiat-value percentage-change fiat-change]} values] |
| 20 | + [rn/view |
| 21 | + {:style (style/container customization-color bg-opacity theme) |
| 22 | + :accessibility-label :container} |
| 23 | + [rn/view |
| 24 | + {:style {:flex-direction :row |
| 25 | + :align-items :center}} |
| 26 | + [rn/image |
| 27 | + {:source (resources/tokens token) |
| 28 | + :style {:width 32 |
| 29 | + :height 32}}] |
| 30 | + [rn/view {:style {:margin-left 8}} |
| 31 | + [text/text {:weight :semi-bold} (common/token-label token)] |
| 32 | + [text/text |
| 33 | + {:size :paragraph-2 |
| 34 | + :style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} |
| 35 | + (str crypto-value " " (string/upper-case (clj->js token)))]]] |
| 36 | + [rn/view |
| 37 | + {:style {:align-items :flex-end |
| 38 | + :justify-content :space-between}} |
| 39 | + [text/text |
| 40 | + {:weight :medium |
| 41 | + :size :paragraph-2} fiat-value] |
| 42 | + (when metrics? |
| 43 | + [rn/view |
| 44 | + {:style {:flex-direction :row |
| 45 | + :align-items :center}} |
| 46 | + [text/text |
| 47 | + {:size :paragraph-2 |
| 48 | + :style (style/metric-text status theme)} (str percentage-change "%")] |
| 49 | + [rn/view {:style (style/dot-divider status theme)}] |
| 50 | + [text/text |
| 51 | + {:size :paragraph-2 |
| 52 | + :style (style/metric-text status theme)} fiat-change] |
| 53 | + (when (not= status :empty) |
| 54 | + [rn/view |
| 55 | + {:style {:margin-left 4} |
| 56 | + :accessibility-label :arrow-icon} |
| 57 | + [icon/icon (if (= status :positive) :i/positive :i/negative) |
| 58 | + (style/arrow-icon status theme)]])])]])) |
| 59 | + |
| 60 | +(def view (quo.theme/with-theme internal-view)) |
0 commit comments