Revize 9814562f
Přidáno uživatelem Fantič před více než 1 rok
src/components/item/ItemView.tsx | ||
---|---|---|
251 | 251 |
props.notesLoading ? |
252 | 252 |
(<LoadingBox text="Notes loading..." />) |
253 | 253 |
: |
254 |
(<VStack paddingLeft={2.5} paddingRight={2.5}>
|
|
255 |
<Flex direction="row" align="flex-start" justifyContent="space-between" marginTop={2.5}> |
|
254 |
(<VStack> |
|
255 |
<Flex direction="row" align="flex-start" justifyContent="space-between" marginTop={2.5} marginLeft={2.5} marginRight={2.5}>
|
|
256 | 256 |
<Text fontWeight="semibold" mt={4} ml={2} fontSize="md" color="4D4D4D">Show related comments</Text> |
257 | 257 |
<Switch value={showRelatedComments} onChange={toggleRelatedComments} size="lg" marginRight={2} /> |
258 | 258 |
</Flex> |
src/components/notes/NoteView.tsx | ||
---|---|---|
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
return ( |
86 |
<HStack style={props.higlighted && {backgroundColor: "#FFF8E1",borderBottomColor: '#FFD54F', borderBottomWidth: 1.5, paddingBottom: 10}} marginTop={5}>
|
|
86 |
<HStack style={props.higlighted && { backgroundColor: "#FFF8E1", borderBottomColor: '#FFD54F', borderBottomWidth: 1.5, paddingBottom: 10 }} marginTop={5}>
|
|
87 | 87 |
<Box width="10" height="10" marginTop="2"> |
88 | 88 |
<Avatar bg={note.noteColor} size="sm" source={{ |
89 | 89 |
uri: AVATAR_URL + "/" + note.avatarUrl |
... | ... | |
119 | 119 |
|
120 | 120 |
{note.items && note.items.length > 0 && |
121 | 121 |
<Flex marginLeft={1} flex={0}> |
122 |
<Button p={1} variant="outline" size="sm" onPress={() => props.navigation.navigate("Item", { itemId: note.items[0] })}> |
|
123 |
{note.items[0]} |
|
122 |
<Button p={1} variant="solid" backgroundColor="#F4DFAB" borderRadius={8} size="sm" onPress={() => props.navigation.navigate("Item", { itemId: note.items[0] })}> |
|
123 |
<Text color="#654B07" fontSize={12}> |
|
124 |
{note.items[0]} |
|
125 |
</Text> |
|
124 | 126 |
</Button> |
125 | 127 |
</Flex> |
126 | 128 |
|
... | ... | |
168 | 170 |
</Flex> |
169 | 171 |
</HStack> |
170 | 172 |
{showReplies && |
171 |
<VStack style={{borderLeftColor: '#FFC107', borderLeftWidth: 1, paddingLeft: 5, marginTop: 5}}>
|
|
173 |
<VStack style={{ borderLeftColor: '#FFC107', borderLeftWidth: 1, paddingLeft: 5, marginTop: 5 }}>
|
|
172 | 174 |
{note.replies?.map((note, index) => { |
173 | 175 |
return ( |
174 | 176 |
<NoteView key={index} note={note} handleReply={null} handleDelete={props.handleDelete} handleEdit={props.handleEdit} setConfirmDialog={props.setConfirmDialog} navigation={props.navigation} /> |
src/components/notes/NotesListView.tsx | ||
---|---|---|
92 | 92 |
}; |
93 | 93 |
|
94 | 94 |
return ( |
95 |
<VStack> |
|
95 |
<VStack >
|
|
96 | 96 |
<Box height={props.height - (replyingTo ? 40 : 0) ?? undefined} marginBottom={2}> |
97 | 97 |
{/* Notes */} |
98 |
<ScrollView contentContainerStyle={{ flexGrow: 1 }} onScrollEndDrag={handleScrollEnd}> |
|
98 |
<ScrollView contentContainerStyle={{ flexGrow: 1 }} onScrollEndDrag={handleScrollEnd} paddingLeft={2.5} paddingRight={2.5}>
|
|
99 | 99 |
{ |
100 | 100 |
notes && notes.length > 0 ? ( |
101 | 101 |
<VStack> |
src/pages/ItemViewPage.tsx | ||
---|---|---|
97 | 97 |
|
98 | 98 |
|
99 | 99 |
const handleIndexChanged = useCallback((newIndex: number, swipe?: boolean) => { |
100 |
if(swipe && item){ |
|
101 |
log.debug("swipe change") |
|
102 |
console.log(newIndex) |
|
103 |
console.log(index) |
|
104 |
if(newIndex > fakeIndex){ |
|
105 |
// next items |
|
106 |
if(item.nextItem){ |
|
107 |
navigation.navigate("Item", { itemId: item.nextItem.toString() }) |
|
108 |
} |
|
109 |
else{ |
|
110 |
log.debug("no next item") |
|
111 |
} |
|
112 |
} |
|
113 |
else if(newIndex < fakeIndex){ |
|
114 |
// previous items |
|
115 |
if(item.prevItem){ |
|
116 |
navigation.navigate("Item", { itemId: item.prevItem.toString() }) |
|
117 |
} |
|
118 |
else{ |
|
119 |
log.debug("no prev item") |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
else if (newIndex >= 0 && newIndex < concordances.length && index != newIndex) { |
|
100 |
// if(swipe && item){ |
|
101 |
// log.debug("swipe change") |
|
102 |
// console.log(newIndex) |
|
103 |
// console.log(index) |
|
104 |
// if(newIndex > index){ |
|
105 |
// // next items |
|
106 |
// if(item.nextItem){ |
|
107 |
// navigation.navigate("Item", { itemId: item.nextItem.toString() }) |
|
108 |
// } |
|
109 |
// else{ |
|
110 |
// log.debug("no next item") |
|
111 |
// } |
|
112 |
// } |
|
113 |
// else if(newIndex < index){ |
|
114 |
// // previous items |
|
115 |
// if(item.prevItem){ |
|
116 |
// navigation.navigate("Item", { itemId: item.prevItem.toString() }) |
|
117 |
// } |
|
118 |
// else{ |
|
119 |
// log.debug("no prev item") |
|
120 |
// } |
|
121 |
// } |
|
122 |
// } |
|
123 |
// else |
|
124 |
if (newIndex >= 0 && newIndex < concordances.length && index != newIndex) { |
|
124 | 125 |
console.log("index changed"); |
125 | 126 |
setIndex(newIndex); |
126 | 127 |
if (concordances && concordances.length > 0) { |
src/pages/NotesViewPage.tsx | ||
---|---|---|
30 | 30 |
const toast = useToast(); |
31 | 31 |
|
32 | 32 |
useEffect(() => { |
33 |
if (lastError) {
|
|
34 |
toast.closeAll()
|
|
35 |
toast.show({
|
|
36 |
render: ({
|
|
37 |
id
|
|
38 |
}) => {
|
|
39 |
return <ErrorToast headerText={"Error"} text={lastError} onClose={() => toast.close(id)} />;
|
|
40 |
},
|
|
41 |
duration: 3000
|
|
42 |
});
|
|
43 |
}
|
|
33 |
if (lastError) { |
|
34 |
toast.closeAll() |
|
35 |
toast.show({ |
|
36 |
render: ({ |
|
37 |
id |
|
38 |
}) => { |
|
39 |
return <ErrorToast headerText={"Error"} text={lastError} onClose={() => toast.close(id)} />; |
|
40 |
}, |
|
41 |
duration: 3000 |
|
42 |
}); |
|
43 |
} |
|
44 | 44 |
}, [lastError]) |
45 | 45 |
|
46 | 46 |
const [sortSettings, setSortSettings] = useState({ |
... | ... | |
48 | 48 |
date: SortOptions.None |
49 | 49 |
}); |
50 | 50 |
|
51 |
console.log(sortSettings) |
|
52 |
|
|
51 | 53 |
const handleSortChanged = useCallback((key: "items" | "date", sortSettings: any) => { |
52 | 54 |
let currentState = sortSettings[key]; |
55 |
let otherKey = "items" |
|
56 |
|
|
57 |
if (key == "items") { |
|
58 |
otherKey = "date" |
|
59 |
} |
|
60 |
|
|
53 | 61 |
if (currentState == SortOptions.None) { |
54 | 62 |
setSortSettings({ |
55 | 63 |
...sortSettings, |
56 |
[key]: SortOptions.Asc |
|
64 |
[key]: SortOptions.Asc, |
|
65 |
[otherKey]: SortOptions.None |
|
57 | 66 |
}) |
58 | 67 |
} |
59 | 68 |
else if (currentState == SortOptions.Asc) { |
60 | 69 |
setSortSettings({ |
61 | 70 |
...sortSettings, |
62 |
[key]: SortOptions.Desc |
|
71 |
[key]: SortOptions.Desc, |
|
72 |
[otherKey]: SortOptions.None |
|
63 | 73 |
}) |
64 | 74 |
} |
65 | 75 |
else { |
66 | 76 |
setSortSettings({ |
67 | 77 |
...sortSettings, |
68 |
[key]: SortOptions.None |
|
78 |
[key]: SortOptions.None, |
|
79 |
[otherKey]: SortOptions.None |
|
69 | 80 |
}) |
70 | 81 |
} |
71 | 82 |
}, [setSortSettings]); |
72 | 83 |
|
73 |
const getSortIcon = (sortOption: SortOptions, size: string) => { |
|
84 |
const getSortIcon = (sortOption: SortOptions, size: string, color?: string) => {
|
|
74 | 85 |
switch (sortOption) { |
75 | 86 |
case SortOptions.Asc: |
76 |
return <ChevronUpIcon size={size} />; |
|
87 |
return <ChevronUpIcon size={size} color={color} />;
|
|
77 | 88 |
case SortOptions.Desc: |
78 |
return <ChevronDownIcon size={size} />; |
|
89 |
return <ChevronDownIcon size={size} color={color} />;
|
|
79 | 90 |
default: |
80 |
return <MinusIcon size={size} />; |
|
91 |
return <MinusIcon size={size} color={color} />;
|
|
81 | 92 |
} |
82 | 93 |
}; |
83 | 94 |
|
... | ... | |
112 | 123 |
// creating new comment |
113 | 124 |
toast.show({ |
114 | 125 |
render: ({ |
115 |
id
|
|
126 |
id |
|
116 | 127 |
}) => { |
117 |
return <InfoToast text={"Adding note"} onClose={() => toast.close(id)} />;
|
|
128 |
return <InfoToast text={"Adding note"} onClose={() => toast.close(id)} />;
|
|
118 | 129 |
}, |
119 | 130 |
duration: 2000 |
120 |
}); |
|
131 |
});
|
|
121 | 132 |
if (replyingTo != null) { |
122 | 133 |
dispatch(createNote({ |
123 | 134 |
newNote: { note: newComment, reply_to: replyingTo.messageId } as Note |
... | ... | |
134 | 145 |
|
135 | 146 |
|
136 | 147 |
return ( |
137 |
<Box marginLeft={2.5} marginRight={2.5} marginTop={2.5}>
|
|
148 |
<Box> |
|
138 | 149 |
<VStack> |
139 |
<HStack height={75} justifyContent="space-between"> |
|
150 |
<HStack height={75} justifyContent="space-between" paddingLeft={2.5} paddingRight={2.5} marginTop={2.5}>
|
|
140 | 151 |
<Box justifyContent={"center"}> |
141 | 152 |
<Popover // @ts-ignore |
142 | 153 |
trigger={triggerProps => { |
143 |
return <Button colorScheme="primary" {...triggerProps} onPress={() => setIsSortOpen(true)}> |
|
144 |
Sort Options |
|
154 |
return <Button width={150} backgroundColor="#F4DFAB" {...triggerProps} onPress={() => setIsSortOpen(true)} |
|
155 |
borderRadius={7} |
|
156 |
rightIcon={(sortSettings.date != SortOptions.None || sortSettings.items != SortOptions.None) ? (getSortIcon(sortSettings.date != SortOptions.None ? sortSettings.date : sortSettings.items, "xs", "#654B07")) : undefined} |
|
157 |
> |
|
158 |
<Text fontSize={14} color="#654B07"> |
|
159 |
Sort {(sortSettings.date != SortOptions.None || sortSettings.items != SortOptions.None) ? (sortSettings.date != SortOptions.None ? "by date" : "by items") : ""} |
|
160 |
</Text> |
|
145 | 161 |
</Button>; |
146 | 162 |
}} isOpen={isSortOpen} onClose={() => setIsSortOpen(!isSortOpen)}> |
147 | 163 |
<Popover.Content w="48"> |
148 | 164 |
<Popover.Arrow /> |
149 | 165 |
<Popover.CloseButton onPress={() => setIsSortOpen(false)} /> |
150 |
<Popover.Header>Sort Options</Popover.Header>
|
|
166 |
<Popover.Header><Text fontSize={"md"} color="#654B07">Sort Options</Text></Popover.Header>
|
|
151 | 167 |
<Popover.Body> |
152 | 168 |
<VStack> |
153 | 169 |
<Button size="md" variant="outline" onPress={() => handleSortChanged("items", sortSettings)} |
154 |
rightIcon={getSortIcon(sortSettings.items, "sm")} |
|
170 |
rightIcon={getSortIcon(sortSettings.items, "sm", "#654B07")}
|
|
155 | 171 |
> |
156 | 172 |
Items</Button> |
157 | 173 |
<Button size="md" variant="outline" marginTop={"5%"} onPress={() => handleSortChanged("date", sortSettings)} |
158 |
rightIcon={getSortIcon(sortSettings.date, "sm")}> |
|
174 |
rightIcon={getSortIcon(sortSettings.date, "sm", "#654B07")}>
|
|
159 | 175 |
Date</Button> |
160 | 176 |
</VStack> |
161 | 177 |
</Popover.Body> |
... | ... | |
164 | 180 |
<Button colorScheme="coolGray" variant="ghost" onPress={() => setIsSortOpen(false)}> |
165 | 181 |
Cancel |
166 | 182 |
</Button> |
167 |
<Button colorScheme="success" onPress={() => { setIsSortOpen(false); getNotes() }}> |
|
168 |
Save |
|
183 |
<Button backgroundColor={"#F4DFAB"} onPress={() => { setIsSortOpen(false); getNotes() }}> |
|
184 |
<Text color="#654B07"> |
|
185 |
Save |
|
186 |
</Text> |
|
169 | 187 |
</Button> |
170 | 188 |
</Button.Group> |
171 | 189 |
</Popover.Footer> |
Také k dispozici: Unified diff
re #10895: NoteViewPage: Sort refactor