tooot/src/screens/Me/Lists.tsx

42 lines
1.0 KiB
TypeScript
Raw Normal View History

import { useNavigation } from '@react-navigation/native'
2020-11-22 00:46:23 +01:00
import React from 'react'
import { ActivityIndicator, Text } from 'react-native'
import { useQuery } from 'react-query'
2020-12-13 14:04:25 +01:00
import { MenuContainer, MenuRow } from '@components/Menu'
2020-11-22 00:46:23 +01:00
2020-12-13 14:04:25 +01:00
import { listsFetch } from '@utils/fetches/listsFetch'
2020-11-22 00:46:23 +01:00
const ScreenMeLists: React.FC = () => {
const navigation = useNavigation()
2020-11-22 00:46:23 +01:00
const { status, data } = useQuery(['Lists'], listsFetch)
let lists
switch (status) {
case 'loading':
lists = <ActivityIndicator />
break
case 'error':
lists = <Text></Text>
break
case 'success':
2020-11-28 17:07:30 +01:00
lists = data?.map((d: Mastodon.List, i: number) => (
2020-12-03 01:28:56 +01:00
<MenuRow
2020-11-28 17:07:30 +01:00
key={i}
iconFront='list'
2020-11-22 00:46:23 +01:00
title={d.title}
onPress={() =>
navigation.navigate('Screen-Me-Lists-List', {
list: d.id,
title: d.title
})
}
2020-11-22 00:46:23 +01:00
/>
))
break
}
2020-11-28 17:07:30 +01:00
return <MenuContainer>{lists}</MenuContainer>
2020-11-22 00:46:23 +01:00
}
export default ScreenMeLists