Revize f22a2126
Přidáno uživatelem Michal Schwob před více než 1 rok
src/pages/NotesViewPage.tsx | ||
---|---|---|
1 | 1 |
import React, { useCallback, useEffect, useState } from "react" |
2 | 2 |
import { log } from "../logging/logger" |
3 | 3 |
import { DrawerScreenProps } from "@react-navigation/drawer" |
4 |
import { Box, Button, ChevronDownIcon, ChevronUpIcon, Flex, HStack, MinusIcon, Popover, Switch, Text, VStack, useToast } from "native-base" |
|
4 |
import { |
|
5 |
Box, |
|
6 |
Button, |
|
7 |
ChevronDownIcon, |
|
8 |
ChevronUpIcon, |
|
9 |
Flex, |
|
10 |
HStack, |
|
11 |
MinusIcon, |
|
12 |
Popover, |
|
13 |
Switch, |
|
14 |
Text, |
|
15 |
VStack, |
|
16 |
useToast, |
|
17 |
KeyboardAvoidingView |
|
18 |
} from "native-base" |
|
5 | 19 |
import { SortOptions } from "../types/general" |
6 | 20 |
import { Note } from "../types/note" |
7 | 21 |
import NotesListView from "../components/notes/NotesListView" |
... | ... | |
13 | 27 |
import { ErrorToast } from "../components/toast/ErrorToast" |
14 | 28 |
import { InfoToast } from "../components/toast/InfoToast" |
15 | 29 |
|
16 |
import { Dimensions } from "react-native";
|
|
30 |
import {Dimensions, Platform} from "react-native";
|
|
17 | 31 |
|
18 | 32 |
const NotesViewPage = ({ navigation }: DrawerScreenProps<RootStackParamList, 'Notes'>) => { |
19 | 33 |
|
... | ... | |
143 | 157 |
|
144 | 158 |
|
145 | 159 |
return ( |
146 |
<Box> |
|
147 |
<VStack> |
|
148 |
<Flex direction="row" align="flex-start" justifyContent="space-between" marginTop={1} marginLeft={2.5} marginRight={2.5}> |
|
149 |
<Text fontWeight="semibold" mt={3} ml={2} fontSize="md" color="#4D4D4D">General comments</Text> |
|
150 |
<Switch isChecked={generalCommentsCheck} onValueChange={() => { if (!notesLoading) setGeneralCommentsCheck(!generalCommentsCheck) }} size="lg" marginRight={2} /> |
|
151 |
</Flex> |
|
152 |
<Flex direction="row" align="flex-start" justifyContent="space-between" marginTop={-1} marginLeft={2.5} marginRight={2.5}> |
|
153 |
<Text fontWeight="semibold" mt={3} ml={2} fontSize="md" color="#4D4D4D">My comments</Text> |
|
154 |
<Switch padding={0} isChecked={myCommentsCheck} onValueChange={() => { if (!notesLoading) setMyCommentsCheck(!myCommentsCheck) }} size="lg" marginRight={2} /> |
|
155 |
</Flex> |
|
156 |
<Popover // @ts-ignore |
|
157 |
trigger={triggerProps => { |
|
158 |
return <Button marginLeft={4} marginBottom={2} width={150} backgroundColor="#F4DFAB" {...triggerProps} onPress={() => setIsSortOpen(true)} |
|
159 |
borderRadius={7} |
|
160 |
rightIcon={(sortSettings.date != SortOptions.None || sortSettings.items != SortOptions.None) ? (getSortIcon(sortSettings.date != SortOptions.None ? sortSettings.date : sortSettings.items, "xs", "#654B07")) : undefined} |
|
161 |
> |
|
162 |
<Text fontSize={14} color="#654B07"> |
|
163 |
Sort {(sortSettings.date != SortOptions.None || sortSettings.items != SortOptions.None) ? (sortSettings.date != SortOptions.None ? "by date" : "by items") : ""} |
|
164 |
</Text> |
|
165 |
</Button>; |
|
166 |
}} isOpen={isSortOpen} onClose={() => setIsSortOpen(!isSortOpen)}> |
|
167 |
<Popover.Content w="48"> |
|
168 |
<Popover.Arrow /> |
|
169 |
<Popover.CloseButton onPress={() => setIsSortOpen(false)} /> |
|
170 |
<Popover.Header><Text fontSize={"md"} color="#654B07">Sort Options</Text></Popover.Header> |
|
171 |
<Popover.Body> |
|
172 |
<VStack> |
|
173 |
<Button size="md" variant="outline" onPress={() => handleSortChanged("items", sortSettings)} |
|
174 |
rightIcon={getSortIcon(sortSettings.items, "sm", "#654B07")} |
|
160 |
|
|
161 |
<Box> |
|
162 |
<VStack> |
|
163 |
<Flex direction="row" align="flex-start" justifyContent="space-between" marginTop={1} marginLeft={2.5} marginRight={2.5}> |
|
164 |
<Text fontWeight="semibold" mt={3} ml={2} fontSize="md" color="primary.500">General comments</Text> |
|
165 |
<Switch isChecked={generalCommentsCheck} onValueChange={() => { if (!notesLoading) setGeneralCommentsCheck(!generalCommentsCheck) }} size="md" marginRight={2} /> |
|
166 |
</Flex> |
|
167 |
<Flex direction="row" align="flex-start" justifyContent="space-between" marginTop={0} marginLeft={2.5} marginRight={2.5}> |
|
168 |
<Text fontWeight="semibold" mt={3} ml={2} fontSize="md" color="primary.500" >My comments</Text> |
|
169 |
<Switch padding={0} isChecked={myCommentsCheck} onValueChange={() => { if (!notesLoading) setMyCommentsCheck(!myCommentsCheck) }} size="md" marginRight={2} /> |
|
170 |
</Flex> |
|
171 |
<Popover // @ts-ignore |
|
172 |
trigger={triggerProps => { |
|
173 |
return <Button marginLeft={4} marginBottom={2} width={150} backgroundColor="secondary.500" {...triggerProps} onPress={() => setIsSortOpen(true)} |
|
174 |
borderRadius={7} |
|
175 |
rightIcon={(sortSettings.date != SortOptions.None || sortSettings.items != SortOptions.None) ? (getSortIcon(sortSettings.date != SortOptions.None ? sortSettings.date : sortSettings.items, "xs", "primary.500")) : undefined} |
|
175 | 176 |
> |
176 |
Items</Button> |
|
177 |
<Button size="md" variant="outline" marginTop={"5%"} onPress={() => handleSortChanged("date", sortSettings)} |
|
178 |
rightIcon={getSortIcon(sortSettings.date, "sm", "#654B07")}> |
|
179 |
Date</Button> |
|
180 |
</VStack> |
|
181 |
</Popover.Body> |
|
182 |
<Popover.Footer justifyContent="flex-end"> |
|
183 |
<Button.Group space={2}> |
|
184 |
<Button colorScheme="coolGray" variant="ghost" onPress={() => setIsSortOpen(false)}> |
|
185 |
Cancel |
|
186 |
</Button> |
|
187 |
<Button backgroundColor={"#F4DFAB"} onPress={() => { setIsSortOpen(false); getNotes() }}> |
|
188 |
<Text color="#654B07"> |
|
189 |
Save |
|
177 |
<Text fontSize={14} color="primary.500"> |
|
178 |
Sort {(sortSettings.date != SortOptions.None || sortSettings.items != SortOptions.None) ? (sortSettings.date != SortOptions.None ? "by date" : "by items") : ""} |
|
190 | 179 |
</Text> |
191 |
</Button> |
|
192 |
</Button.Group> |
|
193 |
</Popover.Footer> |
|
194 |
</Popover.Content> |
|
195 |
</Popover> |
|
196 |
{ |
|
197 |
notesLoading ? ( |
|
198 |
<LoadingBox text="Loading notes" /> |
|
199 |
) |
|
200 |
: |
|
201 |
(<NotesListView height={Dimensions.get('window').height - 307} notes={notes} navigation={navigation} handleCreateComment={handleCreateComment} requestPending={requestPending} />) |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
</VStack> |
|
206 |
</Box> |
|
180 |
</Button>; |
|
181 |
}} isOpen={isSortOpen} onClose={() => setIsSortOpen(!isSortOpen)}> |
|
182 |
<Popover.Content w="48"> |
|
183 |
<Popover.Arrow /> |
|
184 |
<Popover.CloseButton onPress={() => setIsSortOpen(false)} /> |
|
185 |
<Popover.Header><Text fontSize={"md"} color="primary.500">Sort Options</Text></Popover.Header> |
|
186 |
<Popover.Body> |
|
187 |
<VStack> |
|
188 |
<Button size="md" variant="outline" onPress={() => handleSortChanged("items", sortSettings)} |
|
189 |
rightIcon={getSortIcon(sortSettings.items, "sm", "primary.500")} |
|
190 |
> |
|
191 |
Items</Button> |
|
192 |
<Button size="md" variant="outline" marginTop={"5%"} onPress={() => handleSortChanged("date", sortSettings)} |
|
193 |
rightIcon={getSortIcon(sortSettings.date, "sm", "primary.500")}> |
|
194 |
Date</Button> |
|
195 |
</VStack> |
|
196 |
</Popover.Body> |
|
197 |
<Popover.Footer justifyContent="flex-end"> |
|
198 |
<Button.Group space={2}> |
|
199 |
<Button colorScheme="coolGray" variant="ghost" onPress={() => setIsSortOpen(false)}> |
|
200 |
Cancel |
|
201 |
</Button> |
|
202 |
<Button backgroundColor={"secondary.500"} onPress={() => { setIsSortOpen(false); getNotes() }}> |
|
203 |
<Text color="primary.500"> |
|
204 |
Save |
|
205 |
</Text> |
|
206 |
</Button> |
|
207 |
</Button.Group> |
|
208 |
</Popover.Footer> |
|
209 |
</Popover.Content> |
|
210 |
</Popover> |
|
211 |
{ |
|
212 |
notesLoading ? ( |
|
213 |
<LoadingBox text="Loading notes" /> |
|
214 |
) |
|
215 |
: |
|
216 |
(<NotesListView height={Dimensions.get('window').height - 400} notes={notes} navigation={navigation} handleCreateComment={handleCreateComment} requestPending={requestPending} />) |
|
217 |
} |
|
218 |
|
|
219 |
|
|
220 |
</VStack> |
|
221 |
</Box> |
|
207 | 222 |
); |
208 | 223 |
} |
209 | 224 |
|
Také k dispozici: Unified diff
FIX: colors fix
re #10896