Revize cb25df10
Přidáno uživatelem Fantič před téměř 2 roky(ů)
src/components/item/ItemTabBar.tsx | ||
---|---|---|
51 | 51 |
color={CertaintyWithColors[concordances[i].cert].color} |
52 | 52 |
/> |
53 | 53 |
} |
54 |
onPress={() => { if (index != i) { onIndexChange(i) } }}
|
|
54 |
onPress={() => {onIndexChange(i) }}
|
|
55 | 55 |
> |
56 | 56 |
{concordances[i].id} |
57 | 57 |
</Button> |
src/components/item/ItemView.tsx | ||
---|---|---|
3 | 3 |
import { Item } from "../../types/item" |
4 | 4 |
import { Note } from "../../types/note" |
5 | 5 |
import LoadingBox from "../loading/LoadingBox" |
6 |
import NotesListView from "../notes/NotesListView" |
|
6 | 7 |
|
7 | 8 |
interface ItemDetailProps { |
8 | 9 |
item: Item, |
... | ... | |
37 | 38 |
); |
38 | 39 |
} |
39 | 40 |
|
40 |
const ItemNotes = (props: { notes: Note[] }) => { |
|
41 |
const notes = props.notes; |
|
42 |
return ( |
|
43 |
<Center> |
|
44 |
{ |
|
45 |
notes && notes.length > 0 ? ( |
|
46 |
<VStack> |
|
47 |
{notes.map((note, index) => ( |
|
48 |
<Box key={index}> |
|
49 |
<Text>{note.username}</Text> |
|
50 |
<Text>{note.note}</Text> |
|
51 |
</Box> |
|
52 |
))} |
|
53 |
</VStack> |
|
54 |
) : ( |
|
55 |
<Text>There are no notes for selected item.</Text> |
|
56 |
) |
|
57 |
} |
|
58 |
</Center> |
|
59 |
); |
|
60 |
} |
|
61 | 41 |
|
62 | 42 |
|
63 | 43 |
const ItemView = (props: ItemDetailProps) => { |
... | ... | |
86 | 66 |
notesLoading ? |
87 | 67 |
<LoadingBox text="Notes loading"/> |
88 | 68 |
: |
89 |
<ItemNotes notes={props.notes} />
|
|
69 |
<NotesListView notes={props.notes} />
|
|
90 | 70 |
)} |
91 | 71 |
|
92 | 72 |
{/* item notes switch tab */} |
src/components/notes/NoteView.tsx | ||
---|---|---|
1 |
import { HStack, Box, Text } from "native-base"; |
|
2 |
import { Note } from "../../types/note"; |
|
3 |
|
|
4 |
const NoteView = (props: { note: Note }) => { |
|
5 |
const note = props.note; |
|
6 |
return ( |
|
7 |
<HStack> |
|
8 |
<Box width="5%" /> |
|
9 |
<Box width="30%"> |
|
10 |
<Text bold>{note.username}</Text> |
|
11 |
</Box> |
|
12 |
|
|
13 |
<Text>{note.note}</Text> |
|
14 |
</HStack> |
|
15 |
); |
|
16 |
} |
|
17 |
|
|
18 |
export default NoteView |
|
19 |
|
src/components/notes/NotesListView.tsx | ||
---|---|---|
1 |
import { Center, VStack, Box, Text, HStack } from "native-base"; |
|
2 |
import { Note } from "../../types/note"; |
|
3 |
import NoteView from "./NoteView"; |
|
4 |
|
|
5 |
const NotesListView = (props: { notes: Note[] }) => { |
|
6 |
const notes = props.notes; |
|
7 |
return ( |
|
8 |
<VStack> |
|
9 |
{ |
|
10 |
notes && notes.length > 0 ? ( |
|
11 |
<VStack> |
|
12 |
{notes.map((note, index) => ( |
|
13 |
<NoteView key={index} note={note}/> |
|
14 |
))} |
|
15 |
</VStack> |
|
16 |
) : ( |
|
17 |
<Text>There are no notes.</Text> |
|
18 |
) |
|
19 |
} |
|
20 |
</VStack> |
|
21 |
); |
|
22 |
} |
|
23 |
|
|
24 |
export default NotesListView |
src/pages/ItemViewPage.tsx | ||
---|---|---|
76 | 76 |
} |
77 | 77 |
}, [item]); |
78 | 78 |
|
79 |
const handleIndexChanged = (index: number) => { |
|
80 |
if(index > 0 && index < concordances.length){ |
|
81 |
setIndex(index); |
|
79 |
const handleIndexChanged = (newIndex: number) => { |
|
80 |
if(newIndex >= 0 && newIndex < concordances.length && index != newIndex){ |
|
81 |
console.log("index changed"); |
|
82 |
setIndex(newIndex); |
|
82 | 83 |
if (concordances && concordances.length > 0) { |
83 |
dispatch(getItem(concordances[index].id));
|
|
84 |
dispatch(getItem(concordances[newIndex].id));
|
|
84 | 85 |
} |
85 | 86 |
} |
86 | 87 |
} |
Také k dispozici: Unified diff
re #10454: ItemView: NoteView class init