Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f386a4fe

Přidáno uživatelem Fantič před více než 1 rok

re #10818 Toast: implementation to pages

Zobrazit rozdíly:

src/pages/HomePage.tsx
1
import { Center, Image, Pressable, ScrollView, Text } from "native-base"
1
import { Center, Image, Pressable, ScrollView, Text, useToast } from "native-base"
2 2
import { useDispatch, useSelector } from "react-redux"
3 3
import { AppDispatch, RootState } from "../stores/store"
4 4
import { useContext, useEffect, useState } from "react"
......
9 9
import { RootDrawerParamList } from "./Navigation"
10 10
import { log } from "../logging/logger"
11 11
import { HOME_PAGE_IMG_URL } from "../api/constants"
12
import { ErrorToast } from "../components/toast/ErrorToast"
12 13
// import { Image } from "react-native"
13 14

  
14 15
const HomePage = ({navigation}: DrawerScreenProps<RootDrawerParamList, 'Home'>) => {
15 16
    const data = useSelector((state: RootState) => state.homePage.data)
16 17
    const loading = useSelector((state: RootState) => state.homePage.loading)
17
    const lastError = useSelector((state: RootState) => state.homePage.lastError)
18

  
18
    const lastError = useSelector((state: RootState) => state.itemViewState.lastError)
19
    const toast = useToast();
20
  
19 21
    useEffect(() => {
20 22
        if (lastError) {
21

  
23
            toast.closeAll()
24
            toast.show({
25
                render: ({
26
                    id
27
                }) => {
28
                    return <ErrorToast headerText={"Error"} text={lastError} onClose={() => toast.close(id)} />;
29
                },
30
                duration: 3000
31
            });
22 32
        }
23

  
24 33
    }, [lastError])
25 34

  
26 35
    const [aspectRatio, setAspectRatio] = useState(1.0)

Také k dispozici: Unified diff