2021-03-10 10:22:53 +01:00
|
|
|
import Button from '@components/Button'
|
|
|
|
import haptics from '@components/haptics'
|
|
|
|
import ComponentSeparator from '@components/Separator'
|
2022-05-07 00:52:32 +02:00
|
|
|
import CustomText from '@components/Text'
|
2021-03-10 10:22:53 +01:00
|
|
|
import TimelineDefault from '@components/Timeline/Default'
|
2021-08-29 15:25:38 +02:00
|
|
|
import { TabMeStackScreenProps } from '@utils/navigation/navigators'
|
2022-12-28 23:41:36 +01:00
|
|
|
import { useGlobalStorage } from '@utils/storage/actions'
|
|
|
|
import { StorageGlobal } from '@utils/storage/global'
|
2021-03-10 11:49:14 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import { adaptiveScale } from '@utils/styles/scaling'
|
2021-03-10 10:22:53 +01:00
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2022-12-28 23:41:36 +01:00
|
|
|
import React from 'react'
|
2021-03-10 10:22:53 +01:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2023-01-10 00:28:39 +01:00
|
|
|
import { View } from 'react-native'
|
2021-03-10 10:22:53 +01:00
|
|
|
import { ScrollView } from 'react-native-gesture-handler'
|
|
|
|
|
2022-12-28 23:41:36 +01:00
|
|
|
export const mapFontsizeToName = (size: StorageGlobal['app.font_size']) => {
|
2021-03-10 10:22:53 +01:00
|
|
|
switch (size) {
|
|
|
|
case -1:
|
|
|
|
return 'S'
|
|
|
|
case 0:
|
|
|
|
return 'M'
|
|
|
|
case 1:
|
|
|
|
return 'L'
|
|
|
|
case 2:
|
|
|
|
return 'XL'
|
|
|
|
case 3:
|
|
|
|
return 'XXL'
|
2022-12-28 23:41:36 +01:00
|
|
|
default:
|
|
|
|
return 'M'
|
2021-03-10 10:22:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-18 23:15:58 +01:00
|
|
|
const TabMeSettingsFontsize: React.FC<TabMeStackScreenProps<'Tab-Me-Settings-Fontsize'>> = () => {
|
2022-12-28 23:41:36 +01:00
|
|
|
const { colors } = useTheme()
|
2021-03-28 23:31:10 +02:00
|
|
|
const { t } = useTranslation('screenTabs')
|
2022-12-28 23:41:36 +01:00
|
|
|
|
|
|
|
const [fontSize, setFontSize] = useGlobalStorage.number('app.font_size')
|
2021-03-10 10:22:53 +01:00
|
|
|
|
|
|
|
const item = {
|
|
|
|
id: 'demo',
|
|
|
|
uri: 'https://tooot.app',
|
2022-05-28 22:18:03 +02:00
|
|
|
created_at: new Date(2021, 4, 16),
|
2021-03-10 10:22:53 +01:00
|
|
|
sensitive: false,
|
|
|
|
visibility: 'public',
|
|
|
|
replies_count: 0,
|
|
|
|
reblogs_count: 0,
|
|
|
|
favourites_count: 0,
|
|
|
|
favourited: true,
|
|
|
|
reblogged: false,
|
|
|
|
muted: false,
|
|
|
|
bookmarked: false,
|
2021-03-28 23:31:10 +02:00
|
|
|
content: t('me.fontSize.demo'),
|
2021-03-10 10:22:53 +01:00
|
|
|
reblog: null,
|
|
|
|
application: {
|
|
|
|
name: 'tooot',
|
|
|
|
website: 'https://tooot.app'
|
|
|
|
},
|
|
|
|
account: {
|
|
|
|
id: 'demo',
|
|
|
|
url: 'https://tooot.app',
|
|
|
|
username: 'tooot📱',
|
|
|
|
acct: 'tooot@xmflsct.com',
|
|
|
|
display_name: 'tooot📱',
|
2022-05-28 22:18:03 +02:00
|
|
|
avatar: 'https://avatars.githubusercontent.com/u/77554750?s=100',
|
2021-03-10 10:22:53 +01:00
|
|
|
avatar_static: 'https://avatars.githubusercontent.com/u/77554750?s=100'
|
|
|
|
},
|
|
|
|
media_attachments: [],
|
|
|
|
mentions: []
|
|
|
|
}
|
|
|
|
|
2022-12-28 23:41:36 +01:00
|
|
|
return (
|
|
|
|
<ScrollView>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
marginTop: StyleConstants.Spacing.M
|
|
|
|
}}
|
|
|
|
>
|
2021-03-10 10:22:53 +01:00
|
|
|
{([-1, 0, 1, 2, 3] as [-1, 0, 1, 2, 3]).map(size => (
|
2022-05-07 00:52:32 +02:00
|
|
|
<CustomText
|
2021-03-10 11:49:14 +01:00
|
|
|
key={size}
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{
|
|
|
|
marginHorizontal: StyleConstants.Spacing.XS,
|
|
|
|
paddingHorizontal: StyleConstants.Spacing.XS,
|
|
|
|
marginBottom: StyleConstants.Spacing.M,
|
|
|
|
fontSize: adaptiveScale(StyleConstants.Font.Size.M, size),
|
|
|
|
lineHeight: adaptiveScale(StyleConstants.Font.LineHeight.M, size),
|
2022-12-29 23:03:23 +01:00
|
|
|
color: (fontSize || 0) === size ? colors.primaryDefault : colors.secondary,
|
2022-12-31 00:07:28 +01:00
|
|
|
borderWidth: 1,
|
2022-05-07 00:52:32 +02:00
|
|
|
borderColor: colors.border
|
|
|
|
}}
|
2022-12-29 23:03:23 +01:00
|
|
|
fontWeight={(fontSize || 0) === size ? 'Bold' : undefined}
|
2021-03-10 10:22:53 +01:00
|
|
|
>
|
2021-03-28 23:31:10 +02:00
|
|
|
{t(`me.fontSize.sizes.${mapFontsizeToName(size)}`)}
|
2022-05-07 00:52:32 +02:00
|
|
|
</CustomText>
|
2021-03-10 10:22:53 +01:00
|
|
|
))}
|
2022-05-07 00:52:32 +02:00
|
|
|
</View>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center'
|
|
|
|
}}
|
|
|
|
>
|
2021-03-10 10:22:53 +01:00
|
|
|
<Button
|
|
|
|
onPress={() => {
|
2022-12-29 23:03:23 +01:00
|
|
|
if ((fontSize || 0) > -1) {
|
2021-03-10 10:22:53 +01:00
|
|
|
haptics('Light')
|
2021-08-29 15:25:38 +02:00
|
|
|
// @ts-ignore
|
2022-12-29 23:03:23 +01:00
|
|
|
setFontSize((fontSize || 0) - 1)
|
2021-03-10 10:22:53 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
type='icon'
|
2023-01-25 00:15:46 +01:00
|
|
|
content='minus'
|
2021-03-10 10:22:53 +01:00
|
|
|
round
|
2022-12-28 23:41:36 +01:00
|
|
|
disabled={(fontSize || 0) <= -1}
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{ marginHorizontal: StyleConstants.Spacing.S }}
|
2021-03-10 10:22:53 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
onPress={() => {
|
2022-12-29 23:03:23 +01:00
|
|
|
if ((fontSize || 0) < 3) {
|
2021-03-10 10:22:53 +01:00
|
|
|
haptics('Light')
|
2021-08-29 15:25:38 +02:00
|
|
|
// @ts-ignore
|
2022-12-29 23:03:23 +01:00
|
|
|
setFontSize((fontSize || 0) + 1)
|
2021-03-10 10:22:53 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
type='icon'
|
2023-01-25 00:15:46 +01:00
|
|
|
content='plus'
|
2021-03-10 10:22:53 +01:00
|
|
|
round
|
2022-12-28 23:41:36 +01:00
|
|
|
disabled={(fontSize || 0) >= 3}
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{ marginHorizontal: StyleConstants.Spacing.S }}
|
2021-03-10 10:22:53 +01:00
|
|
|
/>
|
|
|
|
</View>
|
2022-12-28 23:41:36 +01:00
|
|
|
<View style={{ marginVertical: StyleConstants.Spacing.L }}>
|
2022-07-09 11:40:48 +02:00
|
|
|
<ComponentSeparator
|
|
|
|
extraMarginLeft={-StyleConstants.Spacing.Global.PagePadding}
|
|
|
|
extraMarginRight={-StyleConstants.Spacing.Global.PagePadding}
|
|
|
|
/>
|
|
|
|
<TimelineDefault
|
|
|
|
// @ts-ignore
|
|
|
|
item={item}
|
|
|
|
disableDetails
|
|
|
|
disableOnPress
|
|
|
|
/>
|
|
|
|
<ComponentSeparator
|
|
|
|
extraMarginLeft={-StyleConstants.Spacing.Global.PagePadding}
|
|
|
|
extraMarginRight={-StyleConstants.Spacing.Global.PagePadding}
|
|
|
|
/>
|
|
|
|
</View>
|
2021-03-10 10:22:53 +01:00
|
|
|
</ScrollView>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
export default TabMeSettingsFontsize
|