add empty view to CustomAlgorithms screen
This commit is contained in:
parent
8948118d5c
commit
6105314f15
2 changed files with 43 additions and 34 deletions
|
@ -11,6 +11,7 @@ import {AlgoItemModel} from 'state/models/feeds/algo/algo-item'
|
||||||
const AlgoItem = observer(
|
const AlgoItem = observer(
|
||||||
({item, style}: {item: AlgoItemModel; style?: StyleProp<ViewStyle>}) => {
|
({item, style}: {item: AlgoItemModel; style?: StyleProp<ViewStyle>}) => {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, style]} key={item.data.uri}>
|
<View style={[styles.container, style]} key={item.data.uri}>
|
||||||
<View style={[styles.headerContainer]}>
|
<View style={[styles.headerContainer]}>
|
||||||
|
@ -19,7 +20,7 @@ const AlgoItem = observer(
|
||||||
</View>
|
</View>
|
||||||
<View style={[styles.headerTextContainer]}>
|
<View style={[styles.headerTextContainer]}>
|
||||||
<Text style={[pal.text, s.bold]}>
|
<Text style={[pal.text, s.bold]}>
|
||||||
{item.data.displayName ?? 'Feed name'}
|
{item.data.displayName ? item.data.displayName : 'Feed name'}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[pal.textLight, styles.description]}>
|
<Text style={[pal.textLight, styles.description]}>
|
||||||
{item.data.description ??
|
{item.data.description ??
|
||||||
|
|
|
@ -44,45 +44,46 @@ const CustomAlgorithms = withAuthRequired(
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenteredView style={{flex: 1}}>
|
<CenteredView style={[s.flex1]}>
|
||||||
<ViewHeader title="Custom Algorithms" showOnDesktop />
|
<ViewHeader title="Custom Algorithms" showOnDesktop />
|
||||||
{!savedFeeds.hasContent || savedFeeds.isEmpty ? (
|
<FlatList
|
||||||
<View style={[pal.border, !isDesktopWeb && s.flex1]}>
|
style={[!isDesktopWeb && s.flex1]}
|
||||||
<View style={[pal.viewLight]}>
|
data={savedFeeds.feeds}
|
||||||
|
keyExtractor={item => item.data.uri}
|
||||||
|
refreshControl={
|
||||||
|
<RefreshControl
|
||||||
|
refreshing={savedFeeds.isRefreshing}
|
||||||
|
onRefresh={() => savedFeeds.refresh()}
|
||||||
|
tintColor={pal.colors.text}
|
||||||
|
titleColor={pal.colors.text}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onEndReached={() => savedFeeds.loadMore()}
|
||||||
|
renderItem={({item}) => <AlgoItem key={item.data.uri} item={item} />}
|
||||||
|
initialNumToRender={15}
|
||||||
|
ListFooterComponent={() => (
|
||||||
|
<View style={styles.footer}>
|
||||||
|
{savedFeeds.isLoading && <ActivityIndicator />}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
ListEmptyComponent={() => (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
pal.border,
|
||||||
|
!isDesktopWeb && s.flex1,
|
||||||
|
pal.viewLight,
|
||||||
|
styles.empty,
|
||||||
|
]}>
|
||||||
<Text type="lg" style={[pal.text]}>
|
<Text type="lg" style={[pal.text]}>
|
||||||
You don't have any saved feeds. To save a feed, click the save
|
You don't have any saved feeds. To save a feed, click the save
|
||||||
button when a custom feed or algorithm shows up.
|
button when a custom feed or algorithm shows up.
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
)}
|
||||||
) : (
|
extraData={savedFeeds.isLoading}
|
||||||
<FlatList
|
// @ts-ignore our .web version only -prf
|
||||||
style={[!isDesktopWeb && s.flex1]}
|
desktopFixedHeight
|
||||||
data={savedFeeds.feeds}
|
/>
|
||||||
keyExtractor={item => item.data.uri}
|
|
||||||
refreshControl={
|
|
||||||
<RefreshControl
|
|
||||||
refreshing={savedFeeds.isRefreshing}
|
|
||||||
onRefresh={() => savedFeeds.refresh()}
|
|
||||||
tintColor={pal.colors.text}
|
|
||||||
titleColor={pal.colors.text}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onEndReached={() => savedFeeds.loadMore()}
|
|
||||||
renderItem={({item}) => (
|
|
||||||
<AlgoItem key={item.data.uri} item={item} />
|
|
||||||
)}
|
|
||||||
initialNumToRender={15}
|
|
||||||
ListFooterComponent={() => (
|
|
||||||
<View style={styles.footer}>
|
|
||||||
{savedFeeds.isLoading && <ActivityIndicator />}
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
extraData={savedFeeds.isLoading}
|
|
||||||
// @ts-ignore our .web version only -prf
|
|
||||||
desktopFixedHeight
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
|
@ -94,4 +95,11 @@ const styles = StyleSheet.create({
|
||||||
footer: {
|
footer: {
|
||||||
paddingVertical: 20,
|
paddingVertical: 20,
|
||||||
},
|
},
|
||||||
|
empty: {
|
||||||
|
paddingHorizontal: 20,
|
||||||
|
paddingVertical: 20,
|
||||||
|
borderRadius: 16,
|
||||||
|
marginHorizontal: 24,
|
||||||
|
marginTop: 10,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue