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

Improve list performance (Round 3) #1778

Merged
merged 12 commits into from
Sep 12, 2024
7 changes: 7 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ PODS:
- React-Core
- SDWebImage (~> 5.11.1)
- SDWebImageWebPCoder (~> 0.8.4)
- RNFlashList (1.7.1):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- RNFS (2.20.0):
- React-Core
- RNGestureHandler (2.15.0):
Expand Down Expand Up @@ -636,6 +639,7 @@ DEPENDENCIES:
- "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
- RNFastImage (from `../node_modules/react-native-fast-image`)
- "RNFlashList (from `../node_modules/@shopify/flash-list`)"
- RNFS (from `../node_modules/react-native-fs`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNInAppBrowser (from `../node_modules/react-native-inappbrowser-reborn`)
Expand Down Expand Up @@ -800,6 +804,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-device-info"
RNFastImage:
:path: "../node_modules/react-native-fast-image"
RNFlashList:
:path: "../node_modules/@shopify/flash-list"
RNFS:
:path: "../node_modules/react-native-fs"
RNGestureHandler:
Expand Down Expand Up @@ -901,6 +907,7 @@ SPEC CHECKSUMS:
RNCMaskedView: 949696f25ec596bfc697fc88e6f95cf0c79669b6
RNDeviceInfo: db5c64a060e66e5db3102d041ebe3ef307a85120
RNFastImage: 5c9c9fed9c076e521b3f509fe79e790418a544e8
RNFlashList: fadf593d8e195ce2fe261980ac59e9f49808b68c
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
RNGestureHandler: 7909c50383a18f0cb10ce1db7262b9a6da504c03
RNInAppBrowser: e36d6935517101ccba0e875bac8ad7b0cb655364
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@react-navigation/native": "^6.1.2",
"@react-navigation/native-stack": "^6.9.8",
"@reduxjs/toolkit": "^1.9.2",
"@shopify/flash-list": "^1.7.1",
"@subwallet/extension-chains": "1.2.28-0",
"@subwallet/extension-dapp": "1.2.28-0",
"@subwallet/extension-inject": "1.2.28-0",
Expand Down
2 changes: 0 additions & 2 deletions src/AppNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ import { EarningPreview } from 'screens/EarningPreview';
import { EarningPreviewPools } from 'screens/EarningPreview/EarningPreviewPools';
import { ExportAllAccount } from 'screens/Account/ExportAllAccount';
import { CrowdloansScreen } from 'screens/Home/Crowdloans';
import { MissionPoolSearchByTabView } from 'screens/Home/Browser/MissionPool/MissionPoolSearchByTabView';

interface Props {
isAppReady: boolean;
Expand Down Expand Up @@ -634,7 +633,6 @@ const AppNavigator = ({ isAppReady }: Props) => {
<Stack.Screen name="BrowserSearch" component={BrowserSearch} />
<Stack.Screen name="BrowserTabsManager" component={BrowserTabsManager} />
<Stack.Screen name="BrowserListByTabview" component={BrowserListByTabview} />
<Stack.Screen name="MissionPoolSearchByTabView" component={MissionPoolSearchByTabView} />
<Stack.Screen name="AccountsScreen" component={AccountsScreen} />
<Stack.Screen name="Drawer" component={DrawerScreen} options={{ gestureEnabled: false }} />
<Stack.Screen name="EarningPreview" component={EarningPreview} options={{ gestureEnabled: false }} />
Expand Down
3 changes: 1 addition & 2 deletions src/components/Browser/styles/BrowserItem.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ThemeTypes } from 'styles/themes';
import { StyleSheet } from 'react-native';
import { FontSemiBold } from 'styles/sharedStyles';
import { browserListItemHeight } from 'constants/itemHeight';

export default (theme: ThemeTypes) => {
return StyleSheet.create({
container: { flexDirection: 'row', alignItems: 'center', height: browserListItemHeight },
container: { flexDirection: 'row', alignItems: 'center' },

contentWrapper: { flexDirection: 'row', flex: 1, overflow: 'hidden' },

Expand Down
28 changes: 17 additions & 11 deletions src/components/FlatListScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { IconProps } from 'phosphor-react-native';
import { Keyboard, ListRenderItemInfo, RefreshControlProps, StyleProp, TextInput, View, ViewStyle } from 'react-native';
import { Keyboard, RefreshControlProps, StyleProp, TextInput, View, ViewStyle } from 'react-native';
import { ContainerWithSubHeader } from 'components/ContainerWithSubHeader';
import { Search } from 'components/Search';
import { SortFunctionInterface } from 'types/ui-types';
Expand All @@ -10,8 +10,8 @@ import { LazyFlatList } from 'components/LazyFlatList';
import { NoInternetScreen } from 'components/NoInternetScreen';
import FilterModal, { OptionType } from 'components/common/FilterModal';
import { useFilterModal } from 'hooks/useFilterModal';
import { SectionListData } from 'react-native/Libraries/Lists/SectionList';
import { LazySectionList, SectionItem } from 'components/LazySectionList';
import { ContentStyle, ListRenderItemInfo } from '@shopify/flash-list';

export interface RightIconOpt {
icon?: (iconProps: IconProps) => JSX.Element;
Expand Down Expand Up @@ -42,7 +42,7 @@ interface Props<T> {
placeholder?: string;
numberColumns?: number;
loading?: boolean;
flatListStyle?: StyleProp<ViewStyle>;
flatListStyle?: ContentStyle;
leftButtonDisabled?: boolean;
headerContent?: () => JSX.Element;
refreshControl?: React.ReactElement<RefreshControlProps, string | React.JSXElementConstructor<any>>;
Expand All @@ -52,7 +52,7 @@ interface Props<T> {
filterOptions?: OptionType[];
isShowListWrapper?: boolean;
grouping?: {
renderSectionHeader: (info: { section: SectionListData<T> }) => React.ReactElement | null;
renderSectionHeader: (item: string, itemLength?: number) => React.ReactElement | null;
groupBy: (item: T) => string;
sortSection?: SortFunctionInterface<SectionItem<T>>;
};
Expand All @@ -61,10 +61,10 @@ interface Props<T> {
defaultSelectionMap?: Record<string, boolean>;
androidKeyboardVerticalOffset?: number;
titleTextAlign?: 'left' | 'center';
getItemLayout?: (
data: readonly T[] | SectionListData<T, SectionListData<T>>[] | null | undefined,
index: number,
) => { length: number; offset: number; index: number };
estimatedItemSize?: number;
extraData?: any;
keyExtractor?: (item: T, index: number) => string;
removeClippedSubviews?: boolean;
}

export function FlatListScreen<T>({
Expand Down Expand Up @@ -103,7 +103,10 @@ export function FlatListScreen<T>({
defaultSelectionMap,
androidKeyboardVerticalOffset,
titleTextAlign,
getItemLayout,
estimatedItemSize,
extraData,
keyExtractor,
removeClippedSubviews,
}: Props<T>) {
const [searchString, setSearchString] = useState<string>(defaultSearchString || '');
const searchRef = useRef<TextInput>(null);
Expand Down Expand Up @@ -159,7 +162,7 @@ export function FlatListScreen<T>({
loading={loading}
groupBy={grouping.groupBy}
renderSectionHeader={grouping.renderSectionHeader}
getItemLayout={getItemLayout}
estimatedItemSize={estimatedItemSize}
/>
) : (
<LazyFlatList
Expand All @@ -176,7 +179,10 @@ export function FlatListScreen<T>({
loading={loading}
numberColumns={numberColumns}
isShowListWrapper={isShowListWrapper}
getItemLayout={getItemLayout}
estimatedItemSize={estimatedItemSize}
extraData={extraData}
keyExtractor={keyExtractor}
removeClippedSubviews={removeClippedSubviews}
/>
))
) : (
Expand Down
228 changes: 0 additions & 228 deletions src/components/Input/InputBalance.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Item/Earning/EarningGroupItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function createStyleSheet(theme: ThemeTypes) {
backgroundColor: theme.colorBgSecondary,
borderRadius: theme.borderRadiusLG,
alignItems: 'center',
marginBottom: theme.marginXS,
},
containerRow: {
flexDirection: 'row',
Expand Down
Loading
Loading