2020-11-29 13:11:23 +01:00
|
|
|
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 = () => {
|
2020-11-29 13:11:23 +01:00
|
|
|
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}
|
2020-11-29 13:11:23 +01:00
|
|
|
iconFront='list'
|
2020-11-22 00:46:23 +01:00
|
|
|
title={d.title}
|
2020-11-29 13:11:23 +01:00
|
|
|
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
|