feat: add loading state while retrieving habits
This commit is contained in:
parent
1c648972d5
commit
57058c97b1
@ -1,10 +1,11 @@
|
|||||||
import { SafeAreaView } from "react-native-safe-area-context"
|
import { SafeAreaView } from "react-native-safe-area-context"
|
||||||
|
import { ActivityIndicator } from "react-native-paper"
|
||||||
|
|
||||||
import { HabitsHistory } from "@/presentation/react/components/HabitsHistory/HabitsHistory"
|
import { HabitsHistory } from "@/presentation/react/components/HabitsHistory/HabitsHistory"
|
||||||
import { useHabitsTracker } from "@/presentation/react/contexts/HabitsTracker"
|
import { useHabitsTracker } from "@/presentation/react/contexts/HabitsTracker"
|
||||||
|
|
||||||
const HabitsPage: React.FC = () => {
|
const HabitsPage: React.FC = () => {
|
||||||
const { habitsTracker } = useHabitsTracker()
|
const { habitsTracker, retrieveHabitsTracker } = useHabitsTracker()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView
|
<SafeAreaView
|
||||||
@ -12,10 +13,16 @@ const HabitsPage: React.FC = () => {
|
|||||||
{
|
{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
justifyContent:
|
||||||
|
retrieveHabitsTracker.state === "loading" ? "center" : "flex-start",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<HabitsHistory habitsHistory={habitsTracker.habitsHistory} />
|
{retrieveHabitsTracker.state === "loading" ? (
|
||||||
|
<ActivityIndicator animating size="large" />
|
||||||
|
) : (
|
||||||
|
<HabitsHistory habitsHistory={habitsTracker.habitsHistory} />
|
||||||
|
)}
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user