[UI > AddonPage] Move back to FlatList

This commit is contained in:
Beef 2023-05-13 00:15:11 +01:00
parent 0dae5b17e5
commit 63fd59e826

View file

@ -18,20 +18,24 @@ export default function AddonPage<T>({ items, safeModeMessage, safeModeExtras, c
return ( return (
<ErrorBoundary> <ErrorBoundary>
<RN.ScrollView style={{ flex: 1 }} contentContainerStyle={{ padding: 10 }}> {/* TODO: Implement better searching than just by ID */}
{settings.safeMode?.enabled && <RN.View style={{ marginBottom: 10 }}> <RN.FlatList
<HelpMessage messageType={0}>{safeModeMessage}</HelpMessage> ListHeaderComponent={<>
{safeModeExtras} {settings.safeMode?.enabled && <RN.View style={{ marginBottom: 10 }}>
</RN.View>} <HelpMessage messageType={0}>{safeModeMessage}</HelpMessage>
<Search {safeModeExtras}
style={{ marginBottom: 10 }} </RN.View>}
onChangeText={(v: string) => setSearch(v.toLowerCase())} <Search
placeholder="Search" style={{ marginBottom: 10 }}
/> onChangeText={(v: string) => setSearch(v.toLowerCase())}
{/* TODO: When I am more awake, implement better searching than just by ID */} placeholder="Search"
{/* TODO: Also when I am more awake, make the search bar not scroll with the cards */} />
{Object.values(items).filter(i => i.id?.toLowerCase().includes(search)).map((i, id) => <CardComponent item={i} index={id} />)} </>}
</RN.ScrollView> style={{ paddingHorizontal: 10, paddingTop: 10 }}
contentContainerStyle={{ paddingBottom: 20 }}
data={Object.values(items).filter(i => i.id?.toLowerCase().includes(search))}
renderItem={({ item, index }) => <CardComponent item={item} index={index} />}
/>
</ErrorBoundary> </ErrorBoundary>
) )
} }