[PWI] Home (#2007)
* Fix up home page * Fix spacing * Remove unused default tab * Update logiczio/stable
parent
a741a201b9
commit
d4714baf13
|
@ -195,13 +195,30 @@ export function FeedPage({
|
||||||
function useHeaderOffset() {
|
function useHeaderOffset() {
|
||||||
const {isDesktop, isTablet} = useWebMediaQueries()
|
const {isDesktop, isTablet} = useWebMediaQueries()
|
||||||
const {fontScale} = useWindowDimensions()
|
const {fontScale} = useWindowDimensions()
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (isTablet) {
|
if (isTablet) {
|
||||||
return 50
|
if (hasSession) {
|
||||||
|
return 50
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSession) {
|
||||||
|
const navBarPad = 16
|
||||||
|
const navBarText = 21 * fontScale
|
||||||
|
const tabBarPad = 20 + 3 // nav bar padding + border
|
||||||
|
const tabBarText = 16 * fontScale
|
||||||
|
const magic = 7 * fontScale
|
||||||
|
return navBarPad + navBarText + tabBarPad + tabBarText + magic
|
||||||
|
} else {
|
||||||
|
const navBarPad = 16
|
||||||
|
const navBarText = 21 * fontScale
|
||||||
|
const magic = 4 * fontScale
|
||||||
|
return navBarPad + navBarText + magic
|
||||||
}
|
}
|
||||||
// default text takes 44px, plus 34px of pad
|
|
||||||
// scale the 44px by the font scale
|
|
||||||
return 34 + 44 * fontScale
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleSheet} from 'react-native'
|
import {View, StyleSheet} from 'react-native'
|
||||||
import Animated from 'react-native-reanimated'
|
import Animated from 'react-native-reanimated'
|
||||||
import {TabBar} from 'view/com/pager/TabBar'
|
import {TabBar} from 'view/com/pager/TabBar'
|
||||||
import {RenderTabBarFnProps} from 'view/com/pager/Pager'
|
import {RenderTabBarFnProps} from 'view/com/pager/Pager'
|
||||||
|
@ -9,20 +9,73 @@ import {FeedsTabBar as FeedsTabBarMobile} from './FeedsTabBarMobile'
|
||||||
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
|
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
|
||||||
import {useShellLayout} from '#/state/shell/shell-layout'
|
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||||
import {usePinnedFeedsInfos} from '#/state/queries/feed'
|
import {usePinnedFeedsInfos} from '#/state/queries/feed'
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
|
import {TextLink} from '#/view/com/util/Link'
|
||||||
|
import {CenteredView} from '../util/Views'
|
||||||
|
|
||||||
export function FeedsTabBar(
|
export function FeedsTabBar(
|
||||||
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
||||||
) {
|
) {
|
||||||
const {isMobile, isTablet} = useWebMediaQueries()
|
const {isMobile, isTablet} = useWebMediaQueries()
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
return <FeedsTabBarMobile {...props} />
|
return <FeedsTabBarMobile {...props} />
|
||||||
} else if (isTablet) {
|
} else if (isTablet) {
|
||||||
return <FeedsTabBarTablet {...props} />
|
if (hasSession) {
|
||||||
|
return <FeedsTabBarTablet {...props} />
|
||||||
|
} else {
|
||||||
|
return <FeedsTabBarPublic />
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null
|
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(
|
function FeedsTabBarTablet(
|
||||||
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export function FeedsTabBar(
|
||||||
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
|
||||||
) {
|
) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {isSandbox} = useSession()
|
const {isSandbox, hasSession} = useSession()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const setDrawerOpen = useSetDrawerOpen()
|
const setDrawerOpen = useSetDrawerOpen()
|
||||||
const feeds = usePinnedFeedsInfos()
|
const feeds = usePinnedFeedsInfos()
|
||||||
|
@ -61,30 +61,35 @@ export function FeedsTabBar(
|
||||||
<Text style={[brandBlue, s.bold, styles.title]}>
|
<Text style={[brandBlue, s.bold, styles.title]}>
|
||||||
{isSandbox ? 'SANDBOX' : 'Bluesky'}
|
{isSandbox ? 'SANDBOX' : 'Bluesky'}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={[pal.view]}>
|
<View style={[pal.view, {width: 18}]}>
|
||||||
<Link
|
{hasSession && (
|
||||||
testID="viewHeaderHomeFeedPrefsBtn"
|
<Link
|
||||||
href="/settings/home-feed"
|
testID="viewHeaderHomeFeedPrefsBtn"
|
||||||
hitSlop={HITSLOP_10}
|
href="/settings/home-feed"
|
||||||
accessibilityRole="button"
|
hitSlop={HITSLOP_10}
|
||||||
accessibilityLabel={_(msg`Home Feed Preferences`)}
|
accessibilityRole="button"
|
||||||
accessibilityHint="">
|
accessibilityLabel={_(msg`Home Feed Preferences`)}
|
||||||
<FontAwesomeIcon
|
accessibilityHint="">
|
||||||
icon="sliders"
|
<FontAwesomeIcon
|
||||||
style={pal.textLight as FontAwesomeIconStyle}
|
icon="sliders"
|
||||||
/>
|
style={pal.textLight as FontAwesomeIconStyle}
|
||||||
</Link>
|
/>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<TabBar
|
|
||||||
key={items.join(',')}
|
{items.length > 0 && (
|
||||||
onPressSelected={props.onPressSelected}
|
<TabBar
|
||||||
selectedPage={props.selectedPage}
|
key={items.join(',')}
|
||||||
onSelect={props.onSelect}
|
onPressSelected={props.onPressSelected}
|
||||||
testID={props.testID}
|
selectedPage={props.selectedPage}
|
||||||
items={items}
|
onSelect={props.onSelect}
|
||||||
indicatorColor={pal.colors.link}
|
testID={props.testID}
|
||||||
/>
|
items={items}
|
||||||
|
indicatorColor={pal.colors.link}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -104,8 +109,7 @@ const styles = StyleSheet.create({
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
paddingHorizontal: 18,
|
paddingHorizontal: 18,
|
||||||
paddingTop: 8,
|
paddingVertical: 8,
|
||||||
paddingBottom: 2,
|
|
||||||
width: '100%',
|
width: '100%',
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
|
|
|
@ -17,13 +17,8 @@ import {useSession} from '#/state/session'
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
||||||
export function HomeScreen(props: Props) {
|
export function HomeScreen(props: Props) {
|
||||||
const {hasSession} = useSession()
|
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
if (!hasSession) {
|
|
||||||
return <HomeScreenPublic />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preferences) {
|
if (preferences) {
|
||||||
return <HomeScreenReady {...props} preferences={preferences} />
|
return <HomeScreenReady {...props} preferences={preferences} />
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,35 +30,12 @@ export function HomeScreen(props: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function HomeScreenPublic() {
|
|
||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
|
||||||
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
|
|
||||||
|
|
||||||
const renderCustomFeedEmptyState = React.useCallback(() => {
|
|
||||||
return <CustomFeedEmptyState />
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useFocusEffect(
|
|
||||||
React.useCallback(() => {
|
|
||||||
setMinimalShellMode(false)
|
|
||||||
setDrawerSwipeDisabled(false)
|
|
||||||
}, [setDrawerSwipeDisabled, setMinimalShellMode]),
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FeedPage
|
|
||||||
isPageFocused
|
|
||||||
feed={`feedgen|at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot`}
|
|
||||||
renderEmptyState={renderCustomFeedEmptyState}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function HomeScreenReady({
|
function HomeScreenReady({
|
||||||
preferences,
|
preferences,
|
||||||
}: Props & {
|
}: Props & {
|
||||||
preferences: UsePreferencesQueryResponse
|
preferences: UsePreferencesQueryResponse
|
||||||
}) {
|
}) {
|
||||||
|
const {hasSession} = useSession()
|
||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
const setMinimalShellMode = useSetMinimalShellMode()
|
||||||
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
|
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
|
||||||
const [selectedPage, setSelectedPage] = React.useState(0)
|
const [selectedPage, setSelectedPage] = React.useState(0)
|
||||||
|
@ -144,7 +116,7 @@ function HomeScreenReady({
|
||||||
return <CustomFeedEmptyState />
|
return <CustomFeedEmptyState />
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return hasSession ? (
|
||||||
<Pager
|
<Pager
|
||||||
testID="homeScreen"
|
testID="homeScreen"
|
||||||
onPageSelected={onPageSelected}
|
onPageSelected={onPageSelected}
|
||||||
|
@ -172,6 +144,20 @@ function HomeScreenReady({
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</Pager>
|
</Pager>
|
||||||
|
) : (
|
||||||
|
<Pager
|
||||||
|
testID="homeScreen"
|
||||||
|
onPageSelected={onPageSelected}
|
||||||
|
onPageScrollStateChanged={onPageScrollStateChanged}
|
||||||
|
renderTabBar={renderTabBar}
|
||||||
|
tabBarPosition="top">
|
||||||
|
<FeedPage
|
||||||
|
testID="customFeedPage"
|
||||||
|
isPageFocused
|
||||||
|
feed={`feedgen|at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot`}
|
||||||
|
renderEmptyState={renderCustomFeedEmptyState}
|
||||||
|
/>
|
||||||
|
</Pager>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue