Projekt

Obecné

Profil

« Předchozí | Další » 

Revize ca53e9f1

Přidáno uživatelem Schwobik před téměř 2 roky(ů)

Demo of listview implemented
re #10342

Zobrazit rozdíly:

src/api/searchService.ts
6 6
}
7 7

  
8 8
export const searchRequest = async (params: SearchParams) => {
9
    return await axiosInstance.get(`/api/search_v2/${ (params.inventory ? `inventory=${ params.inventory }` : "")}`)
9
    return await axiosInstance.get(`/search_v2${ (params.inventory ? `?inventory=${ params.inventory }` : "")}`)
10 10
}
src/components/listView/ItemPreview.tsx
1
import { Center } from "native-base"
1
import { Center, HStack, Image, Text, VStack } from "native-base"
2 2

  
3 3
interface ItemPreviewProps {
4 4
    caption: string
5 5
    title: string
6
    name: string
7
    image: string
6
    name?: string
7
    image?: string
8 8
}
9 9

  
10 10
const ItemPreview = (props: ItemPreviewProps) => {
11 11

  
12 12
    return (
13 13
        <>
14
            <Center>
15 14

  
16
            </Center>
15
            <HStack
16
                space={ 2 }
17
                flex={ 1 }
18
                alignItems={ "start" }
19
            >
20
                <Image
21
                    source={ {uri: `http:/147.228.173.159/static/images/${ props.image ? props.image : "thumb-Rel-78.png" }`} }
22
                    size={ "sm" }
23
                    alt={ props.image ? props.image : "thumb-Rel-78.png" }
24
                />
25
                <VStack>
26
                    <Text>{ props.name }</Text>
27
                    <Text>{ props.caption }</Text>
28
                    <Text>{ props.title }</Text>
29
                </VStack>
30
            </HStack>
17 31
        </>
18 32
    )
19 33
}
src/components/listView/ListView.tsx
1 1
import { useEffect, useState } from "react"
2
import { Text } from "native-base"
2
import { ScrollView, Text, VStack } from "native-base"
3 3
import { useSelector } from "react-redux"
4 4
import { RootState } from "../../stores/store"
5
import ItemPreview from "./ItemPreview"
5 6

  
6 7
const ListView = () => {
7 8
    const items = useSelector((state: RootState) => state.listView.data)
8 9

  
9 10
    return (
10
        <>
11
            <Text>ListView</Text>
12
        </>
11
        <VStack
12
            space={ 2 }
13
            flex={ 1 }
14
            p={ 4 }
15
            alignItems={ "start" }
16
        >
17
            { items.map((item) => (
18
                <ItemPreview
19
                    caption={ item.object[0].caption }
20
                    title={ item.text }
21
                    name={
22
                        item.object[0].name ?
23
                            item.object[0].name[0].getty_data ?
24
                                item.object[0].name[0].getty_data.display_name
25
                                :
26
                                item.object[0].name[0].value
27
                            :
28
                            undefined
29
                    }
30
                    image={ item.object[1] && item.object[1].images && item.object[1].images ? item.object[1].images[0].file : undefined }
31
                />
32
            )) }
33
        </VStack>
13 34
    )
14 35
}
15 36

  
src/components/search/SearchForm.tsx
50 50

  
51 51

  
52 52
    const searchSubmit = () => {
53
        console.log("search")
54 53
        dispatch(search({inventory: selectedInventories ? selectedInventories[0] : undefined}))
55 54
    }
56 55

  
src/pages/LoginPage.tsx
80 80
                            <FormControl.Label>Username</FormControl.Label>
81 81
                            <Input
82 82
                                // value={username}
83
                                textContentType={"username"}
84
                                autoComplete={"username"}
85
                                onSubmitEditing={ () => { loginUser() } }
83 86
                                onChangeText={ (username) => setUsername(username) }
84 87
                            />
85 88
                        </FormControl>
86 89
                        <FormControl>
87 90
                            <FormControl.Label>Password</FormControl.Label>
88
                            <Input type="password"
89
                                // value={password}
90
                                   onChangeText={ (password) => setPassword(password) }
91
                            <Input
92
                                type="password"
93
                                autoComplete={ "password" }
94
                                id={ "password" }
95
                                returnKeyType={ "done" }
96
                                onSubmitEditing={ () => loginUser() }
97
                                onChangeText={ (password) => setPassword(password) }
91 98
                            />
92
                            <Link _text={ {
93
                                fontSize: "xs",
94
                                fontWeight: "500",
95
                                color: "indigo.500"
96
                            } } alignSelf="flex-end" mt="1">
97
                                Forget Password?
98
                            </Link>
99 99
                        </FormControl>
100 100
                        <Button
101 101
                            mt="2"
102 102
                            colorScheme="indigo"
103
                            onPress={ () => loginUser() }
103
                            onPress={ loginUser }
104 104
                        >
105 105
                            Sign in
106 106
                        </Button>
src/pages/SearchPage.tsx
1
import { Center, KeyboardAvoidingView, Text } from "native-base"
1
import { Center, KeyboardAvoidingView, ScrollView, Text, VStack } from "native-base"
2 2
import ListView from "../components/listView/ListView"
3 3
import SearchForm from "../components/search/SearchForm"
4 4
import { Platform } from "react-native"
......
8 8
    return (
9 9
        <KeyboardAvoidingView
10 10
            h={ {
11
                base: "400px",
12 11
                lg: "auto"
13 12
            } }
14 13
            behavior={ Platform.OS === "ios" ? "padding" : "height" }
15 14
        >
16
            <Center>
17
                <SearchForm/>
18
                <ListView/>
19
            </Center>
15
            <ScrollView>
16
                <VStack>
17
                    <SearchForm/>
18
                    <ListView/>
19
                </VStack>
20
            </ScrollView>
20 21
        </KeyboardAvoidingView>
21 22
    )
22 23
}
src/types/listViewTypes.ts
23 23
    src?: ItemSource
24 24
}
25 25

  
26
export type Item = {
27
    caption: string
28
    type: string
29
    name?: PersonName[]
30
    images?: ItemImage[]
31
    origDate?: string
32

  
33
}
26
export type Item = [
27
    {
28
        caption: string
29
        type: string
30
        name?: PersonName[]
31
    },
32
    {
33
        images?: ItemImage[]
34
        origDate?: string
35
    }
36
]
34 37

  
35 38
export type PersonName = {
36 39
    value?: string

Také k dispozici: Unified diff