Revize b225ffee
Přidáno uživatelem Fantič před téměř 2 roky(ů)
src/pages/NotesViewPage.tsx | ||
---|---|---|
2 | 2 |
import { log } from "../logging/logger" |
3 | 3 |
import { DrawerScreenProps } from "@react-navigation/drawer" |
4 | 4 |
import { RootDrawerParamList } from "../components/Navigation" |
5 |
import { Box, Button, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, FormControl, HStack, Heading, Input, MinusIcon, Popover, ScrollView, Switch, Text, VStack } from "native-base"
|
|
5 |
import { Box, Button, ChevronDownIcon, ChevronUpIcon, CloseIcon, Flex, HStack, Icon, IconButton, MinusIcon, Popover, Pressable, ScrollView, Switch, Text, TextArea, VStack } from "native-base"
|
|
6 | 6 |
import { SortOptions } from "../types/general" |
7 |
import { current } from "@reduxjs/toolkit" |
|
8 |
|
|
7 |
import { Note } from "../types/note" |
|
8 |
import NotesListView from "../components/notes/NotesListView" |
|
9 |
import { G, Path } from "react-native-svg" |
|
10 |
import { MessageIcon } from "../components/general/Icons" |
|
11 |
import { ConfirmDialog } from "../components/general/Dialogs" |
|
9 | 12 |
const NotesViewPage = ({ route, navigation }: DrawerScreenProps<RootDrawerParamList, 'Notes'>) => { |
10 | 13 |
|
11 | 14 |
const [isSortOpen, setIsSortOpen] = useState(false); |
... | ... | |
13 | 16 |
const [myCommentsCheck, setMyCommentsCheck] = useState(false); |
14 | 17 |
const [generalCommentsCheck, setGeneralCommentsCheck] = useState(true); |
15 | 18 |
|
19 |
const [replyingTo, setReplyingTo] = useState<{ messageId: string; userName: string } | null>(null); |
|
20 |
|
|
21 |
const cancelRef = React.useRef(null) |
|
22 |
|
|
23 |
const notes = [ |
|
24 |
{ |
|
25 |
uuid: "fadfsfdsaf", |
|
26 |
username: "Alice", |
|
27 |
userId: "123", |
|
28 |
note: "Buy milk and bread", |
|
29 |
avatarUrl: "martin.png", |
|
30 |
items: [], |
|
31 |
createdTime: new Date("2022-01-01T10:00:00Z"), |
|
32 |
updatedTime: new Date("2022-01-01T12:00:00Z"), |
|
33 |
noteColor: "#FFA500", |
|
34 |
}, |
|
35 |
{ |
|
36 |
uuid: "fadfsfdsaf", |
|
37 |
username: "Bob", |
|
38 |
userId: "456", |
|
39 |
note: "Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM ,Call Jane at 2 PM", |
|
40 |
avatarUrl: "https://example.com/avatar2.jpg", |
|
41 |
items: ["Jane"], |
|
42 |
createdTime: new Date("2022-01-02T10:00:00Z"), |
|
43 |
updatedTime: new Date("2022-01-02T14:00:00Z"), |
|
44 |
noteColor: "#6495ED", |
|
45 |
}, |
|
46 |
{ |
|
47 |
uuid: "fadfsfdsaf", |
|
48 |
username: "Charlie", |
|
49 |
userId: "789", |
|
50 |
note: "Pick up dry cleaning", |
|
51 |
avatarUrl: "https://example.com/avatar3.jpg", |
|
52 |
items: ["dry cleaning"], |
|
53 |
createdTime: new Date("2022-01-03T10:00:00Z"), |
|
54 |
updatedTime: new Date("2022-01-03T12:30:00Z"), |
|
55 |
noteColor: "#FFA07A", |
|
56 |
}, |
|
57 |
{ |
|
58 |
uuid: "fadfsfdsaf", |
|
59 |
username: "Dave", |
|
60 |
userId: "012", |
|
61 |
note: "Finish report by Friday", |
|
62 |
avatarUrl: "https://example.com/avatar4.jpg", |
|
63 |
items: ["report"], |
|
64 |
createdTime: new Date("2022-01-04T10:00:00Z"), |
|
65 |
updatedTime: new Date("2022-01-04T16:00:00Z"), |
|
66 |
noteColor: "#7B68EE", |
|
67 |
}, |
|
68 |
{ |
|
69 |
uuid: "fadfsfdsaf", |
|
70 |
username: "Eve", |
|
71 |
userId: "345", |
|
72 |
note: "Buy flowers for mom's birthday", |
|
73 |
avatarUrl: "https://example.com/avatar5.jpg", |
|
74 |
items: ["flowers"], |
|
75 |
createdTime: new Date("2022-01-05T10:00:00Z"), |
|
76 |
updatedTime: new Date("2022-01-05T18:00:00Z"), |
|
77 |
noteColor: "#F08080", |
|
78 |
}, |
|
79 |
{ |
|
80 |
uuid: "fadfsfdsaf", |
|
81 |
username: "Frank", |
|
82 |
userId: "678", |
|
83 |
note: "Schedule dentist appointment", |
|
84 |
avatarUrl: "https://example.com/avatar6.jpg", |
|
85 |
items: ["dentist appointment"], |
|
86 |
createdTime: new Date("2022-01-06T10:00:00Z"), |
|
87 |
updatedTime: new Date("2022-01-06T11:00:00Z"), |
|
88 |
noteColor: "#98FB98", |
|
89 |
}, |
|
90 |
{ |
|
91 |
uuid: "fadfsfdsaf", |
|
92 |
username: "Grace", |
|
93 |
userId: "901", |
|
94 |
note: "Book hotel for vacation", |
|
95 |
avatarUrl: "https://example.com/avatar7.jpg", |
|
96 |
items: ["hotel"], |
|
97 |
createdTime: new Date("2022-01-07T10:00:00Z"), |
|
98 |
updatedTime: new Date("2022-01-07T15:00:00Z"), |
|
99 |
noteColor: "#87CEFA", |
|
100 |
}, |
|
101 |
{ |
|
102 |
uuid: "fadfsfdsaf", |
|
103 |
username: "Alice", |
|
104 |
userId: "123", |
|
105 |
note: "Buy milk and bread", |
|
106 |
avatarUrl: "https://example.com/avatar1.jpg", |
|
107 |
items: ["milk", "bread"], |
|
108 |
createdTime: new Date("2022-01-01T10:00:00Z"), |
|
109 |
updatedTime: new Date("2022-01-01T12:00:00Z"), |
|
110 |
noteColor: "#FFA500", |
|
111 |
}, |
|
112 |
{ |
|
113 |
uuid: "fadfsfdsaf", |
|
114 |
username: "Bob", |
|
115 |
userId: "456", |
|
116 |
note: "Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM, Call Jane at 2 PM ,Call Jane at 2 PM", |
|
117 |
avatarUrl: "https://example.com/avatar2.jpg", |
|
118 |
items: ["Jane"], |
|
119 |
createdTime: new Date("2022-01-02T10:00:00Z"), |
|
120 |
updatedTime: new Date("2022-01-02T14:00:00Z"), |
|
121 |
noteColor: "#6495ED", |
|
122 |
}, |
|
123 |
{ |
|
124 |
uuid: "fadfsfdsaf", |
|
125 |
username: "Charlie", |
|
126 |
userId: "789", |
|
127 |
note: "Pick up dry cleaning", |
|
128 |
avatarUrl: "https://example.com/avatar3.jpg", |
|
129 |
items: ["dry cleaning"], |
|
130 |
createdTime: new Date("2022-01-03T10:00:00Z"), |
|
131 |
updatedTime: new Date("2022-01-03T12:30:00Z"), |
|
132 |
noteColor: "#FFA07A", |
|
133 |
}, |
|
134 |
{ |
|
135 |
uuid: "fadfsfdsaf", |
|
136 |
username: "Dave", |
|
137 |
userId: "012", |
|
138 |
note: "Finish report by Friday", |
|
139 |
avatarUrl: "https://example.com/avatar4.jpg", |
|
140 |
items: ["report"], |
|
141 |
createdTime: new Date("2022-01-04T10:00:00Z"), |
|
142 |
updatedTime: new Date("2022-01-04T16:00:00Z"), |
|
143 |
noteColor: "#7B68EE", |
|
144 |
}, |
|
145 |
{ |
|
146 |
uuid: "fadfsfdsaf", |
|
147 |
username: "Eve", |
|
148 |
userId: "345", |
|
149 |
note: "Buy flowers for mom's birthday", |
|
150 |
avatarUrl: "https://example.com/avatar5.jpg", |
|
151 |
items: ["flowers"], |
|
152 |
createdTime: new Date("2022-01-05T10:00:00Z"), |
|
153 |
updatedTime: new Date("2022-01-05T18:00:00Z"), |
|
154 |
noteColor: "#F08080", |
|
155 |
}]; |
|
156 |
|
|
157 |
const [confirmDialog, setConfirmDialog] = React.useState<{ |
|
158 |
headerText?: string; |
|
159 |
bodyText?: string; |
|
160 |
confirmText?: string; |
|
161 |
confirmColor?: string; |
|
162 |
cancelRef?: any; |
|
163 |
onClose?: () => void; |
|
164 |
onSubmit?: () => void; |
|
165 |
} | null>(null); |
|
16 | 166 |
|
17 | 167 |
const [sortSettings, setSortSettings] = useState({ |
18 | 168 |
items: SortOptions.None, |
... | ... | |
56 | 206 |
console.log("Get NOTES"); |
57 | 207 |
} |
58 | 208 |
|
59 |
return ( |
|
60 |
<ScrollView flex="1"> |
|
61 |
<Box width="90%" marginLeft="5%"> |
|
62 |
<VStack> |
|
63 |
<HStack marginTop="5%"> |
|
209 |
const handleReply = (messageId: string, userName: string) => { |
|
210 |
console.log("Handling reply: " + messageId); |
|
211 |
setReplyingTo({ messageId, userName }) |
|
212 |
} |
|
64 | 213 |
|
65 |
<Box width="30%"> |
|
66 |
<Popover // @ts-ignore |
|
67 |
trigger={triggerProps => { |
|
68 |
return <Button colorScheme="primary" {...triggerProps} onPress={() => setIsSortOpen(true)}> |
|
69 |
Sort Options |
|
70 |
</Button>; |
|
71 |
}} isOpen={isSortOpen} onClose={() => setIsSortOpen(!isSortOpen)}> |
|
72 |
<Popover.Content w="48"> |
|
73 |
<Popover.Arrow /> |
|
74 |
<Popover.CloseButton onPress={() => setIsSortOpen(false)} /> |
|
75 |
<Popover.Header>Sort Options</Popover.Header> |
|
76 |
<Popover.Body> |
|
77 |
<VStack> |
|
78 |
<Button size="md" variant="outline" onPress={() => handleSortChanged("items")} |
|
79 |
rightIcon={getSortIcon(sortSettings.items, "sm")} |
|
80 |
> |
|
81 |
Items</Button> |
|
82 |
<Button size="md" variant="outline" marginTop={"5%"} onPress={() => handleSortChanged("date")} |
|
83 |
rightIcon={getSortIcon(sortSettings.date, "sm")}> |
|
84 |
Date</Button> |
|
85 |
</VStack> |
|
86 |
</Popover.Body> |
|
87 |
<Popover.Footer justifyContent="flex-end"> |
|
88 |
<Button.Group space={2}> |
|
89 |
<Button colorScheme="coolGray" variant="ghost" onPress={() => setIsSortOpen(false)}> |
|
90 |
Cancel |
|
91 |
</Button> |
|
92 |
<Button colorScheme="success" onPress={() => { setIsSortOpen(false); getNotes() }}> |
|
93 |
Save |
|
94 |
</Button> |
|
95 |
</Button.Group> |
|
96 |
</Popover.Footer> |
|
97 |
</Popover.Content> |
|
98 |
</Popover> |
|
99 |
</Box> |
|
100 |
<VStack width="20%"> |
|
101 |
<HStack > |
|
102 |
<Text>My comments</Text> |
|
103 |
<Switch isChecked={myCommentsCheck} onValueChange={setMyCommentsCheck} size="md" /> |
|
104 |
</HStack> |
|
105 |
<HStack > |
|
106 |
<Text>General comments</Text> |
|
107 |
<Switch isChecked={generalCommentsCheck} onValueChange={setGeneralCommentsCheck} size="md" /> |
|
108 |
</HStack> |
|
109 |
</VStack> |
|
110 |
</HStack> |
|
214 |
const handleEdit = (messageId: string, newMessage: string) => { |
|
215 |
console.log("Handling edit:" + messageId + ", " + newMessage); |
|
216 |
} |
|
111 | 217 |
|
112 |
</VStack>
|
|
113 |
</Box>
|
|
114 |
</ScrollView>
|
|
218 |
const handleDelete = (messageId: string) => {
|
|
219 |
console.log("Handling delete:" + messageId);
|
|
220 |
}
|
|
115 | 221 |
|
222 |
return ( |
|
223 |
<Box width="90%" marginLeft="5%"> |
|
224 |
<VStack> |
|
225 |
<HStack marginTop="5%"> |
|
226 |
<Box width="30%" justifyContent={"center"}> |
|
227 |
<Popover // @ts-ignore |
|
228 |
trigger={triggerProps => { |
|
229 |
return <Button colorScheme="primary" {...triggerProps} onPress={() => setIsSortOpen(true)}> |
|
230 |
Sort Options |
|
231 |
</Button>; |
|
232 |
}} isOpen={isSortOpen} onClose={() => setIsSortOpen(!isSortOpen)}> |
|
233 |
<Popover.Content w="48"> |
|
234 |
<Popover.Arrow /> |
|
235 |
<Popover.CloseButton onPress={() => setIsSortOpen(false)} /> |
|
236 |
<Popover.Header>Sort Options</Popover.Header> |
|
237 |
<Popover.Body> |
|
238 |
<VStack> |
|
239 |
<Button size="md" variant="outline" onPress={() => handleSortChanged("items")} |
|
240 |
rightIcon={getSortIcon(sortSettings.items, "sm")} |
|
241 |
> |
|
242 |
Items</Button> |
|
243 |
<Button size="md" variant="outline" marginTop={"5%"} onPress={() => handleSortChanged("date")} |
|
244 |
rightIcon={getSortIcon(sortSettings.date, "sm")}> |
|
245 |
Date</Button> |
|
246 |
</VStack> |
|
247 |
</Popover.Body> |
|
248 |
<Popover.Footer justifyContent="flex-end"> |
|
249 |
<Button.Group space={2}> |
|
250 |
<Button colorScheme="coolGray" variant="ghost" onPress={() => setIsSortOpen(false)}> |
|
251 |
Cancel |
|
252 |
</Button> |
|
253 |
<Button colorScheme="success" onPress={() => { setIsSortOpen(false); getNotes() }}> |
|
254 |
Save |
|
255 |
</Button> |
|
256 |
</Button.Group> |
|
257 |
</Popover.Footer> |
|
258 |
</Popover.Content> |
|
259 |
</Popover> |
|
260 |
</Box> |
|
261 |
<VStack width="70%" space="0"> |
|
262 |
<Flex direction="row" alignItems="center" justify="flex-end"> |
|
263 |
<Text>My comments</Text> |
|
264 |
<Switch isChecked={myCommentsCheck} onValueChange={() => setMyCommentsCheck(!myCommentsCheck)} size="md" /> |
|
265 |
</Flex> |
|
266 |
<Flex direction="row" alignItems="center" justify="flex-end" marginTop="-7.5%"> |
|
267 |
<Text>General comments</Text> |
|
268 |
<Switch isChecked={generalCommentsCheck} onValueChange={() => setGeneralCommentsCheck(!generalCommentsCheck)} size="md" /> |
|
269 |
</Flex> |
|
270 |
</VStack> |
|
271 |
</HStack> |
|
272 |
<Box h={replyingTo != null ? "62.5%" : "67.5%"}> |
|
273 |
<NotesListView notes={notes} handleReply={handleReply} handleDelete={handleDelete} handleEdit={handleEdit} setConfirmDialog={setConfirmDialog} /> |
|
274 |
</Box> |
|
275 |
{replyingTo != null && |
|
276 |
<Flex direction="row" alignItems="center" justify="flex-end" h="5%" marginRight="10%"> |
|
277 |
<Text>Replying to {replyingTo.userName}</Text> |
|
278 |
<IconButton onPress={() => setReplyingTo(null)} size="sm" icon={<CloseIcon />} marginLeft="-1%"> |
|
279 |
</IconButton> |
|
280 |
</Flex> |
|
281 |
} |
|
282 |
<HStack h={replyingTo != null ? "20%" : "15%"} marginTop={replyingTo != null ? "0%" : "5%"}> |
|
283 |
<TextArea placeholder="Add comment" width="90%" autoCompleteType={undefined} ></TextArea> |
|
284 |
<VStack> |
|
285 |
<Box h={replyingTo != null ? "30%" : "45%"}></Box> |
|
286 |
<Box marginLeft="2"> |
|
287 |
<Button startIcon={<MessageIcon color="#FFF" />}></Button> |
|
288 |
</Box> |
|
289 |
</VStack> |
|
290 |
</HStack> |
|
291 |
</VStack> |
|
292 |
<ConfirmDialog {...confirmDialog} isShown={confirmDialog != null} cancelRef={cancelRef} /> |
|
293 |
</Box> |
|
116 | 294 |
); |
117 | 295 |
} |
118 | 296 |
|
Také k dispozici: Unified diff
re #10569: NotesView: interface implementation