Revize 4da7b143
Přidáno uživatelem Schwobik před téměř 2 roky(ů)
src/pages/HomePage.tsx | ||
---|---|---|
1 |
import { Center, Image, Text } from "native-base" |
|
1 |
import { Center, Image, Pressable, ScrollView, Text } from "native-base" |
|
2 |
import { useDispatch, useSelector } from "react-redux" |
|
3 |
import { AppDispatch, RootState } from "../stores/store" |
|
4 |
import { useEffect, useState } from "react" |
|
5 |
import { fetchData } from "../stores/actions/homePageThunks" |
|
6 |
import { ApplicationHeading } from "../components/reusables/ApplicationHeading" |
|
7 |
import LoadingBox from "../components/loading/LoadingBox" |
|
8 |
import { DrawerScreenProps } from "@react-navigation/drawer" |
|
9 |
import { RootDrawerParamList } from "./Navigation" |
|
10 |
import { log } from "../logging/logger" |
|
11 |
// import { Image } from "react-native" |
|
12 |
|
|
13 |
const HomePage = ({navigation}: DrawerScreenProps<RootDrawerParamList, 'Home'>) => { |
|
14 |
const data = useSelector((state: RootState) => state.homePage.data) |
|
15 |
const loading = useSelector((state: RootState) => state.homePage.loading) |
|
16 |
const error = useSelector((state: RootState) => state.homePage.lastError) |
|
17 |
const [aspectRatio, setAspectRatio] = useState(1.0) |
|
18 |
|
|
19 |
const dispatch = useDispatch<AppDispatch>() |
|
20 |
|
|
21 |
useEffect(() => { |
|
22 |
if (data === null || data.length === 0 && !loading) { |
|
23 |
dispatch(fetchData()) |
|
24 |
} |
|
25 |
// Image.getSize("http:/147.228.173.159/static/home/Rudolf-Aachen-crop.png", (width, height) => { |
|
26 |
// setAspectRatio(width / height) |
|
27 |
// }) |
|
28 |
|
|
29 |
}, []) |
|
2 | 30 |
|
3 |
const HomePage = () => { |
|
4 | 31 |
return ( |
5 |
<Center> |
|
6 |
<Text>Home Page</Text> |
|
7 |
<Image |
|
8 |
source={{uri: "http:/147.228.173.159/static/home/Rudolf-Aachen-crop.png"}} |
|
9 |
w={"100%"} |
|
10 |
h={"50%"} |
|
11 |
alt={"Rudolf-Aachen"} |
|
12 |
/> |
|
32 |
<Center m={2} mb={10}> |
|
33 |
{ loading ? ( |
|
34 |
<LoadingBox text={ "Loading..." }/> |
|
35 |
) : ( |
|
36 |
<> |
|
37 |
<ApplicationHeading/> |
|
38 |
<ScrollView > |
|
39 |
<Image |
|
40 |
source={ {uri: "http:/147.228.173.159/static/home/Rudolf-Aachen-crop.png"} } |
|
41 |
w={"100%"} h={ 200 } |
|
42 |
resizeMode={"contain"} |
|
43 |
alignSelf={ "center" } |
|
44 |
alt={ "Rudolf-Aachen" } |
|
45 |
/> |
|
46 |
{ data && data.length > 0 && ( |
|
47 |
<Text |
|
48 |
mx={ 2 } |
|
49 |
fontSize={ "sm" } |
|
50 |
lineHeight={"sm"} |
|
51 |
color={"gray.500"} |
|
52 |
textAlign={"justify"} |
|
53 |
> |
|
54 |
{data[0]["general"].text} |
|
55 |
</Text> |
|
56 |
)} |
|
57 |
<Text |
|
58 |
mt={ 2 } |
|
59 |
bold |
|
60 |
fontSize={"xl"} |
|
61 |
color={"primary.500"} |
|
62 |
> |
|
63 |
Inventories |
|
64 |
</Text> |
|
65 |
{ data && data.length > 1 && data.slice(1).map((item) => ( |
|
66 |
<Pressable |
|
67 |
onPress={() => navigation.navigate("Search", {inventoryId: Object.keys(item)[0]}) } |
|
68 |
key={ Object.values(item)[0].label } |
|
69 |
rounded={ "md" } |
|
70 |
borderWidth={ 1 } |
|
71 |
borderColor={ "gray.300" } |
|
72 |
m = { 2 } |
|
73 |
p={ 3 } |
|
74 |
> |
|
75 |
<Text |
|
76 |
bold |
|
77 |
fontSize={ "md" } |
|
78 |
mb={1} |
|
79 |
> |
|
80 |
{ Object.values(item)[0].label } |
|
81 |
</Text> |
|
82 |
<Text |
|
83 |
fontSize={ "sm" } |
|
84 |
lineHeight={"sm"} |
|
85 |
color={"gray.500"} |
|
86 |
textAlign={"justify"} |
|
87 |
> |
|
88 |
{ Object.values(item)[0].text } |
|
89 |
</Text> |
|
90 |
</Pressable> |
|
91 |
)) } |
|
92 |
|
|
93 |
</ScrollView> |
|
94 |
</> |
|
95 |
) } |
|
13 | 96 |
</Center> |
14 | 97 |
) |
15 | 98 |
} |
Také k dispozici: Unified diff
HomePage connected to new backend endpoint, SearchPage edited to take argument to display inventory content on open
re #10715