f015229acf
* Rip out virtualization on the web
* Screw around with layout
* onEndReached
* scrollToOffset
* Fix background
* onScroll
* Shell bars
* More scroll
* Fixes
* position: sticky
* Clean up 1
* Clean up 2
* Undo PagerWithHeader changes and fork it
* Trim down both versions
* Cleanup 3
* Memoize, lint
* Don't scroll away modal or lightbox
* Add content-visibility for rows
* Fix composer
* Fix types
* Fix borked scroll animation
* Fixes to layout
* More FlatList parity
* Layout fixes
* Fix more layout
* More layout
* More layouts
* Fix profile layout
* Remove onScroll
* Display: none inactive pages
* Add an intermediate List component
* Fix type
* Add onScrolledDownChange
* Port pager to use onScrolledDownChange
* Fix on mobile
* Don't pass down onScroll (replacement TBD)
* Remove resetMainScroll
* Replace onMainScroll with MainScrollProvider
* Hook ScrollProvider to pager
* Fix the remaining special case
* Optimize a bit
* Enforce that onScroll cannot be passed
* Keep value updated even if no handler
* Also memo it
* Move the fork to List.web
* Add scroll handler
* Consolidate List props a bit
* More stuff
* Rm unused
* Simplify
* Make isScrolledDown work
* Oops
* Fixes
* Hook up context scroll handlers
* Scroll restore for tabs
* Route scroll restoration POC
* Fix some issues with restoration
* Remove bad idea
* Fix pager scroll restoration
* Undo accidental locale changes
* onContentSizeChange
* Scroll to post
* Better positioning
* Layout fixes
* Factor out navigation stuff
* Cleanup
* Oops
* Cleanup
* Fixes and types
* Naming etc
* Fix crash
* Match FL semantics
* Snap the header scroll on the web
* Add body scroll lock
* Scroll to top on search
* Fix types
* Typos
* Fix Safari overflow
* Fix search positioning
* Add border
* Patch react navigation
* Revert "Patch react navigation"
This reverts commit 62516ed9c2.
* fixes
* scroll
* scrollbar
* cleanup unrelated
* undo unrel
* flatter
* Fix css
* twk
150 lines
4.3 KiB
TypeScript
150 lines
4.3 KiB
TypeScript
import React from 'react'
|
|
import {View, StyleSheet} from 'react-native'
|
|
import Animated from 'react-native-reanimated'
|
|
import {TabBar} from 'view/com/pager/TabBar'
|
|
import {RenderTabBarFnProps} from 'view/com/pager/Pager'
|
|
import {usePalette} from 'lib/hooks/usePalette'
|
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
|
import {FeedsTabBar as FeedsTabBarMobile} from './FeedsTabBarMobile'
|
|
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
|
|
import {useShellLayout} from '#/state/shell/shell-layout'
|
|
import {usePinnedFeedsInfos} from '#/state/queries/feed'
|
|
import {useSession} from '#/state/session'
|
|
import {TextLink} from '#/view/com/util/Link'
|
|
import {CenteredView} from '../util/Views'
|
|
import {isWeb} from 'platform/detection'
|
|
import {useNavigation} from '@react-navigation/native'
|
|
import {NavigationProp} from 'lib/routes/types'
|
|
|
|
export function FeedsTabBar(
|
|
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
|
) {
|
|
const {isMobile, isTablet} = useWebMediaQueries()
|
|
const {hasSession} = useSession()
|
|
|
|
if (isMobile) {
|
|
return <FeedsTabBarMobile {...props} />
|
|
} else if (isTablet) {
|
|
if (hasSession) {
|
|
return <FeedsTabBarTablet {...props} />
|
|
} else {
|
|
return <FeedsTabBarPublic />
|
|
}
|
|
} else {
|
|
return null
|
|
}
|
|
}
|
|
|
|
function FeedsTabBarPublic() {
|
|
const pal = usePalette('default')
|
|
const {isSandbox} = useSession()
|
|
|
|
return (
|
|
<CenteredView sideBorders>
|
|
<View
|
|
style={[
|
|
pal.view,
|
|
{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'space-between',
|
|
paddingHorizontal: 18,
|
|
paddingVertical: 12,
|
|
},
|
|
]}>
|
|
<TextLink
|
|
type="title-lg"
|
|
href="/"
|
|
style={[pal.text, {fontWeight: 'bold'}]}
|
|
text={
|
|
<>
|
|
{isSandbox ? 'SANDBOX' : 'Bluesky'}{' '}
|
|
{/*hasNew && (
|
|
<View
|
|
style={{
|
|
top: -8,
|
|
backgroundColor: colors.blue3,
|
|
width: 8,
|
|
height: 8,
|
|
borderRadius: 4,
|
|
}}
|
|
/>
|
|
)*/}
|
|
</>
|
|
}
|
|
// onPress={emitSoftReset}
|
|
/>
|
|
</View>
|
|
</CenteredView>
|
|
)
|
|
}
|
|
|
|
function FeedsTabBarTablet(
|
|
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
|
) {
|
|
const {feeds, hasPinnedCustom} = usePinnedFeedsInfos()
|
|
const pal = usePalette('default')
|
|
const {hasSession} = useSession()
|
|
const navigation = useNavigation<NavigationProp>()
|
|
const {headerMinimalShellTransform} = useMinimalShellMode()
|
|
const {headerHeight} = useShellLayout()
|
|
const pinnedDisplayNames = hasSession ? feeds.map(f => f.displayName) : []
|
|
const showFeedsLinkInTabBar = hasSession && !hasPinnedCustom
|
|
const items = showFeedsLinkInTabBar
|
|
? pinnedDisplayNames.concat('Feeds ✨')
|
|
: pinnedDisplayNames
|
|
|
|
const onPressDiscoverFeeds = React.useCallback(() => {
|
|
if (isWeb) {
|
|
navigation.navigate('Feeds')
|
|
} else {
|
|
navigation.navigate('FeedsTab')
|
|
navigation.popToTop()
|
|
}
|
|
}, [navigation])
|
|
|
|
const onSelect = React.useCallback(
|
|
(index: number) => {
|
|
if (showFeedsLinkInTabBar && index === items.length - 1) {
|
|
onPressDiscoverFeeds()
|
|
} else if (props.onSelect) {
|
|
props.onSelect(index)
|
|
}
|
|
},
|
|
[items.length, onPressDiscoverFeeds, props, showFeedsLinkInTabBar],
|
|
)
|
|
|
|
return (
|
|
// @ts-ignore the type signature for transform wrong here, translateX and translateY need to be in separate objects -prf
|
|
<Animated.View
|
|
style={[pal.view, pal.border, styles.tabBar, headerMinimalShellTransform]}
|
|
onLayout={e => {
|
|
headerHeight.value = e.nativeEvent.layout.height
|
|
}}>
|
|
<TabBar
|
|
key={items.join(',')}
|
|
{...props}
|
|
onSelect={onSelect}
|
|
items={items}
|
|
indicatorColor={pal.colors.link}
|
|
/>
|
|
</Animated.View>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
tabBar: {
|
|
// @ts-ignore Web only
|
|
position: 'sticky',
|
|
zIndex: 1,
|
|
// @ts-ignore Web only -prf
|
|
left: 'calc(50% - 300px)',
|
|
width: 600,
|
|
top: 0,
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
borderLeftWidth: 1,
|
|
borderRightWidth: 1,
|
|
},
|
|
})
|