-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEX guideline page integration (#927)
* Added dex guidelines screen for first visit on dex navigations * Updated existing e2e for dex guideline screen * E2E test case for dex guideline screen * Removed DexContext dependancy for dex guideline * Updated Dex guide logic * Updated unit test case * bump * merge * center align button * breaking e2e Co-authored-by: thedoublejay <[email protected]>
- Loading branch information
1 parent
b80a227
commit 169bc7e
Showing
26 changed files
with
1,654 additions
and
2,233 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
20 changes: 20 additions & 0 deletions
20
mobile-app/app/api/persistence/display_dexguidelines_storage.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,20 @@ | ||
import AsyncStorage from '@react-native-async-storage/async-storage' | ||
|
||
/** | ||
* Display dex guideline storage provider | ||
*/ | ||
const KEY = 'WALLET.DISPLAY_DEXGUIDELINES' | ||
|
||
async function set (dexVisited: boolean): Promise<void> { | ||
await AsyncStorage.setItem(KEY, dexVisited.toString()) | ||
} | ||
|
||
async function get (): Promise<boolean> { | ||
const val = await AsyncStorage.getItem(KEY) | ||
return val !== 'false' | ||
} | ||
|
||
export const DisplayDexGuidelinesPersistence = { | ||
set, | ||
get | ||
} |
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
18 changes: 18 additions & 0 deletions
18
mobile-app/app/components/__snapshots__/Button.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
16 changes: 16 additions & 0 deletions
16
mobile-app/app/screens/AppNavigator/screens/Dex/DexGuidelines.test.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,16 @@ | ||
import { render, waitFor } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import { DexGuidelines } from './DexGuidelines' | ||
|
||
jest.mock('../../../../contexts/ThemeProvider') | ||
|
||
describe('Dex guide', () => { | ||
it('should match snapshot', async () => { | ||
const onClose = jest.fn | ||
const rendered = render( | ||
<DexGuidelines onClose={onClose} /> | ||
) | ||
await waitFor(() => rendered.toJSON() !== null) | ||
expect(rendered.toJSON()).toMatchSnapshot() | ||
}) | ||
}) |
99 changes: 99 additions & 0 deletions
99
mobile-app/app/screens/AppNavigator/screens/Dex/DexGuidelines.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,99 @@ | ||
import { MaterialIcons } from '@expo/vector-icons' | ||
import * as React from 'react' | ||
import { View } from '@components/index' | ||
import { Button } from '@components/Button' | ||
import { ThemedIcon, ThemedScrollView, ThemedText } from '@components/themed' | ||
import { tailwind } from '@tailwind' | ||
import { translate } from '@translations' | ||
|
||
interface Props { | ||
onClose: () => void | ||
} | ||
|
||
interface GuidelineItem { | ||
icon: React.ComponentProps<typeof MaterialIcons>['name'] | ||
title: string | ||
subtitle: string | ||
} | ||
|
||
// TODO (Harsh): handle language change bug, when user change the language, sometime it didnt get update the satic page | ||
export function DexGuidelines ({ onClose }: Props): JSX.Element { | ||
const guidelines: GuidelineItem[] = [ | ||
{ | ||
title: 'Add liquidity', | ||
subtitle: 'Earn high yields by supplying token pairs to the liquidity pool.', | ||
icon: 'add' | ||
}, | ||
{ | ||
title: 'Swap tokens', | ||
subtitle: 'Conveniently swap participating tokens within the liquidity pool.', | ||
icon: 'swap-horiz' | ||
}, | ||
{ | ||
title: 'Withdraw at any time', | ||
subtitle: 'You have full control over your tokens unlike any other.', | ||
icon: 'account-balance-wallet' | ||
} | ||
] | ||
|
||
return ( | ||
<ThemedScrollView | ||
dark={tailwind('bg-gray-900')} | ||
light={tailwind('bg-white')} | ||
style={tailwind('flex-1 p-4 pt-6')} | ||
testID='dex_guidelines_screen' | ||
> | ||
<ThemedText | ||
style={tailwind('text-lg font-semibold')} | ||
> | ||
{translate('screens/DexGuidelines', 'Decentralized Exchange')} | ||
</ThemedText> | ||
|
||
<ThemedText | ||
dark={tailwind('text-gray-400')} | ||
light={tailwind('text-gray-500')} | ||
style={tailwind('mt-1 text-sm font-medium mb-4')} | ||
> | ||
{translate('screens/DexGuidelines', 'Participate in supplying liquidity to power the DEX (Decentralized Exchange). Use your tokens to earn high returns (of up to 100%).')} | ||
</ThemedText> | ||
|
||
{ | ||
guidelines.map((g, i) => ( | ||
<View | ||
key={i} | ||
style={tailwind('flex-row items-center my-4')} | ||
> | ||
<ThemedIcon | ||
iconType='MaterialIcons' | ||
name={g.icon} | ||
size={32} | ||
/> | ||
|
||
<View style={tailwind('flex-col flex-auto ml-6')}> | ||
<ThemedText style={tailwind('font-medium')}> | ||
{translate('screens/DexGuidelines', g.title)} | ||
</ThemedText> | ||
|
||
<ThemedText | ||
dark={tailwind('text-gray-400')} | ||
light={tailwind('text-gray-500')} | ||
numberOfLines={4} | ||
style={tailwind('text-sm')} | ||
> | ||
{translate('screens/DexGuidelines', g.subtitle)} | ||
</ThemedText> | ||
</View> | ||
</View> | ||
)) | ||
} | ||
|
||
<Button | ||
label={translate('screens/DexGuidelines', 'CONTINUE')} | ||
margin='mx-0 mt-10 mb-8' | ||
onPress={onClose} | ||
testID='close_dex_guidelines' | ||
title={translate('screens/DexGuidelines', 'CONTINUE')} | ||
/> | ||
</ThemedScrollView> | ||
) | ||
} |
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.