Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-1888] Fix some bug related to UI and background #1889

Open
wants to merge 4 commits into
base: upgrade-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion html/DevModeWeb.bundle/site/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>SubWallet</title><script inline inline-asset="fallback.js$" inline-asset-delete></script><script inline inline-asset="web-runner.js$" inline-asset-delete></script><script defer="defer" src="fallback-0b81a7f9f3a8fbf3b257.js"></script><script defer="defer" src="web-runner-7e39a642b200fcd7f0d8.js"></script></head><body><div id="root">SubWallet</div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>SubWallet</title><script inline inline-asset="fallback.js$" inline-asset-delete></script><script inline inline-asset="web-runner.js$" inline-asset-delete></script><script defer="defer" src="fallback-0b81a7f9f3a8fbf3b257.js"></script><script defer="defer" src="web-runner-a04d239a3ee82e81aa2c.js"></script></head><body><div id="root">SubWallet</div></body></html>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/Web.bundle/site/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>SubWallet</title><script inline inline-asset="fallback.js$" inline-asset-delete></script><script inline inline-asset="web-runner.js$" inline-asset-delete></script><script defer="defer" src="fallback-0b81a7f9f3a8fbf3b257.js"></script><script defer="defer" src="web-runner-ae28e0063e546f407fa5.js"></script></head><body><div id="root">SubWallet</div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>SubWallet</title><script inline inline-asset="fallback.js$" inline-asset-delete></script><script inline inline-asset="web-runner.js$" inline-asset-delete></script><script defer="defer" src="fallback-0b81a7f9f3a8fbf3b257.js"></script><script defer="defer" src="web-runner-da47ab101888489727c6.js"></script></head><body><div id="root">SubWallet</div></body></html>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"@polkadot/api": "^12.0.2",
"@polkadot/util-crypto": "^12.6.2",
"@polkadot/types": "^12.0.2",
"@subwallet/chain-list": "0.2.88-beta.6",
"@subwallet/chain-list": "0.2.97",
"@subwallet/extension-base": "1.3.2-0",
"react-native-svg": "^13.6.0",
"sails-js": "0.1.6",
Expand Down
5 changes: 2 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { Warning } from 'phosphor-react-native';
import { Images } from 'assets/index';
import Text from 'components/Text';
import i18n from 'utils/i18n/i18n';
import { useGetEarningPoolData } from 'hooks/static-content/useGetEarningPoolData';
import { AppOnlineContentContextProvider } from 'providers/AppOnlineContentProvider';
import { GlobalModalContextProvider } from 'providers/GlobalModalContext';
import { useGetAppInstructionData } from 'hooks/static-content/useGetAppInstructionData';
Expand Down Expand Up @@ -172,7 +171,6 @@ export const App = () => {
const isI18nReady = useSetupI18n().isI18nReady;
const { checkIsShowBuyToken } = useShowBuyToken();
const { getDAppsData } = useGetDAppList();
const { getPoolInfoMap } = useGetEarningPoolData();
const { getConfig } = useGetConfig();
const { getBrowserConfig } = useGetBrowserConfig();
const { getAppInstructionData } = useGetAppInstructionData(language); // data for app instruction, will replace getEarningStaticData
Expand Down Expand Up @@ -214,7 +212,8 @@ export const App = () => {
SplashScreen.hide();
}, 100);
checkIsShowBuyToken();
getPoolInfoMap();
// getPoolInfoMap();
mmkvStore.delete('poolInfoMap'); // remove unused mmkvStore
getDAppsData();
getConfig();
getBrowserConfig();
Expand Down
11 changes: 11 additions & 0 deletions src/components/Modal/common/AccountSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ export const AccountSelector = ({
return { groupBy, sortSection: undefined, renderSectionHeader };
}, [groupBy, renderSectionHeader]);

const searchFunc = useCallback((_items: AccountAddressItemExtraType[], searchString: string) => {
const lowerCaseSearchString = searchString.toLowerCase();

return _items.filter(
acc =>
(acc.accountName && acc.accountName.toLowerCase().includes(lowerCaseSearchString)) ||
acc.address.toLowerCase().includes(lowerCaseSearchString),
);
}, []);

