Revize f386a4fe
Přidáno uživatelem Fantič před více než 1 rok
src/components/notes/NotesListView.tsx | ||
---|---|---|
8 | 8 |
import { AppDispatch } from "../../stores/store"; |
9 | 9 |
import { useDispatch } from "react-redux"; |
10 | 10 |
import { Dimensions } from "react-native"; |
11 |
import { InfoToast } from "../toast/InfoToast"; |
|
11 | 12 |
|
12 | 13 |
|
13 | 14 |
|
14 | 15 |
const NotesListView = (props: { notes: Note[], navigation: any, handleCreateComment: any, requestPending: boolean }) => { |
15 | 16 |
const notes = props.notes; |
16 | 17 |
|
17 |
const toast = useToast(); |
|
18 |
|
|
19 | 18 |
const [newComment, setNewComment] = useState<string>(""); |
20 | 19 |
const [replyingTo, setReplyingTo] = useState<{ messageId: string; userName: string } | null>(null); |
21 | 20 |
|
21 |
const toast = useToast(); |
|
22 |
|
|
22 | 23 |
const [renderedNotes, setRenderedNotes] = useState(6); |
23 | 24 |
|
24 | 25 |
const cancelRef = React.useRef(null); |
... | ... | |
53 | 54 |
} |
54 | 55 |
}, [dispatch, props.requestPending]); |
55 | 56 |
|
57 |
|
|
58 |
|
|
56 | 59 |
const handleScrollEnd = (event: any) => { |
57 | 60 |
const offsetY = event.nativeEvent.contentOffset.y; |
58 | 61 |
const contentHeight = event.nativeEvent.contentSize.height; |
... | ... | |
63 | 66 |
const nextBatchSize = 5; // Number of notes to render in the next batch |
64 | 67 |
|
65 | 68 |
if ((renderedNotes + nextBatchSize) > notes.length && (renderedNotes + nextBatchSize) != notes.length) { |
69 |
toast.closeAll() |
|
70 |
toast.show({ |
|
71 |
render: ({ |
|
72 |
id |
|
73 |
}) => { |
|
74 |
return <InfoToast text={"All notes loaded..."} onClose={() => toast.close(id)} />; |
|
75 |
}, |
|
76 |
duration: 3000 |
|
77 |
}); |
|
66 | 78 |
setRenderedNotes(notes.length); |
67 |
// TODO toast display info all rendered |
|
79 |
|
|
68 | 80 |
} |
69 | 81 |
else if ((renderedNotes + nextBatchSize) != notes.length) { |
82 |
toast.closeAll() |
|
83 |
toast.show({ |
|
84 |
render: ({ |
|
85 |
id |
|
86 |
}) => { |
|
87 |
return <InfoToast text={"Loading more notes..."} onClose={() => toast.close(id)} />; |
|
88 |
}, |
|
89 |
duration: 3000 |
|
90 |
}); |
|
70 | 91 |
setRenderedNotes(renderedNotes + nextBatchSize); |
71 |
// TODO toast display loading more notes |
|
92 |
|
|
72 | 93 |
} |
73 | 94 |
} |
74 | 95 |
}; |
... | ... | |
83 | 104 |
<VStack> |
84 | 105 |
{ |
85 | 106 |
notes.slice(0, renderedNotes).map((note, index) => { |
86 |
|
|
87 |
if(replyingTo?.messageId == note.uuid){
|
|
107 |
|
|
108 |
if (replyingTo?.messageId == note.uuid) {
|
|
88 | 109 |
return <NoteView higlighted key={index} note={note} handleReply={handleReply} handleDelete={handleDelete} handleEdit={handleEdit} setConfirmDialog={setConfirmDialog} navigation={props.navigation} /> |
89 | 110 |
} |
90 |
|
|
111 |
|
|
91 | 112 |
return <NoteView key={index} note={note} handleReply={handleReply} handleDelete={handleDelete} handleEdit={handleEdit} setConfirmDialog={setConfirmDialog} navigation={props.navigation} />; |
92 |
|
|
113 |
|
|
93 | 114 |
}) |
94 | 115 |
} |
95 | 116 |
</VStack> |
... | ... | |
107 | 128 |
|
108 | 129 |
{/* Replying to */} |
109 | 130 |
{replyingTo != null && |
110 |
<Flex direction="row" alignItems="center" justify="flex-end" height={10} style={{backgroundColor: "#FFF8E1"}}>
|
|
131 |
<Flex direction="row" alignItems="center" justify="flex-end" height={10} style={{ backgroundColor: "#FFF8E1" }}>
|
|
111 | 132 |
<Text>Replying to {replyingTo.userName}</Text> |
112 |
<IconButton onPress={() => setReplyingTo(null)} size="sm" icon={<CloseIcon />} marginLeft="-1%" marginRight={20 }/>
|
|
133 |
<IconButton onPress={() => setReplyingTo(null)} size="sm" icon={<CloseIcon />} marginLeft="-1%" marginRight={20} />
|
|
113 | 134 |
</Flex> |
114 | 135 |
} |
115 | 136 |
|
Také k dispozici: Unified diff
re #10818 Toast: implementation to pages