-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dea32f1
commit b1b80fe
Showing
5 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/assets.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 Asset from '@/types/Asset'; | ||
|
||
const ASSETS: Asset[] = [ | ||
{ name: 'USD Coin', symbol: 'USDC' }, | ||
{ name: 'Penumbra', symbol: 'UM' }, | ||
{ name: 'Cosmo', symbol: 'ATOM' }, | ||
{ name: 'Ethereum', symbol: 'ETH' }, | ||
{ name: 'Osmosis', symbol: 'OSMO' }, | ||
]; | ||
|
||
export default ASSETS; |
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
22 changes: 22 additions & 0 deletions
22
react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/useFilteredAssets.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,22 @@ | ||
import { useAppSelector } from '@/store/hooks'; | ||
import ASSETS from './assets'; | ||
import { useMemo } from 'react'; | ||
|
||
export default function useFilteredAssets() { | ||
const searchText = useAppSelector(state => state.defaultPaymentTokenScreen.searchText); | ||
|
||
const filteredTokens = useMemo( | ||
() => | ||
ASSETS.filter(asset => { | ||
const searchTextLowerCase = searchText.toLocaleLowerCase(); | ||
|
||
if (asset.name.toLocaleLowerCase().includes(searchTextLowerCase)) return true; | ||
if (asset.symbol.toLocaleLowerCase().includes(searchTextLowerCase)) return true; | ||
|
||
return false; | ||
}), | ||
[searchText], | ||
); | ||
|
||
return filteredTokens; | ||
} |
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,24 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
|
||
/** State specific to `DefaultPaymentTokenScreen`. */ | ||
export interface DefaultPaymentTokenScreenState { | ||
searchText: string; | ||
} | ||
|
||
const initialState: DefaultPaymentTokenScreenState = { | ||
searchText: '', | ||
}; | ||
|
||
export const defaultPaymentTokenScreenSlice = createSlice({ | ||
name: 'portfolioScreen', | ||
initialState, | ||
reducers: { | ||
setSearchText: (state, action: PayloadAction<string>) => { | ||
state.searchText = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setSearchText } = defaultPaymentTokenScreenSlice.actions; | ||
|
||
export default defaultPaymentTokenScreenSlice.reducer; |
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