From 1fbe885718a30f7976f0b899f3c1a3661c74b52a Mon Sep 17 00:00:00 2001 From: Mansurkhoja Date: Wed, 30 Mar 2022 17:34:54 +0500 Subject: [PATCH 01/14] feat: currency rates --- src/assets/stylus/components/_chat.styl | 10 +- src/assets/stylus/themes/adamant/_inputs.styl | 58 ++++++++++ src/components/AChat/AChatTransaction.vue | 32 +++++- src/components/Chat/Chat.vue | 7 +- src/components/CurrencySwitcher.vue | 102 +++++++++++++++++ src/components/SendFundsForm.vue | 58 +++++++--- src/components/TransactionListItem.vue | 24 +++- src/components/WalletCard.vue | 16 ++- .../__tests__/TransactionListItem.test.js | 2 +- .../transactions/TransactionTemplate.vue | 62 +++++++++- src/config/development.json | 3 + src/config/production.json | 3 + src/config/test.json | 3 + src/config/tor.json | 3 + .../{currency.js => currencyAmount.js} | 4 +- src/filters/currencyAmountWithSymbol.js | 15 +++ src/filters/helpers/index.js | 10 ++ src/i18n/de.json | 3 + src/i18n/en.json | 3 + src/i18n/ru.json | 3 + src/lib/constants.js | 15 ++- src/lib/notifications.js | 2 +- src/main.js | 2 +- src/mixins/transaction.js | 16 ++- src/store/index.js | 6 +- src/store/modules/options/index.js | 5 +- src/store/modules/rate/index.js | 107 ++++++++++++++++++ src/store/plugins/localStorage.js | 3 +- src/views/Home.vue | 35 +++++- src/views/Options.vue | 18 +++ src/views/Transactions.vue | 1 - 31 files changed, 591 insertions(+), 40 deletions(-) create mode 100644 src/components/CurrencySwitcher.vue rename src/filters/{currency.js => currencyAmount.js} (84%) create mode 100644 src/filters/currencyAmountWithSymbol.js create mode 100644 src/store/modules/rate/index.js diff --git a/src/assets/stylus/components/_chat.styl b/src/assets/stylus/components/_chat.styl index 9e6701216..4d828e9e7 100644 --- a/src/assets/stylus/components/_chat.styl +++ b/src/assets/stylus/components/_chat.styl @@ -181,7 +181,13 @@ $chat-avatar-size := 40px &--clickable cursor: pointer - + &__rates-column + flex-direction: column + &__rates + color: hsla(0,0%,100%,.7) + font-style: italic + font-size: 14px + font-weight: 300 &__status line-height: 1 margin-left: 8px @@ -257,6 +263,8 @@ $chat-avatar-size := 40px color: $adm-colors.muted &__amount color: $adm-colors.regular + &__rates + color: $adm-colors.muted &__direction color: $adm-colors.regular &__message-text diff --git a/src/assets/stylus/themes/adamant/_inputs.styl b/src/assets/stylus/themes/adamant/_inputs.styl index 92b41bd9b..840e4a8ec 100644 --- a/src/assets/stylus/themes/adamant/_inputs.styl +++ b/src/assets/stylus/themes/adamant/_inputs.styl @@ -17,6 +17,60 @@ &:after // [2] transition: unset +.fake-input + color: rgba(255,255,255,0.5) + font-weight: 400 + padding-top: 12px + margin-top: 4px + pointer-events: none + flex: 1 1 auto + font-size: 16px + text-align: left + display: flex + align-items: flex-start + min-height: inherit; + position: relative +.fake-input__label + left: 0px + right: auto + position: absolute + transform: translateY(-18px) scale(0.75) + overflow: hidden + text-overflow: ellipsis + top: 15px + transform-origin: top left + white-space: nowrap + max-width: 133% +.fake-input__box + width: 100% + padding-bottom: 20px + position: relative + display: flex + align-items: baseline + overflow: hidden +.fake-input__value + line-height: 32px + display: block; + text-overflow: ellipsis; + white-space: nowrap; +.fake-input__box:before + content: '' + border-image: repeating-linear-gradient(to right, rgba(255,255,255,0.5) 0px, rgba(255,255,255,0.5) 2px, transparent 2px, transparent 4px) 1 repeat + border-color: rgba(255,255,255,0.7) + border-style: solid + border-width: thin 0 0 0 + border-top-width: 1px + left: 0 + position: absolute + transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1) + width: 100% + top: 31px +.fake-input__value--rate + font-style: italic + padding-left: 3px + color: inherit !important + + .theme--light .a-input .v-label @@ -42,3 +96,7 @@ &.v-input--is-focused > .v-input__control > .v-input__slot:after // [3.c.] border-color: $adm-colors.primary2 border-width: thin 0 0 0 + .fake-input + color: rgba(0,0,0,0.54) + .fake-input__box:before + border-image: repeating-linear-gradient(to right, rgba(0,0,0,0.38) 0px, rgba(0,0,0,0.38) 2px, transparent 2px, transparent 4px) 1 repeat diff --git a/src/components/AChat/AChatTransaction.vue b/src/components/AChat/AChatTransaction.vue index 6430aeab6..1162a4786 100644 --- a/src/components/AChat/AChatTransaction.vue +++ b/src/components/AChat/AChatTransaction.vue @@ -38,7 +38,10 @@ > - {{ amount }} +
+ {{ amount | currency(crypto) }} + {{ historyRate }} +
@@ -56,6 +59,8 @@ + + diff --git a/src/components/SendFundsForm.vue b/src/components/SendFundsForm.vue index cddd7e97f..fa13f20a0 100644 --- a/src/components/SendFundsForm.vue +++ b/src/components/SendFundsForm.vue @@ -104,21 +104,29 @@ - - - +
+ {{ transferFeeLabel }} +
+
+ {{ transferFeeFixed }} {{ transferFeeCurrency }} + ~{{ transferFeeRate }} +
+ +
- + class="fake-input" + > +
+ {{ $t('transfer.final_amount_label') }} +
+
+ {{ finalAmountFixed }} {{ currency }} + ~{{ finalAmountRate }} +
+
- {{ amount | currency(crypto) }} + {{ historyRate }} - {{ balance | currency(crypto, true) }} + {{ balance | currency(crypto, true) }} ~{{ rate }} {{ currentCurrency }} @@ -97,6 +100,10 @@ export default { type: Number, required: true }, + rate: { + type: Number, + required: true + }, crypto: { type: String, default: 'ADM' @@ -104,6 +111,10 @@ export default { cryptoName: { type: String, default: 'ADAMANT' + }, + currentCurrency: { + type: String, + default: 'USD' } }, data: () => ({ showShareURIDialog: false }), @@ -129,6 +140,9 @@ export default { &__subtitle a-text-regular-enlarged() word-break: break-word + span + font-style: italic + color: inherit &__list padding: 8px 0 0 &__tile diff --git a/src/components/__tests__/TransactionListItem.test.js b/src/components/__tests__/TransactionListItem.test.js index c28791de9..b5769df21 100644 --- a/src/components/__tests__/TransactionListItem.test.js +++ b/src/components/__tests__/TransactionListItem.test.js @@ -4,7 +4,7 @@ import Vuex from 'vuex' import VueI18n from 'vue-i18n' import Vuetify from 'vuetify' -import currencyFilter from '@/filters/currency' +import currencyFilter from '@/filters/currencyAmountWithSymbol' import { EPOCH } from '@/lib/constants' import formatters from '@/lib/formatters' import mockupI18n from './__mocks__/plugins/i18n' diff --git a/src/components/transactions/TransactionTemplate.vue b/src/components/transactions/TransactionTemplate.vue index 19a6c7377..bec40eae7 100644 --- a/src/components/transactions/TransactionTemplate.vue +++ b/src/components/transactions/TransactionTemplate.vue @@ -11,7 +11,6 @@ flat :class="`${className}__toolbar`" /> - @@ -30,6 +29,43 @@ + + + + {{ $t('transaction.currentVal') }} + + + +
+ + {{ rate }} + +
+
+ + + + + + + {{ $t('transaction.valueTimeTxn') }} + + + +
+ + {{ historyRate }} + +
+
+ + @@ -229,9 +265,9 @@