diff options
Diffstat (limited to 'src/view/screens')
-rw-r--r-- | src/view/screens/Home.tsx | 21 | ||||
-rw-r--r-- | src/view/screens/home/FeedsTabBar.tsx | 72 | ||||
-rw-r--r-- | src/view/screens/home/FeedsTabBar.web.tsx | 22 |
3 files changed, 8 insertions, 107 deletions
diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 4950bc0fd..505f9e723 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {FlatList, View, useWindowDimensions} from 'react-native' +import {FlatList, View} from 'react-native' import {useFocusEffect, useIsFocused} from '@react-navigation/native' import {observer} from 'mobx-react-lite' import useAppState from 'react-native-appstate-hook' @@ -9,17 +9,16 @@ import {withAuthRequired} from 'view/com/auth/withAuthRequired' import {Feed} from '../com/posts/Feed' import {FollowingEmptyState} from 'view/com/posts/FollowingEmptyState' import {LoadLatestBtn} from '../com/util/LoadLatestBtn' -import {FeedsTabBar} from './home/FeedsTabBar' -import {Pager, RenderTabBarFnProps} from 'view/com/util/pager/Pager' +import {FeedsTabBar} from '../com/pager/FeedsTabBar' +import {Pager, RenderTabBarFnProps} from 'view/com/pager/Pager' import {FAB} from '../com/util/FAB' import {useStores} from 'state/index' import {s} from 'lib/styles' import {useOnMainScroll} from 'lib/hooks/useOnMainScroll' import {useAnalytics} from 'lib/analytics' import {ComposeIcon2} from 'lib/icons' -import {isDesktopWeb} from 'platform/detection' -const TAB_BAR_HEIGHT = 82 +const HEADER_OFFSET = 40 type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'> export const HomeScreen = withAuthRequired((_opts: Props) => { @@ -69,7 +68,7 @@ export const HomeScreen = withAuthRequired((_opts: Props) => { <Pager onPageSelected={onPageSelected} renderTabBar={renderTabBar} - tabBarPosition={isDesktopWeb ? 'top' : 'bottom'} + tabBarPosition="top" initialPage={initialPage}> <FeedPage key="1" @@ -100,11 +99,6 @@ const FeedPage = observer( onForeground: () => doPoll(true), }) const isScreenFocused = useIsFocused() - const winDim = useWindowDimensions() - const containerStyle = React.useMemo( - () => ({height: winDim.height - (isDesktopWeb ? 0 : TAB_BAR_HEIGHT)}), - [winDim], - ) const doPoll = React.useCallback( (knownActive = false) => { @@ -125,7 +119,7 @@ const FeedPage = observer( ) const scrollToTop = React.useCallback(() => { - scrollElRef.current?.scrollToOffset({offset: 0}) + scrollElRef.current?.scrollToOffset({offset: -HEADER_OFFSET}) }, [scrollElRef]) const onSoftReset = React.useCallback(() => { @@ -169,7 +163,7 @@ const FeedPage = observer( }, [feed, scrollToTop]) return ( - <View style={containerStyle}> + <View style={s.h100pct}> <Feed testID="homeFeed" key="default" @@ -180,6 +174,7 @@ const FeedPage = observer( onPressTryAgain={onPressTryAgain} onScroll={onMainScroll} renderEmptyState={renderEmptyState} + headerOffset={HEADER_OFFSET} /> {feed.hasNewLatest && !feed.isRefreshing && ( <LoadLatestBtn onPress={onPressLoadLatest} /> diff --git a/src/view/screens/home/FeedsTabBar.tsx b/src/view/screens/home/FeedsTabBar.tsx deleted file mode 100644 index d34034103..000000000 --- a/src/view/screens/home/FeedsTabBar.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import React from 'react' -import {Animated, StyleSheet} from 'react-native' -import {observer} from 'mobx-react-lite' -import {TabBar} from 'view/com/util/TabBar' -import {RenderTabBarFnProps} from 'view/com/util/pager/Pager' -import {useStores} from 'state/index' -import {usePalette} from 'lib/hooks/usePalette' -import {useSafeAreaInsets} from 'react-native-safe-area-context' -import {useAnimatedValue} from 'lib/hooks/useAnimatedValue' -import {clamp} from 'lodash' - -const BOTTOM_BAR_HEIGHT = 48 - -export const FeedsTabBar = observer( - (props: RenderTabBarFnProps & {onPressSelected: () => void}) => { - const store = useStores() - const safeAreaInsets = useSafeAreaInsets() - const pal = usePalette('default') - const interp = useAnimatedValue(0) - - const pad = React.useMemo( - () => ({ - paddingBottom: clamp(safeAreaInsets.bottom, 15, 20), - }), - [safeAreaInsets], - ) - - React.useEffect(() => { - Animated.timing(interp, { - toValue: store.shell.minimalShellMode ? 0 : 1, - duration: 100, - useNativeDriver: true, - isInteraction: false, - }).start() - }, [interp, store.shell.minimalShellMode]) - const transform = { - transform: [ - {translateY: Animated.multiply(interp, -1 * BOTTOM_BAR_HEIGHT)}, - ], - } - - return ( - <Animated.View - style={[pal.view, pal.border, styles.tabBar, pad, transform]}> - <TabBar - {...props} - items={['Following', "What's hot"]} - indicatorPosition="top" - indicatorColor={pal.colors.link} - /> - </Animated.View> - ) - }, -) - -const styles = StyleSheet.create({ - tabBar: { - position: 'absolute', - left: 0, - right: 0, - bottom: 0, - flexDirection: 'row', - alignItems: 'center', - paddingHorizontal: 10, - borderTopWidth: 1, - paddingTop: 0, - paddingBottom: 30, - }, - tabBarAvi: { - marginRight: 4, - }, -}) diff --git a/src/view/screens/home/FeedsTabBar.web.tsx b/src/view/screens/home/FeedsTabBar.web.tsx deleted file mode 100644 index 59ea42988..000000000 --- a/src/view/screens/home/FeedsTabBar.web.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react' -import {observer} from 'mobx-react-lite' -import {TabBar} from 'view/com/util/TabBar' -import {CenteredView} from 'view/com/util/Views' -import {RenderTabBarFnProps} from 'view/com/util/pager/Pager' -import {usePalette} from 'lib/hooks/usePalette' - -export const FeedsTabBar = observer( - (props: RenderTabBarFnProps & {onPressSelected: () => void}) => { - const pal = usePalette('default') - return ( - <CenteredView> - <TabBar - {...props} - items={['Following', "What's hot"]} - indicatorPosition="bottom" - indicatorColor={pal.colors.link} - /> - </CenteredView> - ) - }, -) |