1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Reply working

This commit is contained in:
Zhiyuan Zheng
2020-12-13 01:24:25 +01:00
parent f0daae30cd
commit cfd2d40d02
13 changed files with 346 additions and 180 deletions

View File

@ -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({