[#4008] Users can set currency
This commit is contained in:
parent
9b17cdd306
commit
35983aa3d6
|
@ -98,6 +98,101 @@
|
|||
:name "Status mainnet mailserver"
|
||||
:address "enode://b963569aac14785f756ecf97e7549a513dea993a1bc744c4f8efe2b4e9479500dd3f5d18f3da19f6550b8bd0d8770350950c9a7da8168b44865402dcc9a51657@51.15.35.110:30403"}}})
|
||||
|
||||
(def currencies
|
||||
{:aed {:id :aed :code "AED" :display-name (i18n/label :t/currency-display-name-aed) :symbol "د.إ"}
|
||||
:afn {:id :afn :code "AFN" :display-name (i18n/label :t/currency-display-name-afn) :symbol "؋"}
|
||||
:ars {:id :ars :code "ARS" :display-name (i18n/label :t/currency-display-name-ars) :symbol "$"}
|
||||
:aud {:id :aud :code "AUD" :display-name (i18n/label :t/currency-display-name-aud) :symbol "$"}
|
||||
:bbd {:id :bbd :code "BBD" :display-name (i18n/label :t/currency-display-name-bbd) :symbol "$"}
|
||||
:bdt {:id :bdt :code "BDT" :display-name (i18n/label :t/currency-display-name-bdt) :symbol " Tk"}
|
||||
:bgn {:id :bgn :code "BGN" :display-name (i18n/label :t/currency-display-name-bgn) :symbol "лв"}
|
||||
:bhd {:id :bhd :code "BHD" :display-name (i18n/label :t/currency-display-name-bhd) :symbol "BD"}
|
||||
:bmd {:id :bmd :code "BMD" :display-name (i18n/label :t/currency-display-name-bmd) :symbol "$"}
|
||||
:bnd {:id :bnd :code "BND" :display-name (i18n/label :t/currency-display-name-bnd) :symbol "$"}
|
||||
:bob {:id :bob :code "BOB" :display-name (i18n/label :t/currency-display-name-bob) :symbol "$b"}
|
||||
:brl {:id :brl :code "BRL" :display-name (i18n/label :t/currency-display-name-brl) :symbol "R$"}
|
||||
:btn {:id :btn :code "BTN" :display-name (i18n/label :t/currency-display-name-btn) :symbol "Nu."}
|
||||
:bzd {:id :bzd :code "BZD" :display-name (i18n/label :t/currency-display-name-bzd) :symbol "BZ$"}
|
||||
:cad {:id :cad :code "CAD" :display-name (i18n/label :t/currency-display-name-cad) :symbol "$"}
|
||||
:chf {:id :chf :code "CHF" :display-name (i18n/label :t/currency-display-name-chf) :symbol "CHF"}
|
||||
:clp {:id :clp :code "CLP" :display-name (i18n/label :t/currency-display-name-clp) :symbol "$"}
|
||||
:cny {:id :cny :code "CNY" :display-name (i18n/label :t/currency-display-name-cny) :symbol "¥"}
|
||||
:cop {:id :cop :code "COP" :display-name (i18n/label :t/currency-display-name-cop) :symbol "$"}
|
||||
:crc {:id :crc :code "CRC" :display-name (i18n/label :t/currency-display-name-crc) :symbol "₡"}
|
||||
:czk {:id :czk :code "CZK" :display-name (i18n/label :t/currency-display-name-czk) :symbol "Kč"}
|
||||
:dkk {:id :dkk :code "DKK" :display-name (i18n/label :t/currency-display-name-dkk) :symbol "kr"}
|
||||
:dop {:id :dop :code "DOP" :display-name (i18n/label :t/currency-display-name-dop) :symbol "RD$"}
|
||||
:egp {:id :egp :code "EGP" :display-name (i18n/label :t/currency-display-name-egp) :symbol "£"}
|
||||
:etb {:id :etb :code "ETB" :display-name (i18n/label :t/currency-display-name-etb) :symbol "Br"}
|
||||
:eur {:id :eur :code "EUR" :display-name (i18n/label :t/currency-display-name-eur) :symbol "€"}
|
||||
:gbp {:id :gbp :code "GBP" :display-name (i18n/label :t/currency-display-name-gbp) :symbol "£"}
|
||||
:gel {:id :gel :code "GEL" :display-name (i18n/label :t/currency-display-name-gel) :symbol "₾"}
|
||||
:ghs {:id :ghs :code "GHS" :display-name (i18n/label :t/currency-display-name-ghs) :symbol "¢"}
|
||||
:gmd {:id :gmd :code "GMD" :display-name (i18n/label :t/currency-display-name-gmd) :symbol "D"}
|
||||
:gyd {:id :gyd :code "GYD" :display-name (i18n/label :t/currency-display-name-gyd) :symbol "$"}
|
||||
:hkd {:id :hkd :code "HKD" :display-name (i18n/label :t/currency-display-name-hkd) :symbol "$"}
|
||||
:hrk {:id :hrk :code "HRK" :display-name (i18n/label :t/currency-display-name-hrk) :symbol "kn"}
|
||||
:huf {:id :huf :code "HUF" :display-name (i18n/label :t/currency-display-name-huf) :symbol "Ft"}
|
||||
:idr {:id :idr :code "IDR" :display-name (i18n/label :t/currency-display-name-idr) :symbol "Rp"}
|
||||
:ils {:id :ils :code "ILS" :display-name (i18n/label :t/currency-display-name-ils) :symbol "₪"}
|
||||
:inr {:id :inr :code "INR" :display-name (i18n/label :t/currency-display-name-inr) :symbol "₹"}
|
||||
:isk {:id :isk :code "ISK" :display-name (i18n/label :t/currency-display-name-isk) :symbol "kr"}
|
||||
:jmd {:id :jmd :code "JMD" :display-name (i18n/label :t/currency-display-name-jmd) :symbol "J$"}
|
||||
:jpy {:id :jpy :code "JPY" :display-name (i18n/label :t/currency-display-name-jpy) :symbol "¥"}
|
||||
:kes {:id :kes :code "KES" :display-name (i18n/label :t/currency-display-name-kes) :symbol "KSh"}
|
||||
:krw {:id :krw :code "KRW" :display-name (i18n/label :t/currency-display-name-krw) :symbol "₩"}
|
||||
:kwd {:id :kwd :code "KWD" :display-name (i18n/label :t/currency-display-name-kwd) :symbol "د.ك"}
|
||||
:kyd {:id :kyd :code "KYD" :display-name (i18n/label :t/currency-display-name-kyd) :symbol "$"}
|
||||
:kzt {:id :kzt :code "KZT" :display-name (i18n/label :t/currency-display-name-kzt) :symbol "лв"}
|
||||
:lak {:id :lak :code "LAK" :display-name (i18n/label :t/currency-display-name-lak) :symbol "₭"}
|
||||
:lkr {:id :lkr :code "LKR" :display-name (i18n/label :t/currency-display-name-lkr) :symbol "₨"}
|
||||
:lrd {:id :lrd :code "LRD" :display-name (i18n/label :t/currency-display-name-lrd) :symbol "$"}
|
||||
:ltl {:id :ltl :code "LTL" :display-name (i18n/label :t/currency-display-name-ltl) :symbol "Lt"}
|
||||
:mad {:id :mad :code "MAD" :display-name (i18n/label :t/currency-display-name-mad) :symbol "MAD"}
|
||||
:mdl {:id :mdl :code "MDL" :display-name (i18n/label :t/currency-display-name-mdl) :symbol "MDL"}
|
||||
:mkd {:id :mkd :code "MKD" :display-name (i18n/label :t/currency-display-name-mkd) :symbol "ден"}
|
||||
:mnt {:id :mnt :code "MNT" :display-name (i18n/label :t/currency-display-name-mnt) :symbol "₮"}
|
||||
:mur {:id :mur :code "MUR" :display-name (i18n/label :t/currency-display-name-mur) :symbol "₨"}
|
||||
:mwk {:id :mwk :code "MWK" :display-name (i18n/label :t/currency-display-name-mwk) :symbol "MK"}
|
||||
:mxn {:id :mxn :code "MXN" :display-name (i18n/label :t/currency-display-name-mxn) :symbol "$"}
|
||||
:myr {:id :myr :code "MYR" :display-name (i18n/label :t/currency-display-name-myr) :symbol "RM"}
|
||||
:mzn {:id :mzn :code "MZN" :display-name (i18n/label :t/currency-display-name-mzn) :symbol "MT"}
|
||||
:nad {:id :nad :code "NAD" :display-name (i18n/label :t/currency-display-name-nad) :symbol "$"}
|
||||
:ngn {:id :ngn :code "NGN" :display-name (i18n/label :t/currency-display-name-ngn) :symbol "₦"}
|
||||
:nio {:id :nio :code "NIO" :display-name (i18n/label :t/currency-display-name-nio) :symbol "C$"}
|
||||
:nok {:id :nok :code "NOK" :display-name (i18n/label :t/currency-display-name-nok) :symbol "kr"}
|
||||
:npr {:id :npr :code "NPR" :display-name (i18n/label :t/currency-display-name-npr) :symbol "₨"}
|
||||
:nzd {:id :nzd :code "NZD" :display-name (i18n/label :t/currency-display-name-nzd) :symbol "$"}
|
||||
:omr {:id :omr :code "OMR" :display-name (i18n/label :t/currency-display-name-omr) :symbol "﷼"}
|
||||
:pen {:id :pen :code "PEN" :display-name (i18n/label :t/currency-display-name-pen) :symbol "S/."}
|
||||
:pgk {:id :pgk :code "PGK" :display-name (i18n/label :t/currency-display-name-pgk) :symbol "K"}
|
||||
:php {:id :php :code "PHP" :display-name (i18n/label :t/currency-display-name-php) :symbol "₱"}
|
||||
:pkr {:id :pkr :code "PKR" :display-name (i18n/label :t/currency-display-name-pkr) :symbol "₨"}
|
||||
:pln {:id :pln :code "PLN" :display-name (i18n/label :t/currency-display-name-pln) :symbol "zł"}
|
||||
:pyg {:id :pyg :code "PYG" :display-name (i18n/label :t/currency-display-name-pyg) :symbol "Gs"}
|
||||
:qar {:id :qar :code "QAR" :display-name (i18n/label :t/currency-display-name-qar) :symbol "﷼"}
|
||||
:ron {:id :ron :code "RON" :display-name (i18n/label :t/currency-display-name-ron) :symbol "lei"}
|
||||
:rsd {:id :rsd :code "RSD" :display-name (i18n/label :t/currency-display-name-rsd) :symbol "Дин."}
|
||||
:rub {:id :rub :code "RUB" :display-name (i18n/label :t/currency-display-name-rub) :symbol "₽"}
|
||||
:sar {:id :sar :code "SAR" :display-name (i18n/label :t/currency-display-name-sar) :symbol "﷼"}
|
||||
:sek {:id :sek :code "SEK" :display-name (i18n/label :t/currency-display-name-sek) :symbol "kr"}
|
||||
:sgd {:id :sgd :code "SGD" :display-name (i18n/label :t/currency-display-name-sgd) :symbol "$"}
|
||||
:sos {:id :sos :code "SOS" :display-name (i18n/label :t/currency-display-name-sos) :symbol "S"}
|
||||
:srd {:id :srd :code "SRD" :display-name (i18n/label :t/currency-display-name-srd) :symbol "$"}
|
||||
:thb {:id :thb :code "THB" :display-name (i18n/label :t/currency-display-name-thb) :symbol "฿"}
|
||||
:ttd {:id :ttd :code "TTD" :display-name (i18n/label :t/currency-display-name-ttd) :symbol "TT$"}
|
||||
:twd {:id :twd :code "TWD" :display-name (i18n/label :t/currency-display-name-twd) :symbol "NT$"}
|
||||
:tzs {:id :tzs :code "TZS" :display-name (i18n/label :t/currency-display-name-tzs) :symbol "TSh"}
|
||||
:try {:id :try :code "TRY" :display-name (i18n/label :t/currency-display-name-try) :symbol "₺"}
|
||||
:uah {:id :uah :code "UAH" :display-name (i18n/label :t/currency-display-name-uah) :symbol "₴"}
|
||||
:ugx {:id :ugx :code "UGX" :display-name (i18n/label :t/currency-display-name-ugx) :symbol "USh"}
|
||||
:uyu {:id :uyu :code "UYU" :display-name (i18n/label :t/currency-display-name-uyu) :symbol "$U"}
|
||||
:usd {:id :usd :code "USD" :display-name (i18n/label :t/currency-display-name-usd) :symbol "$"}
|
||||
:vef {:id :vef :code "VEF" :display-name (i18n/label :t/currency-display-name-vef) :symbol "Bs"}
|
||||
:vnd {:id :vnd :code "VND" :display-name (i18n/label :t/currency-display-name-vnd) :symbol "₫"}
|
||||
:yer {:id :yer :code "YER" :display-name (i18n/label :t/currency-display-name-yer) :symbol "﷼"}
|
||||
:zar {:id :zar :code "ZAR" :display-name (i18n/label :t/currency-display-name-zar) :symbol "R"}})
|
||||
|
||||
(def inbox-password "status-offline-inbox")
|
||||
|
||||
;; Used to generate topic for contact discoveries
|
||||
|
|
|
@ -418,6 +418,99 @@
|
|||
:gwei "Gwei"
|
||||
:currency "Currency"
|
||||
:usd-currency "USD"
|
||||
:currency-display-name-aed "Emirati Dirham"
|
||||
:currency-display-name-afn "Afghanistan Afghani"
|
||||
:currency-display-name-ars "Argentine Peso"
|
||||
:currency-display-name-aud "Australian Dollar"
|
||||
:currency-display-name-bbd "Barbados Dollar"
|
||||
:currency-display-name-bdt "Bangladeshi Taka"
|
||||
:currency-display-name-bgn "Bulgarian Lev"
|
||||
:currency-display-name-bhd "Bahraini Dinar"
|
||||
:currency-display-name-bmd "Bermuda Dollar"
|
||||
:currency-display-name-bnd "Brunei Darussalam Dollar"
|
||||
:currency-display-name-bob "Bolivia Bolíviano"
|
||||
:currency-display-name-brl "Brazil Real"
|
||||
:currency-display-name-btn "Bhutanese Ngultrum"
|
||||
:currency-display-name-bzd "Belize Dollar"
|
||||
:currency-display-name-cad "Canada Dollar"
|
||||
:currency-display-name-chf "Switzerland Franc"
|
||||
:currency-display-name-clp "Chile Peso"
|
||||
:currency-display-name-cny "China Yuan Renminbi"
|
||||
:currency-display-name-cop "Colombia Peso"
|
||||
:currency-display-name-crc "Costa Rica Colon"
|
||||
:currency-display-name-czk "Czech Koruna"
|
||||
:currency-display-name-dkk "Denmark Krone"
|
||||
:currency-display-name-dop "Dominican Republic Peso"
|
||||
:currency-display-name-egp "Egypt Pound"
|
||||
:currency-display-name-etb "Ethiopian Birr"
|
||||
:currency-display-name-eur "Euro"
|
||||
:currency-display-name-gbp "British Pound"
|
||||
:currency-display-name-gel "Georgian Lari"
|
||||
:currency-display-name-ghs "Ghana Cedi"
|
||||
:currency-display-name-gmd "Gambian dalasi"
|
||||
:currency-display-name-gyd "Guyana Dollar"
|
||||
:currency-display-name-hkd "Hong Kong Dollar"
|
||||
:currency-display-name-hrk "Croatia Kuna"
|
||||
:currency-display-name-huf "Hungary Forint"
|
||||
:currency-display-name-idr "Indonesia Rupiah"
|
||||
:currency-display-name-ils "Israel Shekel"
|
||||
:currency-display-name-inr "India Rupee"
|
||||
:currency-display-name-isk "Iceland Krona"
|
||||
:currency-display-name-jmd "Jamaica Dollar"
|
||||
:currency-display-name-jpy "Japanese Yen"
|
||||
:currency-display-name-kes "Kenyan Shilling"
|
||||
:currency-display-name-krw "Korea (South) Won"
|
||||
:currency-display-name-kwd "Kuwaiti Dinar"
|
||||
:currency-display-name-kyd "Cayman Islands Dollar"
|
||||
:currency-display-name-kzt "Kazakhstan Tenge"
|
||||
:currency-display-name-lak "Laos Kip"
|
||||
:currency-display-name-lkr "Sri Lanka Rupee"
|
||||
:currency-display-name-lrd "Liberia Dollar"
|
||||
:currency-display-name-ltl "Lithuanian Litas"
|
||||
:currency-display-name-mad "Moroccan Dirham"
|
||||
:currency-display-name-mdl "Moldovan Leu"
|
||||
:currency-display-name-mkd "Macedonia Denar"
|
||||
:currency-display-name-mnt "Mongolia Tughrik"
|
||||
:currency-display-name-mur "Mauritius Rupee"
|
||||
:currency-display-name-mwk "Malawian Kwacha"
|
||||
:currency-display-name-mxn "Mexico Peso"
|
||||
:currency-display-name-myr "Malaysia Ringgit"
|
||||
:currency-display-name-mzn "Mozambique Metical"
|
||||
:currency-display-name-nad "Namibia Dollar"
|
||||
:currency-display-name-ngn "Nigeria Naira"
|
||||
:currency-display-name-nio "Nicaragua Cordoba"
|
||||
:currency-display-name-nok "Norway Krone"
|
||||
:currency-display-name-npr "Nepal Rupee"
|
||||
:currency-display-name-nzd "New Zealand Dollar"
|
||||
:currency-display-name-omr "Oman Rial"
|
||||
:currency-display-name-pen "Peru Sol"
|
||||
:currency-display-name-pgk "Papua New Guinean Kina"
|
||||
:currency-display-name-php "Philippines Peso"
|
||||
:currency-display-name-pkr "Pakistan Rupee"
|
||||
:currency-display-name-pln "Poland Zloty"
|
||||
:currency-display-name-pyg "Paraguay Guarani"
|
||||
:currency-display-name-qar "Qatar Riyal"
|
||||
:currency-display-name-ron "Romania Leu"
|
||||
:currency-display-name-rsd "Serbia Dinar"
|
||||
:currency-display-name-rub "Russia Ruble"
|
||||
:currency-display-name-sar "Saudi Arabia Riyal"
|
||||
:currency-display-name-sek "Sweden Krona"
|
||||
:currency-display-name-sgd "Singapore Dollar"
|
||||
:currency-display-name-sos "Somalia Shilling"
|
||||
:currency-display-name-srd "Suriname Dollar"
|
||||
:currency-display-name-thb "Thailand Baht"
|
||||
:currency-display-name-ttd "Trinidad and Tobago Dollar"
|
||||
:currency-display-name-twd "Taiwan New Dollar"
|
||||
:currency-display-name-tzs "Tanzanian Shilling"
|
||||
:currency-display-name-try "Turkish Lira"
|
||||
:currency-display-name-uah "Ukraine Hryvnia"
|
||||
:currency-display-name-ugx "Ugandan Shilling"
|
||||
:currency-display-name-uyu "Uruguay Peso"
|
||||
:currency-display-name-usd "United States Dollar"
|
||||
:currency-display-name-vef "Venezuela Bolívar"
|
||||
:currency-display-name-vnd "Viet Nam Dong"
|
||||
:currency-display-name-yer "Yemen Rial"
|
||||
:currency-display-name-zar "South Africa Rand"
|
||||
:amount-placeholder "Specify amount..."
|
||||
:transactions "Transactions"
|
||||
:transaction-details "Transaction details"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
(ns status-im.ui.screens.currency-settings.events
|
||||
(:require [status-im.ui.screens.accounts.events :as accounts]
|
||||
[status-im.utils.handlers :as handlers]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.settings/set-currency
|
||||
(fn [{:keys [db] :as cofx} [_ currency]]
|
||||
(let [settings (get-in db [:account/account :settings])
|
||||
new-settings (assoc-in settings [:wallet :currency] currency)]
|
||||
(accounts/update-settings new-settings cofx))))
|
|
@ -0,0 +1,23 @@
|
|||
(ns status-im.ui.screens.currency-settings.styles
|
||||
(:require-macros [status-im.utils.styles :refer [defstyle]])
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def wrapper
|
||||
{:flex 1
|
||||
:background-color :white})
|
||||
|
||||
(defstyle currency-item
|
||||
{:flex-direction :row
|
||||
:justify-content :space-between
|
||||
:background-color :white
|
||||
:align-items :center
|
||||
:padding-horizontal 16
|
||||
:ios {:height 64}
|
||||
:android {:height 56}})
|
||||
|
||||
(defstyle currency-name-text
|
||||
{:color colors/black
|
||||
:ios {:font-size 17
|
||||
:letter-spacing -0.2
|
||||
:line-height 20}
|
||||
:android {:font-size 16}})
|
|
@ -0,0 +1,8 @@
|
|||
(ns status-im.ui.screens.currency-settings.subs
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet.settings/currency
|
||||
:<- [:get-current-account]
|
||||
(fn [current-account]
|
||||
(or (get-in current-account [:settings :wallet :currency]) :usd)))
|
|
@ -0,0 +1,38 @@
|
|||
(ns status-im.ui.screens.currency-settings.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.ui.components.status-bar.view :as status-bar]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.screens.profile.components.views :as profile.components]
|
||||
[status-im.ui.screens.currency-settings.styles :as styles]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(defn render-currency [current-currency-id]
|
||||
(fn [{:keys [id code display-name] :as currency}]
|
||||
(let [selected? (= id current-currency-id)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:wallet.settings/set-currency id])
|
||||
:accessibility-label :currency-item}
|
||||
[react/view styles/currency-item
|
||||
[react/text {:style styles/currency-name-text}
|
||||
(str display-name " (" code ")")]
|
||||
(when selected?
|
||||
[vector-icons/icon :icons/ok {:color :active}])]])))
|
||||
|
||||
(views/defview currency-settings []
|
||||
(views/letsubs [currency-id [:wallet.settings/currency]]
|
||||
[react/view {:flex 1}
|
||||
[status-bar/status-bar]
|
||||
[toolbar/simple-toolbar
|
||||
(i18n/label :t/main-currency)]
|
||||
[react/view styles/wrapper
|
||||
[list/flat-list {:data (->> constants/currencies
|
||||
vals
|
||||
(sort #(compare (:code %1) (:code %2))))
|
||||
:key-fn :code
|
||||
:separator (profile.components/settings-item-separator)
|
||||
:render-fn (render-currency currency-id)}]]]))
|
|
@ -24,6 +24,7 @@
|
|||
status-im.ui.screens.wallet.choose-recipient.events
|
||||
status-im.ui.screens.browser.events
|
||||
status-im.ui.screens.offline-messaging-settings.events
|
||||
status-im.ui.screens.currency-settings.events
|
||||
status-im.ui.screens.usage-data.events
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.native-module.core :as status]
|
||||
|
|
|
@ -95,13 +95,14 @@
|
|||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:logout encryption-key])))))
|
||||
|
||||
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]} sharing-usage-data?]
|
||||
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]} currency]
|
||||
(let [show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))]
|
||||
[react/view
|
||||
[profile.components/settings-title (i18n/label :t/settings)]
|
||||
[profile.components/settings-item {:label-kw :t/main-currency
|
||||
:value (i18n/label :usd-currency)
|
||||
:active? false}]
|
||||
:value (:code currency)
|
||||
:action-fn #(re-frame/dispatch [:navigate-to :currency-settings])
|
||||
:accessibility-label :currency-button}]
|
||||
[profile.components/settings-item-separator]
|
||||
[profile.components/settings-item {:label-kw :t/notifications
|
||||
:accessibility-label :notifications-button
|
||||
|
@ -165,7 +166,8 @@
|
|||
(defview my-profile []
|
||||
(letsubs [{:keys [public-key] :as current-account} [:get-current-account]
|
||||
editing? [:get :my-profile/editing?]
|
||||
changed-account [:get :my-profile/profile]]
|
||||
changed-account [:get :my-profile/profile]
|
||||
currency [:wallet/currency]]
|
||||
(let [shown-account (merge current-account changed-account)]
|
||||
[react/view profile.components.styles/profile
|
||||
(if editing?
|
||||
|
@ -177,5 +179,5 @@
|
|||
[react/view action-button.styles/actions-list
|
||||
[share-contact-code current-account public-key]]
|
||||
[react/view styles/my-profile-info-container
|
||||
[my-profile-settings current-account]]
|
||||
[my-profile-settings current-account currency]]
|
||||
[advanced shown-account]]])))
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
status-im.ui.screens.wallet.transactions.subs
|
||||
status-im.ui.screens.network-settings.subs
|
||||
status-im.ui.screens.offline-messaging-settings.subs
|
||||
status-im.ui.screens.currency-settings.subs
|
||||
status-im.ui.screens.browser.subs
|
||||
status-im.bots.subs
|
||||
status-im.ui.screens.add-new.new-chat.subs
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
[status-im.ui.screens.network-settings.views :refer [network-settings]]
|
||||
[status-im.ui.screens.network-settings.network-details.views :refer [network-details]]
|
||||
[status-im.ui.screens.offline-messaging-settings.views :refer [offline-messaging-settings]]
|
||||
[status-im.ui.screens.currency-settings.views :refer [currency-settings]]
|
||||
[status-im.ui.screens.browser.views :refer [browser]]
|
||||
[status-im.ui.screens.add-new.open-dapp.views :refer [open-dapp dapp-description]]
|
||||
[status-im.ui.screens.intro.views :refer [intro]]
|
||||
|
@ -153,6 +154,7 @@
|
|||
:network-settings network-settings
|
||||
:network-details network-details
|
||||
:offline-messaging-settings offline-messaging-settings
|
||||
:currency-settings currency-settings
|
||||
:recent-recipients recent-recipients
|
||||
:recipient-qr-code recipient-qr-code
|
||||
:contact-code contact-code
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
[status-im.utils.transactions :as transactions]
|
||||
[taoensso.timbre :as log]
|
||||
status-im.ui.screens.wallet.request.events
|
||||
[status-im.utils.money :as money]))
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(defn get-balance [{:keys [web3 account-id on-success on-error]}]
|
||||
(if (and web3 account-id)
|
||||
|
@ -100,11 +101,12 @@
|
|||
;; Handlers
|
||||
(handlers/register-handler-fx
|
||||
:update-wallet
|
||||
(fn [{{:keys [web3 account/account network network-status] :as db} :db} _]
|
||||
(fn [{{:keys [web3 account/account network network-status] {:keys [address settings]} :account/account :as db} :db} _]
|
||||
(let [chain (ethereum/network->chain-keyword network)
|
||||
mainnet? (= :mainnet chain)
|
||||
address (:address account)
|
||||
symbols (get-in account [:settings :wallet :visible-tokens chain])]
|
||||
symbols (get-in settings [:wallet :visible-tokens chain])
|
||||
currency-id (or (get-in settings [:wallet :currency]) :usd)
|
||||
currency (get constants/currencies currency-id)]
|
||||
(when (not= network-status :offline)
|
||||
{:get-balance {:web3 web3
|
||||
:account-id address
|
||||
|
@ -117,7 +119,7 @@
|
|||
:success-event :update-token-balance-success
|
||||
:error-event :update-token-balance-fail}
|
||||
:get-prices {:from (if mainnet? (conj symbols "ETH") ["ETH"])
|
||||
:to ["USD"]
|
||||
:to [(:code currency)]
|
||||
:success-event :update-prices-success
|
||||
:error-event :update-prices-fail}
|
||||
:db (-> db
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
(ns status-im.ui.screens.wallet.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.utils.ethereum.core :as ethereum]
|
||||
[status-im.utils.ethereum.tokens :as tokens]))
|
||||
[status-im.utils.ethereum.tokens :as tokens]
|
||||
[status-im.utils.money :as money]))
|
||||
|
||||
(re-frame/reg-sub :wallet
|
||||
(fn [db]
|
||||
|
@ -50,9 +51,14 @@
|
|||
(re-frame/reg-sub :portfolio-value
|
||||
:<- [:balance]
|
||||
:<- [:prices]
|
||||
(fn [[balance prices] [_ currency]]
|
||||
:<- [:wallet/currency]
|
||||
(fn [[balance prices currency] [_ currency-code]]
|
||||
(if (and balance prices)
|
||||
(let [balance-total-value (get-balance-total-value balance prices currency)]
|
||||
(let [balance-total-value
|
||||
(get-balance-total-value balance
|
||||
prices
|
||||
(or currency-code
|
||||
(-> currency :code keyword)))]
|
||||
(-> balance-total-value
|
||||
(money/with-precision 2)
|
||||
str))
|
||||
|
@ -97,3 +103,8 @@
|
|||
:<- [:wallet/visible-assets]
|
||||
(fn [[balance visible-assets]]
|
||||
(map #(assoc % :amount (get balance (:symbol %))) visible-assets)))
|
||||
|
||||
(re-frame/reg-sub :wallet/currency
|
||||
:<- [:wallet.settings/currency]
|
||||
(fn [currency-id]
|
||||
(get constants/currencies currency-id)))
|
||||
|
|
|
@ -22,16 +22,16 @@
|
|||
:options [{:label (i18n/label :t/wallet-manage-assets)
|
||||
:action #(re-frame/dispatch [:navigate-to-modal :wallet-settings-assets])}]}]]])
|
||||
|
||||
(defn- total-section [usd-value]
|
||||
(defn- total-section [value currency]
|
||||
[react/view styles/section
|
||||
[react/view {:style styles/total-balance-container}
|
||||
[react/view {:style styles/total-balance}
|
||||
[react/text {:style styles/total-balance-value
|
||||
:accessibility-label :total-amount-value-text}
|
||||
usd-value]
|
||||
value]
|
||||
[react/text {:style styles/total-balance-currency
|
||||
:accessibility-label :total-amount-currency-text}
|
||||
(i18n/label :t/usd-currency)]]
|
||||
(:code currency)]]
|
||||
[react/text {:style styles/total-value} (i18n/label :t/wallet-total-value)]]])
|
||||
|
||||
(def actions
|
||||
|
@ -48,8 +48,9 @@
|
|||
:icon :icons/transaction-history
|
||||
:action #(re-frame/dispatch [:navigate-to :transactions-history])}])
|
||||
|
||||
(defn- render-asset [{:keys [symbol icon decimals amount]}]
|
||||
(let [asset-value (re-frame/subscribe [:asset-value symbol :USD])]
|
||||
(defn- render-asset [currency]
|
||||
(fn [{:keys [symbol icon decimals amount]}]
|
||||
(let [asset-value (re-frame/subscribe [:asset-value symbol (-> currency :code keyword)])]
|
||||
[react/view {:style styles/asset-item-container}
|
||||
[list/item
|
||||
[list/item-image icon]
|
||||
|
@ -66,9 +67,9 @@
|
|||
[react/text {:style styles/asset-item-price
|
||||
:uppercase? true
|
||||
:number-of-lines 1}
|
||||
(if @asset-value (str "$" @asset-value) "...")]]]))
|
||||
(if @asset-value (str (:symbol currency) @asset-value) "...")]]])))
|
||||
|
||||
(defn- asset-section [assets]
|
||||
(defn- asset-section [assets currency]
|
||||
[react/view styles/asset-section
|
||||
[react/text {:style styles/asset-section-title} (i18n/label :t/wallet-assets)]
|
||||
[list/flat-list
|
||||
|
@ -76,11 +77,12 @@
|
|||
:scroll-enabled false
|
||||
:key-fn (comp str :symbol)
|
||||
:data assets
|
||||
:render-fn render-asset}]])
|
||||
:render-fn (render-asset currency)}]])
|
||||
|
||||
(views/defview wallet []
|
||||
(views/letsubs [assets [:wallet/visible-assets-with-amount]
|
||||
portfolio-value [:portfolio-value :USD]]
|
||||
currency [:wallet/currency]
|
||||
portfolio-value [:portfolio-value]]
|
||||
[react/view styles/main-section
|
||||
[toolbar-view]
|
||||
[react/scroll-view {:refresh-control
|
||||
|
@ -89,7 +91,7 @@
|
|||
:tint-color :white
|
||||
:refreshing false}])}
|
||||
[react/view {:style styles/scroll-top}] ;; Hack to allow different colors for top / bottom scroll view]
|
||||
[total-section portfolio-value]
|
||||
[total-section portfolio-value currency]
|
||||
[list/action-list actions
|
||||
{:container-style styles/action-section}]
|
||||
[asset-section assets]]]))
|
||||
[asset-section assets currency]]]))
|
||||
|
|
Loading…
Reference in New Issue