fix: add loading to history screen
This commit is contained in:
parent
8f3f487080
commit
9afd06fe0f
1 changed files with 23 additions and 18 deletions
|
|
@ -10,6 +10,7 @@ import { HistoryByDayDTO } from '@dtos/HistoryByDayDTO';
|
|||
import { HistoryCard } from '@components/HistoryCard';
|
||||
import { ScreenHeader } from '@components/ScreenHeader';
|
||||
import { ToastMessage } from '@components/ToastMessage';
|
||||
import { Loading } from '@components/Loading';
|
||||
|
||||
export function History() {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
|
@ -47,24 +48,28 @@ export function History() {
|
|||
<VStack flex={1}>
|
||||
<ScreenHeader title="Histórico" />
|
||||
|
||||
<SectionList
|
||||
sections={exercises}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={({ item }) => <HistoryCard data={item} />}
|
||||
renderSectionHeader={({ section }) => (
|
||||
<Heading color="$gray200" fontSize="$md" mt="$10" mb="$3">
|
||||
{section.title}
|
||||
</Heading>
|
||||
)}
|
||||
style={{ paddingHorizontal: 32 }}
|
||||
contentContainerStyle={exercises.length === 0 && { flex: 1, justifyContent: 'center' }}
|
||||
ListEmptyComponent={() => (
|
||||
<Text color="$gray100" textAlign="center">
|
||||
Não há exercícios registrados ainda.{'\n'}Vamos fazer exercícios hoje?
|
||||
</Text>
|
||||
)}
|
||||
showsVerticalScrollIndicator={false}
|
||||
/>
|
||||
{isLoading ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<SectionList
|
||||
sections={exercises}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={({ item }) => <HistoryCard data={item} />}
|
||||
renderSectionHeader={({ section }) => (
|
||||
<Heading color="$gray200" fontSize="$md" mt="$10" mb="$3">
|
||||
{section.title}
|
||||
</Heading>
|
||||
)}
|
||||
style={{ paddingHorizontal: 32 }}
|
||||
contentContainerStyle={exercises.length === 0 && { flex: 1, justifyContent: 'center' }}
|
||||
ListEmptyComponent={() => (
|
||||
<Text color="$gray100" textAlign="center">
|
||||
Não há exercícios registrados ainda.{'\n'}Vamos fazer exercícios hoje?
|
||||
</Text>
|
||||
)}
|
||||
showsVerticalScrollIndicator={false}
|
||||
/>
|
||||
)}
|
||||
</VStack>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue