Revize b5ac7218
Přidáno uživatelem Fantič před více než 1 rok
src/pages/NotesViewPage.tsx | ||
---|---|---|
1 |
import React, { useEffect, useState } from "react" |
|
1 |
import React, { useCallback, useEffect, useState } from "react"
|
|
2 | 2 |
import { log } from "../logging/logger" |
3 | 3 |
import { DrawerScreenProps } from "@react-navigation/drawer" |
4 | 4 |
import { Box, Button, ChevronDownIcon, ChevronUpIcon, Flex, HStack, MinusIcon, Popover, Switch, Text, VStack } from "native-base" |
... | ... | |
10 | 10 |
import LoadingBox from "../components/loading/LoadingBox" |
11 | 11 |
import { createNote, getAllNotes } from "../stores/actions/notesThunks" |
12 | 12 |
import { RootDrawerParamList } from "./Navigation" |
13 |
import { Dimensions } from "react-native" |
|
13 | 14 |
const NotesViewPage = ({ navigation }: DrawerScreenProps<RootDrawerParamList, 'Notes'>) => { |
14 | 15 |
|
15 | 16 |
const { notes, notesLoading, requestPending, triggerRefresh } = useSelector((state: RootState) => state.noteViewState) |
... | ... | |
26 | 27 |
date: SortOptions.None |
27 | 28 |
}); |
28 | 29 |
|
29 |
const handleSortChanged = (key: "items" | "date") => { |
|
30 |
const handleSortChanged = useCallback((key: "items" | "date") => {
|
|
30 | 31 |
let currentState = sortSettings[key]; |
31 | 32 |
if (currentState == SortOptions.None) { |
32 | 33 |
setSortSettings({ |
... | ... | |
46 | 47 |
[key]: SortOptions.None |
47 | 48 |
}) |
48 | 49 |
} |
49 |
} |
|
50 |
}, [setSortSettings]);
|
|
50 | 51 |
|
51 | 52 |
const getSortIcon = (sortOption: SortOptions, size: string) => { |
52 | 53 |
switch (sortOption) { |
... | ... | |
103 | 104 |
|
104 | 105 |
|
105 | 106 |
return ( |
106 |
<Box width="92%" marginLeft="5%">
|
|
107 |
<Box marginLeft={2.5} marginRight={2.5} marginTop={2.5}>
|
|
107 | 108 |
<VStack> |
108 |
<HStack marginTop="5%">
|
|
109 |
<Box width="30%" justifyContent={"center"}>
|
|
109 |
<HStack height={75} justifyContent="space-between">
|
|
110 |
<Box justifyContent={"center"}> |
|
110 | 111 |
<Popover // @ts-ignore |
111 | 112 |
trigger={triggerProps => { |
112 | 113 |
return <Button colorScheme="primary" {...triggerProps} onPress={() => setIsSortOpen(true)}> |
... | ... | |
141 | 142 |
</Popover.Content> |
142 | 143 |
</Popover> |
143 | 144 |
</Box> |
144 |
<VStack width="70%" space="0"> |
|
145 |
<Flex direction="row" alignItems="center" justify="flex-end"> |
|
145 |
|
|
146 |
<VStack space={0.5}> |
|
147 |
<Flex direction="row" alignItems="center" justify="flex-end" height={35}> |
|
146 | 148 |
<Text>My comments</Text> |
147 | 149 |
<Switch isChecked={myCommentsCheck} onValueChange={() => { if (!notesLoading) setMyCommentsCheck(!myCommentsCheck) }} size="md" /> |
148 | 150 |
</Flex> |
149 |
<Flex direction="row" alignItems="center" justify="flex-end" marginTop="-7.5%">
|
|
151 |
<Flex direction="row" alignItems="center" justify="flex-end" height={35}>
|
|
150 | 152 |
<Text>General comments</Text> |
151 | 153 |
<Switch isChecked={generalCommentsCheck} onValueChange={() => { if (!notesLoading) setGeneralCommentsCheck(!generalCommentsCheck) }} size="md" /> |
152 | 154 |
</Flex> |
153 | 155 |
</VStack> |
154 | 156 |
</HStack> |
155 |
<Box> |
|
156 |
{ |
|
157 |
notesLoading ? ( |
|
158 |
<LoadingBox text="Loading notes" /> |
|
159 |
) |
|
160 |
: |
|
161 |
(<NotesListView notes={notes} navigation={navigation} handleCreateComment={handleCreateComment} requestPending={requestPending} />) |
|
162 |
} |
|
163 |
</Box> |
|
157 |
{ |
|
158 |
notesLoading ? ( |
|
159 |
<LoadingBox text="Loading notes" /> |
|
160 |
) |
|
161 |
: |
|
162 |
(<NotesListView notes={notes} navigation={navigation} handleCreateComment={handleCreateComment} requestPending={requestPending} />) |
|
163 |
} |
|
164 | 164 |
|
165 | 165 |
|
166 | 166 |
</VStack> |
Také k dispozici: Unified diff
#re 10797 NoteViewPage refactor -> Responsive layout