return (
<FullSizeSelectModal
items={listItems}
Expand All @@ -153,6 +163,7 @@ export const AccountSelector = ({
selectModalType={'single'}
selectModalItemType={'account'}
disabled={disabled}
searchFunc={searchFunc}
renderSelected={renderSelected}
placeholder={i18n.placeholder.accountName}
title={i18n.header.selectAccount}
Expand Down
13 changes: 13 additions & 0 deletions src/components/Modal/common/AccountSelectorNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,26 @@ export const AccountProxySelector = ({
onSelectItem && onSelectItem(item);
};

const searchFunc = useCallback((_items: AccountProxyItem[], searchString: string) => {
const lowerCaseSearchString = searchString.toLowerCase();

return _items.filter(acc => {
const isValidSearchByAddress = acc.accounts.some(ac => {
return ac.address.toLowerCase().includes(searchString.toLowerCase());
});

return (acc.name && acc.name.toLowerCase().includes(lowerCaseSearchString)) || isValidSearchByAddress;
});
}, []);

return (
<FullSizeSelectModal
items={listItems}
selectedValueMap={selectedValueMap}
onSelectItem={_onSelectItem}
selectModalType={'single'}
selectModalItemType={'account-proxy'}
searchFunc={searchFunc}
disabled={disabled}
renderSelected={renderSelected}
placeholder={i18n.placeholder.accountName}
Expand Down
9 changes: 8 additions & 1 deletion src/components/Modal/common/ChainSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';
import i18n from 'utils/i18n/i18n';
import { ChainInfo } from 'types/index';
import { FullSizeSelectModal } from 'components/common/SelectModal';
Expand All @@ -23,12 +23,19 @@ export const ChainSelector = ({
acceptDefaultValue,
chainSelectorRef,
}: Props) => {
const searchFunc = useCallback((_items: ChainInfo[], searchString: string) => {
const lowerCaseSearchString = searchString.toLowerCase();

return _items.filter(({ name }) => name.toLowerCase().includes(lowerCaseSearchString));
}, []);

return (
<FullSizeSelectModal
items={items}
selectedValueMap={selectedValueMap}
selectModalType={'single'}
selectModalItemType={'chain'}
searchFunc={searchFunc}
onSelectItem={onSelectItem}
renderSelected={renderSelected}
disabled={disabled}
Expand Down
17 changes: 17 additions & 0 deletions src/components/Modal/common/TokenSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { MagnifyingGlass } from 'phosphor-react-native';
import { useNavigation } from '@react-navigation/native';
import { RootNavigationProps } from 'routes/index';
import { ListRenderItemInfo } from '@shopify/flash-list';
import { useSelector } from 'react-redux';
import { RootState } from 'stores/index';

export type TokenItemType = {
name: string;
Expand Down Expand Up @@ -58,6 +60,7 @@ export const TokenSelector = ({
onCloseAccountSelector,
showAddBtn = true,
}: Props) => {
const chainInfoMap = useSelector((root: RootState) => root.chainStore.chainInfoMap);
const navigation = useNavigation<RootNavigationProps>();
useEffect(() => {
setAdjustPan();
Expand Down Expand Up @@ -87,12 +90,26 @@ export const TokenSelector = ({
);
}, [navigation, onCloseAccountSelector, showAddBtn, tokenSelectorRef]);

const searchFunc = useCallback(
(_items: TokenItemType[], searchString: string) => {
const lowerCaseSearchString = searchString.toLowerCase();

return (_items as TokenItemType[]).filter(
({ symbol, originChain }) =>
symbol.toLowerCase().includes(lowerCaseSearchString) ||
chainInfoMap[originChain]?.name?.toLowerCase().includes(lowerCaseSearchString),
);
},
[chainInfoMap],
);

return (
<FullSizeSelectModal
items={items}
selectedValueMap={selectedValueMap}
selectModalType={'single'}
selectModalItemType={'token'}
searchFunc={searchFunc}
title={i18n.header.selectToken}
onSelectItem={_onSelectItem}
ref={tokenSelectorRef}
Expand Down
20 changes: 19 additions & 1 deletion src/components/Modal/common/TokenSelectorNew.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import React, { useCallback } from 'react';
import { ListRenderItemInfo } from 'react-native';
import i18n from 'utils/i18n/i18n';
import { FullSizeSelectModal } from 'components/common/SelectModal';
import { useSelector } from 'react-redux';
import { RootState } from 'stores/index';

export type TokenItemType = {
name: string;
Expand Down Expand Up @@ -41,12 +43,28 @@ export const TokenSelector = ({
defaultValue,
acceptDefaultValue,
}: Props) => {
const chainInfoMap = useSelector((root: RootState) => root.chainStore.chainInfoMap);

const searchFunc = useCallback(
(_items: TokenItemType[], searchString: string) => {
const lowerCaseSearchString = searchString.toLowerCase();

return (_items as TokenItemType[]).filter(
({ symbol, originChain }) =>
symbol.toLowerCase().includes(lowerCaseSearchString) ||
chainInfoMap[originChain]?.name?.toLowerCase().includes(lowerCaseSearchString),
);
},
[chainInfoMap],
);

return (
<FullSizeSelectModal
items={items}
selectedValueMap={selectedValueMap}
selectModalType={'single'}
selectModalItemType={'token'}
searchFunc={searchFunc}
title={i18n.header.selectToken}
onSelectItem={onSelectItem}
ref={tokenSelectorRef}
Expand Down
4 changes: 4 additions & 0 deletions src/components/SeedPhraseArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ interface SeedPhraseAreaProps extends ViewProps {
currentWords: SelectedWordType[];
}

export function getWordKey(word: string, index: number, rowIndex: number) {
return `${index}-${word}-${rowIndex}`;
}

function getWrapperStyle(style: StyleProp<any> = {}): StyleProp<any> {
return {
borderRadius: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const AccountCreationArea = ({ createAccountRef, importAccountRef, attach
key: 'privateKey',
backgroundColor: '#4D4D4D',
icon: Wallet,
label: i18n.importAccount.importByMetaMaskPrivateKey,
label: i18n.importAccount.importFromPrivateKey,
},
{
key: 'qrCode',
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Modal/ConfirmModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ConfirmModal: React.FC<Props> = ({
{cancelBtnTitle || i18n.common.cancel}
</Button>
<Button
externalTextStyle={{ flex: 1, textAlign: 'center' }}
externalTextStyle={{ flexShrink: 1 }}
style={{ flex: 1 }}
icon={<Icon phosphorIcon={CheckCircle} size={'lg'} weight={'fill'} />}
type="primary"
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/SelectAccountAllItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const SelectAccountAllItem = ({ isSelected, accountProxies, showUnSelecte
<View style={styles.checkedIconWrapper}>
<Icon
phosphorIcon={CheckCircle}
iconColor={isSelected ? theme.colorSuccess : theme.colorTextLight4}
iconColor={isSelected ? theme.colorSuccess : theme['gray-5']}
size={'sm'}
weight={'fill'}
/>
Expand Down
95 changes: 31 additions & 64 deletions src/components/common/SelectModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { SelectModalField } from 'components/common/SelectModal/parts/SelectModa
import { EmptyList } from 'components/EmptyList';
import i18n from 'utils/i18n/i18n';
import { TokenItemType } from 'components/Modal/common/TokenSelector';
import { useSelector } from 'react-redux';
import { RootState } from 'stores/index';
import { ChainInfo } from 'types/index';
import { useSubWalletTheme } from 'hooks/useSubWalletTheme';
import { SWModalRefProps } from 'components/design-system-ui/modal/ModalBaseV2';
Expand Down Expand Up @@ -123,7 +121,6 @@ function _SelectModal<T>(selectModalProps: Props<T>, ref: ForwardedRef<any>) {
keyExtractor,
flatListStyle,
} = selectModalProps;
const chainInfoMap = useSelector((root: RootState) => root.chainStore.chainInfoMap);
const [isOpen, setOpen] = useState<boolean>(false);
const [isLoadingData, setLoadingData] = useState<boolean>(true);
const modalBaseV2Ref = useRef<SWModalRefProps>(null);
Expand Down Expand Up @@ -199,38 +196,6 @@ function _SelectModal<T>(selectModalProps: Props<T>, ref: ForwardedRef<any>) {
[isOpen, onCloseModal, onModalOpened],
);

const _searchFunction = useCallback(
(_items: T[], searchString: string): T[] => {
const lowerCaseSearchString = searchString.toLowerCase();

if (selectModalItemType === 'account') {
return (_items as AccountAddressItemExtraType[]).filter(
acc =>
(acc.accountName && acc.accountName.toLowerCase().includes(lowerCaseSearchString)) ||
acc.address.toLowerCase().includes(lowerCaseSearchString),
) as T[];
} else if (selectModalItemType === 'account-proxy') {
return (_items as AccountProxyItem[]).filter(acc => {
const isValidSearchByAddress = acc.accounts.some(ac => {
return ac.address.toLowerCase().includes(searchString.toLowerCase());
});
return (acc.name && acc.name.toLowerCase().includes(lowerCaseSearchString)) || isValidSearchByAddress;
}) as T[];
} else if (selectModalItemType === 'token') {
return (_items as TokenItemType[]).filter(
({ symbol, originChain }) =>
symbol.toLowerCase().includes(lowerCaseSearchString) ||
chainInfoMap[originChain]?.name?.toLowerCase().includes(lowerCaseSearchString),
) as T[];
} else if (selectModalItemType === 'chain') {
return (items as ChainInfo[]).filter(({ name }) => name.toLowerCase().includes(lowerCaseSearchString)) as T[];
} else {
return items;
}
},
[chainInfoMap, items, selectModalItemType],
);

const renderItem = ({ item }: ListRenderItemInfo<T>) => {
if (selectModalItemType === 'account') {
return (
Expand Down Expand Up @@ -353,35 +318,37 @@ function _SelectModal<T>(selectModalProps: Props<T>, ref: ForwardedRef<any>) {
setVisible={setOpen}
onBackButtonPress={onBackButtonPress}>
<>
<FlatListScreen
autoFocus={true}
items={items}
style={{ flex: 1 }}
flatListStyle={flatListStyle}
renderItem={renderCustomItem || renderItem}
searchFunction={searchFunc || _searchFunction}
renderListEmptyComponent={renderListEmptyComponent || _renderListEmptyComponent}
title={title}
onPressBack={onCloseModal}
isLoadingData={isLoadingData}
isShowFilterBtn={isShowFilterBtn}
filterFunction={filterFunction}
filterOptions={filterOptions}
placeholder={placeholder}
loading={loading}
withSearchInput={withSearchInput}
isShowListWrapper={isShowListWrapper}
rightIconOption={rightIconOption}
grouping={grouping}
removeClippedSubviews={true}
afterListItem={
selectModalType === 'multi' ? renderFooter() : renderAfterListItem ? renderAfterListItem() : undefined
}
estimatedItemSize={estimatedItemSize || 80}
searchMarginBottom={grouping ? theme.sizeXS : undefined}
extraData={extraData}
keyExtractor={keyExtractor}
/>
{isOpen && (
<FlatListScreen
autoFocus={true}
items={items}
style={{ flex: 1 }}
flatListStyle={flatListStyle}
renderItem={renderCustomItem || renderItem}
searchFunction={searchFunc}
renderListEmptyComponent={renderListEmptyComponent || _renderListEmptyComponent}
title={title}
onPressBack={onCloseModal}
isLoadingData={isLoadingData}
isShowFilterBtn={isShowFilterBtn}
filterFunction={filterFunction}
filterOptions={filterOptions}
placeholder={placeholder}
loading={loading}
withSearchInput={withSearchInput}
isShowListWrapper={isShowListWrapper}
rightIconOption={rightIconOption}
grouping={grouping}
removeClippedSubviews={true}
afterListItem={
selectModalType === 'multi' ? renderFooter() : renderAfterListItem ? renderAfterListItem() : undefined
}
estimatedItemSize={estimatedItemSize || 80}
searchMarginBottom={grouping ? theme.sizeXS : undefined}
extraData={extraData}
keyExtractor={keyExtractor}
/>
)}
</>

{children}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/earning/useYieldPoolInfoByGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

import { YieldPoolInfo } from '@subwallet/extension-base/types';
import { useGetChainSlugs } from 'hooks/screen/Home/useGetChainSlugs';
import { useMemo } from 'react';
import { useSelector } from 'react-redux';
import { RootState } from 'stores/index';
import { useGetChainSlugsByAccount } from 'hooks/useGetChainSlugsByAccount';

const useYieldPoolInfoByGroup = (group: string): YieldPoolInfo[] => {
const { poolInfoMap } = useSelector((state: RootState) => state.earning);
const chainsByAccountType = useGetChainSlugs();
const chainsByAccountType = useGetChainSlugsByAccount();

return useMemo(() => {
const result: YieldPoolInfo[] = [];
Expand Down
Loading
Loading