mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Reply working
This commit is contained in:
@ -1,35 +1,54 @@
|
||||
import { Feather } from '@expo/vector-icons'
|
||||
import React from 'react'
|
||||
import React, { useMemo } from 'react'
|
||||
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native'
|
||||
import { QueryStatus } from 'react-query'
|
||||
import { ButtonRow } from 'src/components/Button'
|
||||
import { StyleConstants } from 'src/utils/styles/constants'
|
||||
import { useTheme } from 'src/utils/styles/ThemeManager'
|
||||
|
||||
export interface Props {
|
||||
isLoading: boolean
|
||||
isError: boolean
|
||||
status: QueryStatus
|
||||
refetch: () => void
|
||||
}
|
||||
|
||||
const TimelineEmpty: React.FC<Props> = ({ isLoading, isError, refetch }) => {
|
||||
const TimelineEmpty: React.FC<Props> = ({ status, refetch }) => {
|
||||
const { theme } = useTheme()
|
||||
|
||||
return (
|
||||
<View style={styles.base}>
|
||||
{isLoading && <ActivityIndicator />}
|
||||
{isError && (
|
||||
<>
|
||||
<Feather
|
||||
name='frown'
|
||||
size={StyleConstants.Font.Size.L}
|
||||
color={theme.primary}
|
||||
/>
|
||||
<Text style={[styles.error, { color: theme.primary }]}>加载错误</Text>
|
||||
<ButtonRow text='重试' onPress={() => refetch()} />
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
const children = useMemo(() => {
|
||||
switch (status) {
|
||||
case 'loading':
|
||||
return <ActivityIndicator />
|
||||
case 'error':
|
||||
return (
|
||||
<>
|
||||
<Feather
|
||||
name='frown'
|
||||
size={StyleConstants.Font.Size.L}
|
||||
color={theme.primary}
|
||||
/>
|
||||
<Text style={[styles.error, { color: theme.primary }]}>
|
||||
加载错误
|
||||
</Text>
|
||||
<ButtonRow text='重试' onPress={() => refetch()} />
|
||||
</>
|
||||
)
|
||||
case 'success':
|
||||
return (
|
||||
<>
|
||||
<Feather
|
||||
name='smartphone'
|
||||
size={StyleConstants.Font.Size.L}
|
||||
color={theme.primary}
|
||||
/>
|
||||
<Text style={[styles.error, { color: theme.primary }]}>
|
||||
空无一物
|
||||
</Text>
|
||||
<ButtonRow text='刷新试试' onPress={() => refetch()} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
}, [status])
|
||||
return <View style={styles.base} children={children} />
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
Reference in New Issue
Block a user