Skip to content

Commit

Permalink
fix: Android tabs issue on v5.2.1 (#5910)
Browse files Browse the repository at this point in the history
* fix: some tab issues on android (#5888)

* fix: the tab issues on android (#5895)

---------

Co-authored-by: hublot <hublot@aliyun.com>
  • Loading branch information
originalix and hellohublot authored Sep 24, 2024
1 parent 818d6f8 commit c8c85c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const TabComponent = (
tabContentContainerStyle,
style,
onRefresh: onRefreshCallBack,
initialHeaderHeight = 250,
initialHeaderHeight = 0,
}: ITabProps,
// fix missing forwardRef warnings.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -172,9 +172,18 @@ export const TabComponent = (
);

const onIndexChange = useCallback(() => {}, []);
const onLayout = useCallback(({ nativeEvent }: LayoutChangeEvent) => {
setHeaderHeight(nativeEvent.layout.height);
}, []);
const onLayout = useCallback(
({ nativeEvent }: LayoutChangeEvent) => {
if (nativeEvent.layout.height === headerHeight) {
return;
}
if (platformEnv.isNativeAndroid && initialHeaderHeight > 0) {
return;
}
setHeaderHeight(nativeEvent.layout.height);
},
[headerHeight, initialHeaderHeight],
);
return (
// @ts-expect-error
<NestedTabView
Expand Down
3 changes: 1 addition & 2 deletions packages/kit/src/components/TokenListView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ function TokenListView(props: IProps) {
if (
(isTokenSelector && tokenSelectorSearchTokenState.isSearching) ||
(!isTokenSelector && searchTokenState.isSearching) ||
(!tokenListState.initialized && tokenListState.isRefreshing) ||
(platformEnv.isNativeAndroid && isInRequest)
(!tokenListState.initialized && tokenListState.isRefreshing)
) {
return (
<NestedScrollView style={{ flex: 1 }}>
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/views/Home/pages/HomePageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export function HomePageView({
data={tabs}
ListHeaderComponent={<HomeHeaderContainer />}
initialScrollIndex={0}
initialHeaderHeight={220}
contentItemWidth={CONTENT_ITEM_WIDTH}
contentWidth={screenWidth}
showsVerticalScrollIndicator={false}
Expand Down
1 change: 0 additions & 1 deletion packages/kit/src/views/Market/MarketHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ function MarketHome() {
return (
<Tab
disableRefresh
initialHeaderHeight={0}
data={tabConfig}
onSelectedPageIndex={handleSelectedPageIndex}
/>
Expand Down

0 comments on commit c8c85c0

Please sign in to comment.