Tune the empty state code

This commit is contained in:
Paul Frazee
2023-05-05 13:52:53 -05:00
parent 1b7763fae6
commit be4171c168
4 changed files with 83 additions and 148 deletions
-86
View File
@@ -1,86 +0,0 @@
import React from 'react'
import {StyleSheet, View} from 'react-native'
import {
FontAwesomeIcon,
FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome'
import {Text} from '../util/text/Text'
import {Button} from '../util/forms/Button'
import {usePalette} from 'lib/hooks/usePalette'
import {s} from 'lib/styles'
export function MyListsEmptyState() {
const pal = usePalette('default')
const palInverted = usePalette('inverted')
const onPressCreateList = React.useCallback(() => {
// TODO
}, [])
return (
<View style={styles.container}>
<View style={styles.iconContainer}>
<FontAwesomeIcon
icon="list-ul"
style={[styles.icon, pal.text]}
size={62}
/>
</View>
<Text type="xl-medium" style={[s.textCenter, pal.text]}>
Lists are public collections of users. You can create a list or find
other users' lists on their profiles.
</Text>
<View style={styles.btns}>
<Button type="inverted" style={styles.btn} onPress={onPressCreateList}>
<FontAwesomeIcon
icon="plus"
style={palInverted.text as FontAwesomeIconStyle}
size={14}
/>
<Text type="lg-medium" style={palInverted.text}>
New mutelist
</Text>
</Button>
</View>
<View style={[pal.viewLight, styles.notice]}>
<Text type="lg" style={[pal.textLight, s.textCenter]}>
Currently only "mutelists" are available. Feed lists will be
implemented soon!
</Text>
</View>
</View>
)
}
const styles = StyleSheet.create({
container: {
height: '100%',
paddingVertical: 40,
paddingHorizontal: 30,
},
iconContainer: {
marginBottom: 16,
},
icon: {
marginLeft: 'auto',
marginRight: 'auto',
},
btns: {
flexDirection: 'row',
justifyContent: 'center',
},
btn: {
gap: 10,
marginVertical: 20,
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 14,
paddingHorizontal: 24,
borderRadius: 30,
},
notice: {
borderRadius: 12,
paddingHorizontal: 12,
paddingVertical: 10,
marginHorizontal: 30,
},
})
@@ -4,12 +4,20 @@ import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import {Text} from '../util/text/Text' import {IconProp} from '@fortawesome/fontawesome-svg-core'
import {Button} from '../util/forms/Button' import {Text} from './text/Text'
import {Button} from './forms/Button'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {s} from 'lib/styles' import {s} from 'lib/styles'
export function SubscribedMutelistsEmptyState() { interface Props {
icon: IconProp
message: string
buttonLabel: string
onPress: () => void
}
export function EmptyStateWithButton(props: Props) {
const pal = usePalette('default') const pal = usePalette('default')
const palInverted = usePalette('inverted') const palInverted = usePalette('inverted')
@@ -21,25 +29,23 @@ export function SubscribedMutelistsEmptyState() {
<View style={styles.container}> <View style={styles.container}>
<View style={styles.iconContainer}> <View style={styles.iconContainer}>
<FontAwesomeIcon <FontAwesomeIcon
icon="list-ul" icon={props.icon}
style={[styles.icon, pal.text]} style={[styles.icon, pal.text]}
size={62} size={62}
/> />
</View> </View>
<Text type="xl-medium" style={[s.textCenter, pal.text]}> <Text type="xl-medium" style={[s.textCenter, pal.text]}>
You can subscribe to mutelists to automatically mute all of the users {props.message}
they include. Mutelists are public but your subscription to a mutelist
is private.
</Text> </Text>
<View style={styles.btns}> <View style={styles.btns}>
<Button type="inverted" style={styles.btn} onPress={onPressCreateList}> <Button type="inverted" style={styles.btn} onPress={props.onPress}>
<FontAwesomeIcon <FontAwesomeIcon
icon="plus" icon="plus"
style={palInverted.text as FontAwesomeIconStyle} style={palInverted.text as FontAwesomeIconStyle}
size={14} size={14}
/> />
<Text type="lg-medium" style={palInverted.text}> <Text type="lg-medium" style={palInverted.text}>
New mutelist {props.buttonLabel}
</Text> </Text>
</Button> </Button>
</View> </View>
+1 -1
View File
@@ -74,7 +74,7 @@ export const ModerationScreen = withAuthRequired(
/> />
</View> </View>
<Text type="lg" style={pal.text}> <Text type="lg" style={pal.text}>
Mutelist subscriptions Mute-list subscriptions
</Text> </Text>
</Link> </Link>
<Link <Link
+67 -52
View File
@@ -1,15 +1,17 @@
import React from 'react' import React from 'react'
import {StyleSheet} from 'react-native'
import {useFocusEffect} from '@react-navigation/native' import {useFocusEffect} from '@react-navigation/native'
import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types' import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types'
import {withAuthRequired} from 'view/com/auth/withAuthRequired' import {withAuthRequired} from 'view/com/auth/withAuthRequired'
import {TabBar} from '../com/pager/TabBar' import {EmptyStateWithButton} from 'view/com/util/EmptyStateWithButton'
import {Pager, RenderTabBarFnProps} from 'view/com/pager/Pager' import {MutelistsEmptyState} from 'view/com/lists/MutelistsEmptyState'
import {MyListsEmptyState} from 'view/com/lists/MyListsEmptyState'
import {SubscribedMutelistsEmptyState} from 'view/com/lists/SubscribedMutelistsEmptyState'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {ListsListModel} from 'state/models/lists/lists-list' import {ListsListModel} from 'state/models/lists/lists-list'
import {ListsList} from 'view/com/lists/ListsList' import {ListsList} from 'view/com/lists/ListsList'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {CenteredView} from 'view/com/util/Views'
import {ViewHeader} from 'view/com/util/ViewHeader'
import {isDesktopWeb} from 'platform/detection'
type Props = NativeStackScreenProps< type Props = NativeStackScreenProps<
CommonNavigatorParams, CommonNavigatorParams,
@@ -18,13 +20,6 @@ type Props = NativeStackScreenProps<
export const ModerationMuteListsScreen = withAuthRequired(({route}: Props) => { export const ModerationMuteListsScreen = withAuthRequired(({route}: Props) => {
const pal = usePalette('default') const pal = usePalette('default')
const store = useStores() const store = useStores()
const [selectedPage, setSelectedPage] = React.useState(0)
const mine: ListsListModel = React.useMemo(() => {
const list = new ListsListModel(store, store.me.did)
list.loadMore()
return list
}, [store])
const mutelists: ListsListModel = React.useMemo(() => { const mutelists: ListsListModel = React.useMemo(() => {
const list = new ListsListModel(store, 'mutelists') const list = new ListsListModel(store, 'mutelists')
@@ -35,54 +30,74 @@ export const ModerationMuteListsScreen = withAuthRequired(({route}: Props) => {
useFocusEffect( useFocusEffect(
React.useCallback(() => { React.useCallback(() => {
store.shell.setMinimalShellMode(false) store.shell.setMinimalShellMode(false)
}, [store, selectedPage]), }, [store]),
) )
const onPageSelected = React.useCallback( const renderEmptyState = React.useCallback(() => {
(index: number) => {
setSelectedPage(index)
},
[store, setSelectedPage],
)
const renderTabBar = React.useCallback((props: RenderTabBarFnProps) => {
return ( return (
<TabBar <EmptyStateWithButton
{...props} icon="users-slash"
items={['My Lists', 'Mutelists']} message="You can subscribe to mute-lists to automatically mute all of the users they include. Mute-lists are public but your subscription to a mute-list is private."
indicatorColor={pal.colors.link} buttonLabel="New Mute List"
indicatorPosition="bottom" onPress={() => undefined}
testID="tabs"
/> />
) )
}, []) }, [])
const renderMineEmptyState = React.useCallback(() => {
return <MyListsEmptyState />
}, [])
const renderMutelistsEmptyState = React.useCallback(() => {
return <SubscribedMutelistsEmptyState />
}, [])
return ( return (
<Pager <CenteredView
testID="listsScreen" style={[
onPageSelected={onPageSelected} styles.container,
renderTabBar={renderTabBar} isDesktopWeb && styles.containerDesktop,
tabBarPosition="top"> pal.view,
<ListsList pal.border,
key="1" ]}
testID="minePage" testID="moderationMutelistsScreen">
listsList={mine} <ViewHeader title="Mute-list Subscriptions" showOnDesktop />
renderEmptyState={renderMineEmptyState} <ListsList listsList={mutelists} renderEmptyState={renderEmptyState} />
/> </CenteredView>
<ListsList
key="2"
testID="mutelistsPage"
listsList={mutelists}
renderEmptyState={renderMutelistsEmptyState}
/>
</Pager>
) )
}) })
const styles = StyleSheet.create({
container: {
flex: 1,
paddingBottom: isDesktopWeb ? 0 : 100,
},
containerDesktop: {
borderLeftWidth: 1,
borderRightWidth: 1,
},
title: {
textAlign: 'center',
marginTop: 12,
marginBottom: 12,
},
description: {
textAlign: 'center',
paddingHorizontal: 30,
marginBottom: 14,
},
descriptionDesktop: {
marginTop: 14,
},
flex1: {
flex: 1,
},
empty: {
paddingHorizontal: 20,
paddingVertical: 20,
borderRadius: 16,
marginHorizontal: 24,
marginTop: 10,
},
emptyText: {
textAlign: 'center',
},
footer: {
height: 200,
paddingTop: 20,
},
})