-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/swap-layout
- Loading branch information
Showing
38 changed files
with
372 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
155 changes: 155 additions & 0 deletions
155
src/components/App/Settings/Currency/SelectCurrencyDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<template> | ||
<dialog-base :visible.sync="visibility" :title="t('currencyDialog.currency')" class="select-currency-dialog"> | ||
<search-input | ||
ref="search" | ||
v-model="query" | ||
class="select-currency__search" | ||
autofocus | ||
:placeholder="t('currencyDialog.searchPlaceholder')" | ||
@clear="handleClearSearch" | ||
/> | ||
<s-scrollbar class="select-currency-scrollbar"> | ||
<s-radio-group v-model="selectedCurrency" class="select-currency-list s-flex"> | ||
<s-radio | ||
v-for="currency in filteredCurrencies" | ||
:key="currency.key" | ||
:label="currency.key" | ||
:value="currency.key" | ||
:disabled="currency.disabled" | ||
size="medium" | ||
class="select-currency-list__item s-flex" | ||
> | ||
<div :ref="currency.key === selectedCurrency ? 'selectedEl' : undefined" class="select-currency-item s-flex"> | ||
<div class="select-currency-item__value"> | ||
{{ currency.name }} | ||
</div> | ||
<div class="select-currency-item__name"> | ||
{{ currency.symbol }} | ||
</div> | ||
</div> | ||
</s-radio> | ||
</s-radio-group> | ||
</s-scrollbar> | ||
</dialog-base> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { components } from '@soramitsu/soraneo-wallet-web'; | ||
import { Component, Mixins, Ref } from 'vue-property-decorator'; | ||
import TranslationMixin from '@/components/mixins/TranslationMixin'; | ||
import { state, mutation } from '@/store/decorators'; | ||
import type { CurrencyFields, Currency } from '@soramitsu/soraneo-wallet-web/lib/types/currency'; | ||
@Component({ | ||
components: { | ||
DialogBase: components.DialogBase, | ||
SearchInput: components.SearchInput, | ||
}, | ||
}) | ||
export default class SelectCurrencyDialog extends Mixins(TranslationMixin) { | ||
@state.wallet.settings.currencies currencies!: Array<CurrencyFields>; | ||
query = ''; | ||
@Ref('selectedEl') selectedEl!: Nullable<[HTMLDivElement]>; | ||
@state.settings.selectCurrencyDialogVisibility private selectCurrencyDialogVisibility!: boolean; | ||
@state.wallet.settings.currency private currency!: Currency; | ||
@mutation.settings.setSelectCurrencyDialogVisibility private setDialogVisibility!: (flag: boolean) => void; | ||
@mutation.wallet.settings.setFiatCurrency private setCurrency!: (currency: Currency) => Promise<void>; | ||
get visibility(): boolean { | ||
return this.selectCurrencyDialogVisibility; | ||
} | ||
set visibility(flag: boolean) { | ||
this.setDialogVisibility(flag); | ||
if (flag) { | ||
this.$nextTick(() => { | ||
this.selectedEl?.[0]?.scrollIntoView?.({ behavior: 'smooth' }); | ||
}); | ||
} | ||
} | ||
get selectedCurrency(): any { | ||
return this.currency; | ||
} | ||
set selectedCurrency(value: any) { | ||
this.setCurrency(value); | ||
} | ||
get filteredCurrencies() { | ||
const currencies = this.currencies; | ||
if (this.query) { | ||
const query = this.query.toLowerCase().trim(); | ||
return currencies.filter( | ||
(item) => | ||
item.name.toLowerCase().includes(query) || | ||
item.symbol.toLowerCase().includes(query) || | ||
item.key.toLocaleLowerCase().includes(query) | ||
); | ||
} | ||
return currencies; | ||
} | ||
public handleClearSearch(): void { | ||
this.query = ''; | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.dialog-wrapper.select-currency-dialog { | ||
.el-radio { | ||
margin-right: 0; | ||
} | ||
} | ||
.select-currency-scrollbar { | ||
@include scrollbar(-$inner-spacing-big); | ||
} | ||
</style> | ||
|
||
<style lang="scss" scoped> | ||
$item-height: 66px; | ||
$list-items: 7; | ||
.select-currency-list { | ||
height: 600px; | ||
flex-direction: column; | ||
max-height: calc(#{$item-height} * #{$list-items}); | ||
&__item { | ||
align-items: center; | ||
height: $item-height; | ||
padding: $inner-spacing-small $inner-spacing-big; | ||
border-radius: var(--s-border-radius-mini); | ||
} | ||
.select-currency-item { | ||
flex-direction: column; | ||
&__value { | ||
color: var(--s-color-base-content-primary); | ||
font-size: var(--s-font-size-medium); | ||
line-height: var(--s-line-height-medium); | ||
font-weight: 600; | ||
} | ||
&__name { | ||
color: var(--s-color-base-content-secondary); | ||
font-size: var(--s-font-size-mini); | ||
line-height: var(--s-line-height-medium); | ||
font-weight: 300; | ||
} | ||
} | ||
} | ||
.select-currency__search { | ||
margin-bottom: $basic-spacing; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.