tooot/src/screens/Tabs/Me/Settings/Dev.tsx

80 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-01-27 00:35:34 +01:00
import Button from '@components/Button'
import { MenuContainer, MenuRow } from '@components/Menu'
import { useActionSheet } from '@expo/react-native-action-sheet'
import { persistor } from '@root/store'
2021-02-20 19:12:44 +01:00
import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice'
2021-01-27 00:35:34 +01:00
import { StyleConstants } from '@utils/styles/constants'
2021-02-27 16:33:54 +01:00
import { useTheme } from '@utils/styles/ThemeManager'
2021-01-27 00:35:34 +01:00
import React from 'react'
2021-02-27 16:33:54 +01:00
import { Text } from 'react-native'
2021-01-27 00:35:34 +01:00
import { useSelector } from 'react-redux'
const SettingsDev: React.FC = () => {
2021-02-27 16:33:54 +01:00
const { theme } = useTheme()
2021-01-27 00:35:34 +01:00
const { showActionSheetWithOptions } = useActionSheet()
2021-02-20 19:12:44 +01:00
const instanceActive = useSelector(getInstanceActive)
2021-02-27 16:33:54 +01:00
const instances = useSelector(getInstances, () => true)
2021-01-27 00:35:34 +01:00
return (
<MenuContainer>
2021-02-27 16:33:54 +01:00
<Text
selectable
style={{
paddingHorizontal: StyleConstants.Spacing.Global.PagePadding,
...StyleConstants.FontStyle.S,
color: theme.primaryDefault
2021-02-27 16:33:54 +01:00
}}
>
2021-03-02 01:17:06 +01:00
{instances[instanceActive]?.token}
2021-02-27 16:33:54 +01:00
</Text>
2021-01-27 00:35:34 +01:00
<MenuRow
title={'Local active index'}
2021-02-20 19:12:44 +01:00
content={typeof instanceActive + ' - ' + instanceActive}
2021-01-27 00:35:34 +01:00
onPress={() => {}}
/>
<MenuRow
title={'Saved local instances'}
2021-02-20 19:12:44 +01:00
content={instances.length.toString()}
2021-01-27 00:35:34 +01:00
iconBack='ChevronRight'
onPress={() =>
showActionSheetWithOptions(
{
2021-02-20 19:12:44 +01:00
options: instances
2021-01-27 00:35:34 +01:00
.map(instance => {
return instance.url + ': ' + instance.account.id
})
.concat(['Cancel']),
2021-02-20 19:12:44 +01:00
cancelButtonIndex: instances.length
2021-01-27 00:35:34 +01:00
},
2021-03-10 10:22:53 +01:00
() => {}
2021-01-27 00:35:34 +01:00
)
}
/>
<Button
type='text'
content={'Purge secure storage'}
style={{
marginHorizontal: StyleConstants.Spacing.Global.PagePadding * 2,
marginBottom: StyleConstants.Spacing.Global.PagePadding * 2
}}
destructive
onPress={() => persistor.purge()}
/>
<Button
type='text'
content={'Crash test'}
style={{
marginHorizontal: StyleConstants.Spacing.Global.PagePadding * 2,
marginBottom: StyleConstants.Spacing.Global.PagePadding * 2
}}
destructive
onPress={() => {
throw new Error('Testing crash')
}}
/>
</MenuContainer>
)
}
export default SettingsDev