-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1197 from alephium/region-mw
Region settings
- Loading branch information
Showing
25 changed files
with
1,801 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@alephium/mobile-wallet": patch | ||
--- | ||
|
||
Format amounts based on user's locale |
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,5 @@ | ||
--- | ||
"@alephium/mobile-wallet": patch | ||
--- | ||
|
||
Tap to reveal hidden amounts |
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
File renamed without changes.
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
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
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
48 changes: 48 additions & 0 deletions
48
apps/mobile-wallet/src/features/settings/regionSettings/RegionSelectModal.tsx
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,48 @@ | ||
import { FlashList } from '@shopify/flash-list' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { sendAnalytics } from '~/analytics' | ||
import RadioButtonRow from '~/components/RadioButtonRow' | ||
import BottomModalFlashList from '~/features/modals/BottomModalFlashList' | ||
import { closeModal } from '~/features/modals/modalActions' | ||
import withModal from '~/features/modals/withModal' | ||
import { numberFormatRegionChanged } from '~/features/settings/regionSettings/regionSettingsActions' | ||
import { regionOptions } from '~/features/settings/regionSettings/regionsUtils' | ||
import { useAppDispatch, useAppSelector } from '~/hooks/redux' | ||
|
||
const RegionSelectModal = withModal(({ id }) => { | ||
const dispatch = useAppDispatch() | ||
const { t } = useTranslation() | ||
const currentRegion = useAppSelector((s) => s.settings.region) | ||
|
||
const handleRegionChange = (region: string) => { | ||
dispatch(numberFormatRegionChanged(region)) | ||
dispatch(closeModal({ id })) | ||
sendAnalytics({ event: 'Region changed', props: { region } }) | ||
} | ||
|
||
return ( | ||
<BottomModalFlashList | ||
modalId={id} | ||
title={t('Region')} | ||
flashListRender={(props) => ( | ||
<FlashList | ||
data={regionOptions} | ||
estimatedItemSize={65} | ||
renderItem={({ item: regionOption, index }) => ( | ||
<RadioButtonRow | ||
key={regionOption.label} | ||
title={regionOption.label} | ||
onPress={() => handleRegionChange(regionOption.value)} | ||
isActive={currentRegion === regionOption.value} | ||
isLast={index === regionOptions.length - 1} | ||
/> | ||
)} | ||
{...props} | ||
/> | ||
)} | ||
/> | ||
) | ||
}) | ||
|
||
export default RegionSelectModal |
25 changes: 25 additions & 0 deletions
25
apps/mobile-wallet/src/features/settings/regionSettings/RegionSettingsRow.tsx
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,25 @@ | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import AppText from '~/components/AppText' | ||
import Row from '~/components/Row' | ||
import { openModal } from '~/features/modals/modalActions' | ||
import { regionOptions } from '~/features/settings/regionSettings/regionsUtils' | ||
import { useAppDispatch, useAppSelector } from '~/hooks/redux' | ||
|
||
const RegionSettingsRow = () => { | ||
const currentRegion = useAppSelector((s) => s.settings.region) | ||
const { t } = useTranslation() | ||
const dispatch = useAppDispatch() | ||
|
||
const openRegionSelectModal = () => dispatch(openModal({ name: 'RegionSelectModal' })) | ||
|
||
return ( | ||
<Row onPress={openRegionSelectModal} title={t('Region')}> | ||
<AppText bold style={{ textAlign: 'right' }}> | ||
{regionOptions.find((region) => region.value === currentRegion)?.label} | ||
</AppText> | ||
</Row> | ||
) | ||
} | ||
|
||
export default RegionSettingsRow |
11 changes: 11 additions & 0 deletions
11
apps/mobile-wallet/src/features/settings/regionSettings/regionSettingsActions.ts
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,11 @@ | ||
import { createAction } from '@reduxjs/toolkit' | ||
|
||
import { Settings } from '~/types/settings' | ||
|
||
export const numberFormatRegionChanged = createAction<Settings['general']['region']>( | ||
'settings/numberFormatRegionChanged' | ||
) | ||
|
||
export const systemRegionMatchSucceeded = createAction<string>('settings/systemRegionMatchSucceeded') | ||
|
||
export const systemRegionMatchFailed = createAction('settings/systemRegionMatchFailed') |
Oops, something went wrong.