Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add currency conversions for signing sheet - Fixes #8027 #9063

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions src/status_im/ui/screens/signing/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@
(defn separator []
[react/view {:height 1 :background-color colors/gray-lighter}])

(defn acc-text [txt1 txt2]
[react/nested-text nil
txt1 " "
[{:style {:color colors/gray}} txt2]])

(defn displayed-name [contact]
(if (or (:preferred-name contact) (:name contact))
(multiaccounts/displayed-name contact)
Expand Down Expand Up @@ -218,9 +213,13 @@
sign [:signing/sign]
chain [:ethereum/chain-keyword]
{:keys [amount-error gas-error]} [:signing/amount-errors (:address from)]
keycard-multiaccount? [:keycard-multiaccount?]]
keycard-multiaccount? [:keycard-multiaccount?]
prices [:prices]
wallet-currency [:wallet/currency]]
(let [display-symbol (wallet.utils/display-symbol token)
fee-display-symbol (wallet.utils/display-symbol (tokens/native-currency chain))]
fee-display-symbol (wallet.utils/display-symbol (tokens/native-currency chain))
converted-value (* amount (get-in prices [(keyword display-symbol) (keyword (:code wallet-currency)) :price]))
converted-fee-value (* fee (get-in prices [(keyword fee-display-symbol) (keyword (:code wallet-currency)) :price]))]
[react/view styles/sheet
[header sign tx display-symbol fee fee-display-symbol]
[separator]
Expand All @@ -239,24 +238,43 @@
{:type :small
:title :t/send-request-amount
:error amount-error
:accessories [[acc-text (if amount (str amount) "0")
(or display-symbol fee-display-symbol)]]}]
[separator]])
[list-item/list-item
{:type :small
:title :t/network-fee
:error gas-error
:accessories [[acc-text fee fee-display-symbol] :chevron]
:on-press #(re-frame/dispatch
[:signing.ui/open-fee-sheet
{:content (fn [] [sheets/fee-bottom-sheet fee-display-symbol])
:content-height 270}])}]
[react/view {:align-items :center :margin-top 16 :margin-bottom 40}
(if keycard-multiaccount?
[sign-with-keycard-button amount-error gas-error]
[button/button {:on-press #(re-frame/dispatch [:set :signing/sign {:type :password}])
:disabled? (or amount-error gas-error)
:label :t/sign-with-password}])]])])))
:accessories [[react/nested-text {:style {:color colors/gray}}
[{:style {:color colors/black}} (if amount (str amount) "0")]
" "
(or display-symbol fee-display-symbol)
" • "
[{:style {:color colors/black}} (if converted-value (str "~" (i18n/format-currency converted-value (:code wallet-currency)))
[react/activity-indicator {:color :colors/gray
:ios {:size :small}
:android {:size :16}}])]
" "
(str (:code wallet-currency))]]}]
[separator]
[list-item/list-item
{:type :small
:title :t/network-fee
:error gas-error
:accessories [[react/nested-text {:style {:color colors/gray}}
[{:style {:color colors/black}} fee]
" "
fee-display-symbol
" • "
[{:style {:color colors/black}} (if converted-fee-value (str "~" (i18n/format-currency converted-fee-value (:code wallet-currency)))
[react/activity-indicator {:color :colors/gray
:ios {:size :small}
:android {:size :16}}])]
" "
(str (:code wallet-currency))] :chevron]
:on-press #(re-frame/dispatch
[:signing.ui/open-fee-sheet
{:content (fn [] [sheets/fee-bottom-sheet fee-display-symbol])
:content-height 270}])}]
[react/view {:align-items :center :margin-top 16 :margin-bottom 40}
(if keycard-multiaccount?
[sign-with-keycard-button amount-error gas-error]
[button/button {:on-press #(re-frame/dispatch [:set :signing/sign {:type :password}])
:disabled? (or amount-error gas-error)
:label :t/sign-with-password}])]])])])))

(defn signing-view [tx window-height]
(let [bottom-anim-value (anim/create-value window-height)
Expand Down