From 6f0c318d06dbfc24ec630ebfefd11dd57a326a5f Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sat, 12 Feb 2022 14:51:01 +0100 Subject: [PATCH] Implemented new dark theme --- src/Screens.tsx | 11 ++- src/components/Account.tsx | 9 +- src/components/Button.tsx | 26 +++--- src/components/Emojis/Button.tsx | 6 +- src/components/Emojis/List.tsx | 4 +- src/components/GracefullyImage.tsx | 8 +- src/components/Hashtag.tsx | 9 +- src/components/Header/Center.tsx | 4 +- src/components/Header/Left.tsx | 8 +- src/components/Header/Right.tsx | 10 +-- src/components/Input.tsx | 14 +-- src/components/Instance.tsx | 22 ++--- src/components/Instance/Info.tsx | 8 +- src/components/Menu/Header.tsx | 4 +- src/components/Menu/Row.tsx | 18 ++-- src/components/Message.tsx | 28 +++--- src/components/Parse/Emojis.tsx | 6 +- src/components/Parse/HTML.tsx | 28 +++--- src/components/Relationship/Incoming.tsx | 4 +- src/components/Relationship/Outgoing.tsx | 4 +- src/components/Separator.tsx | 6 +- src/components/Timeline.tsx | 6 +- src/components/Timeline/Conversation.tsx | 11 ++- src/components/Timeline/Default.tsx | 9 +- src/components/Timeline/Empty.tsx | 19 ++-- src/components/Timeline/Footer.tsx | 8 +- src/components/Timeline/Lookback.tsx | 8 +- src/components/Timeline/Notifications.tsx | 15 ++-- src/components/Timeline/Refresh.tsx | 13 +-- src/components/Timeline/Shared/Actioned.tsx | 9 +- src/components/Timeline/Shared/Actions.tsx | 16 ++-- .../Timeline/Shared/ActionsUsers.tsx | 11 ++- .../Timeline/Shared/Attachment/Audio.tsx | 12 +-- .../Shared/Attachment/Unsupported.tsx | 6 +- src/components/Timeline/Shared/Card.tsx | 13 +-- src/components/Timeline/Shared/Filtered.tsx | 6 +- .../Timeline/Shared/FullConversation.tsx | 4 +- .../Timeline/Shared/HeaderConversation.tsx | 12 ++- .../Timeline/Shared/HeaderDefault.tsx | 4 +- .../Timeline/Shared/HeaderNotification.tsx | 4 +- .../Timeline/Shared/HeaderShared/Account.tsx | 4 +- .../Shared/HeaderShared/Application.tsx | 4 +- .../Timeline/Shared/HeaderShared/Created.tsx | 4 +- .../Timeline/Shared/HeaderShared/Muted.tsx | 4 +- .../Shared/HeaderShared/Visibility.tsx | 6 +- src/components/Timeline/Shared/Poll.tsx | 36 ++++---- src/components/Timeline/Shared/Translate.tsx | 10 +-- src/i18n/en/screens/tabs.json | 8 ++ src/screens/Actions.tsx | 8 +- src/screens/Actions/Account.tsx | 6 +- src/screens/Actions/Domain.tsx | 4 +- src/screens/Actions/Status.tsx | 4 +- src/screens/Announcements.tsx | 38 ++++---- src/screens/Compose.tsx | 6 +- src/screens/Compose/DraftsList/Root.tsx | 18 ++-- src/screens/Compose/EditAttachment/Image.tsx | 15 ++-- src/screens/Compose/EditAttachment/Root.tsx | 12 +-- src/screens/Compose/Posting.tsx | 6 +- src/screens/Compose/Root.tsx | 4 +- src/screens/Compose/Root/Actions.tsx | 33 +++---- .../Compose/Root/Footer/Attachments.tsx | 16 ++-- src/screens/Compose/Root/Footer/Emojis.tsx | 4 +- src/screens/Compose/Root/Footer/Poll.tsx | 18 ++-- src/screens/Compose/Root/Footer/Reply.tsx | 4 +- src/screens/Compose/Root/Header/PostingAs.tsx | 4 +- .../Compose/Root/Header/SpoilerInput.tsx | 8 +- src/screens/Compose/Root/Header/TextInput.tsx | 8 +- src/screens/Compose/formatText.tsx | 4 +- src/screens/ImageViewer/save.ts | 23 ++--- src/screens/ImagesViewer.tsx | 11 +-- src/screens/Tabs.tsx | 8 +- src/screens/Tabs/Me/Profile/Fields.tsx | 16 ++-- src/screens/Tabs/Me/Profile/Name.tsx | 6 +- src/screens/Tabs/Me/Profile/Note.tsx | 14 +-- src/screens/Tabs/Me/Profile/Root.tsx | 27 +++--- .../Tabs/Me/Profile/Root/AvatarHeader.tsx | 4 +- src/screens/Tabs/Me/Push.tsx | 6 +- src/screens/Tabs/Me/Settings/Analytics.tsx | 4 +- src/screens/Tabs/Me/Settings/App.tsx | 50 +++++++++-- src/screens/Tabs/Me/Settings/Dev.tsx | 7 +- src/screens/Tabs/Me/Settings/Tooot.tsx | 8 +- src/screens/Tabs/Me/SettingsFontsize.tsx | 14 +-- src/screens/Tabs/Me/Switch.tsx | 8 +- src/screens/Tabs/Shared/Account.tsx | 10 +-- .../Tabs/Shared/Account/Attachments.tsx | 13 ++- src/screens/Tabs/Shared/Account/Header.tsx | 4 +- .../Tabs/Shared/Account/Information.tsx | 6 +- .../Shared/Account/Information/Account.tsx | 17 ++-- .../Shared/Account/Information/Created.tsx | 8 +- .../Shared/Account/Information/Fields.tsx | 10 +-- .../Tabs/Shared/Account/Information/Name.tsx | 4 +- .../Tabs/Shared/Account/Information/Stats.tsx | 19 ++-- src/screens/Tabs/Shared/Account/Nav.tsx | 4 +- src/screens/Tabs/Shared/Root.tsx | 10 +-- src/screens/Tabs/Shared/Search.tsx | 34 ++++---- src/store.ts | 8 +- src/utils/migrations/contexts/migration.ts | 15 ++-- src/utils/migrations/contexts/v2.ts | 13 +++ src/utils/migrations/instances/migration.ts | 41 +++++---- src/utils/migrations/instances/v7.ts | 77 +++++++++++++++++ src/utils/migrations/settings/migration.ts | 13 +++ src/utils/migrations/settings/v0.ts | 7 ++ src/utils/migrations/settings/v1.ts | 8 ++ src/utils/push/useConnect.ts | 4 +- src/utils/queryHooks/profile.ts | 7 +- src/utils/slices/settingsSlice.ts | 19 +++- src/utils/styles/ThemeManager.tsx | 72 ++++++++++++---- src/utils/styles/themes.ts | 86 +++++++++++++------ 108 files changed, 863 insertions(+), 571 deletions(-) create mode 100644 src/utils/migrations/contexts/v2.ts create mode 100644 src/utils/migrations/instances/v7.ts create mode 100644 src/utils/migrations/settings/migration.ts create mode 100644 src/utils/migrations/settings/v0.ts create mode 100644 src/utils/migrations/settings/v1.ts diff --git a/src/Screens.tsx b/src/Screens.tsx index 86d27c7f..632452a9 100644 --- a/src/Screens.tsx +++ b/src/Screens.tsx @@ -26,7 +26,6 @@ import { addScreenshotListener } from 'expo-screen-capture' import React, { useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { Alert, Platform, StatusBar } from 'react-native' -import { useQueryClient } from 'react-query' import { useDispatch, useSelector } from 'react-redux' import * as Sentry from 'sentry-expo' @@ -40,7 +39,7 @@ const Screens: React.FC = ({ localCorrupt }) => { const { t } = useTranslation('screens') const dispatch = useDispatch() const instanceActive = useSelector(getInstanceActive) - const { mode, theme } = useTheme() + const { colors, mode, theme } = useTheme() enum barStyle { light = 'dark-content', dark = 'light-content' @@ -53,7 +52,6 @@ const Screens: React.FC = ({ localCorrupt }) => { getInstances, (prev, next) => prev.length === next.length ) - const queryClient = useQueryClient() pushUseConnect({ t, instances }) pushUseReceive({ instances }) pushUseRespond({ instances }) @@ -77,8 +75,9 @@ const Screens: React.FC = ({ localCorrupt }) => { message: t('localCorrupt.message'), description: localCorrupt.length ? localCorrupt : undefined, type: 'error', - mode + theme }) + // @ts-ignore navigationRef.navigate('Screen-Tabs', { screen: 'Tab-Me' }) @@ -164,11 +163,11 @@ const Screens: React.FC = ({ localCorrupt }) => { <> diff --git a/src/components/Account.tsx b/src/components/Account.tsx index ca9d2f17..6ef62e2e 100644 --- a/src/components/Account.tsx +++ b/src/components/Account.tsx @@ -20,10 +20,9 @@ const ComponentAccount: React.FC = ({ onPress: customOnPress, origin }) => { - const { theme } = useTheme() - const navigation = useNavigation< - StackNavigationProp - >() + const { colors } = useTheme() + const navigation = + useNavigation>() const onPress = useCallback(() => { analytics('search_account_press', { page: origin }) @@ -51,7 +50,7 @@ const ComponentAccount: React.FC = ({ @{account.acct} diff --git a/src/components/Button.tsx b/src/components/Button.tsx index d884b472..ffdb695f 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -54,7 +54,7 @@ const Button: React.FC = ({ overlay = false, onPress }) => { - const { mode, theme } = useTheme() + const { colors, theme } = useTheme() const mounted = useRef(false) useEffect(() => { @@ -68,35 +68,35 @@ const Button: React.FC = ({ const loadingSpinkit = useMemo( () => ( - + ), - [mode] + [theme] ) const mainColor = useMemo(() => { if (selected) { - return theme.blue + return colors.blue } else if (overlay) { - return theme.primaryOverlay + return colors.primaryOverlay } else if (disabled || loading) { - return theme.disabled + return colors.disabled } else { if (destructive) { - return theme.red + return colors.red } else { - return theme.primaryDefault + return colors.primaryDefault } } - }, [mode, disabled, loading, selected]) + }, [theme, disabled, loading, selected]) const colorBackground = useMemo(() => { if (overlay) { - return theme.backgroundOverlayInvert + return colors.backgroundOverlayInvert } else { - return theme.backgroundDefault + return colors.backgroundDefault } - }, [mode]) + }, [theme]) const children = useMemo(() => { switch (type) { @@ -130,7 +130,7 @@ const Button: React.FC = ({ ) } - }, [mode, content, loading, disabled]) + }, [theme, content, loading, disabled]) const [layoutHeight, setLayoutHeight] = useState() diff --git a/src/components/Emojis/Button.tsx b/src/components/Emojis/Button.tsx index e6d03283..92ce4620 100644 --- a/src/components/Emojis/Button.tsx +++ b/src/components/Emojis/Button.tsx @@ -7,7 +7,7 @@ import EmojisContext from './helpers/EmojisContext' const EmojisButton = React.memo( () => { - const { theme } = useTheme() + const { colors } = useTheme() const { emojisState, emojisDispatch } = useContext(EmojisContext) return emojisState.enabled ? ( @@ -30,8 +30,8 @@ const EmojisButton = React.memo( size={StyleConstants.Font.Size.L} color={ emojisState.emojis && emojisState.emojis.length - ? theme.primaryDefault - : theme.disabled + ? colors.primaryDefault + : colors.disabled } /> } diff --git a/src/components/Emojis/List.tsx b/src/components/Emojis/List.tsx index 5e5998d0..c143e3c8 100644 --- a/src/components/Emojis/List.tsx +++ b/src/components/Emojis/List.tsx @@ -23,11 +23,11 @@ const EmojisList = React.memo( const { t } = useTranslation() const { emojisState, emojisDispatch } = useContext(EmojisContext) - const { theme } = useTheme() + const { colors } = useTheme() const listHeader = useCallback( ({ section: { title } }) => ( - {title} + {title} ), [] ) diff --git a/src/components/GracefullyImage.tsx b/src/components/GracefullyImage.tsx index 2e1257d0..6ba1d475 100644 --- a/src/components/GracefullyImage.tsx +++ b/src/components/GracefullyImage.tsx @@ -51,7 +51,7 @@ const GracefullyImage = React.memo( imageStyle, setImageDimensions }: Props) => { - const { theme } = useTheme() + const { colors } = useTheme() const [originalFailed, setOriginalFailed] = useState(false) const [imageLoaded, setImageLoaded] = useState(false) @@ -85,7 +85,7 @@ const GracefullyImage = React.memo( source={{ uri: uri.preview }} style={[ styles.placeholder, - { backgroundColor: theme.shimmerDefault } + { backgroundColor: colors.shimmerDefault } ]} /> ) : null, @@ -118,7 +118,7 @@ const GracefullyImage = React.memo( ) @@ -135,7 +135,7 @@ const GracefullyImage = React.memo( : { accessibilityRole: 'image' })} accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} - style={[style, dimension, { backgroundColor: theme.shimmerDefault }]} + style={[style, dimension, { backgroundColor: colors.shimmerDefault }]} {...(onPress ? hidden ? { disabled: true } diff --git a/src/components/Hashtag.tsx b/src/components/Hashtag.tsx index d23ea288..c32a9ef7 100644 --- a/src/components/Hashtag.tsx +++ b/src/components/Hashtag.tsx @@ -17,10 +17,9 @@ const ComponentHashtag: React.FC = ({ onPress: customOnPress, origin }) => { - const { theme } = useTheme() - const navigation = useNavigation< - StackNavigationProp - >() + const { colors } = useTheme() + const navigation = + useNavigation>() const onPress = useCallback(() => { analytics('search_account_press', { page: origin }) @@ -33,7 +32,7 @@ const ComponentHashtag: React.FC = ({ style={styles.itemDefault} onPress={customOnPress || onPress} > - + #{hashtag.name} diff --git a/src/components/Header/Center.tsx b/src/components/Header/Center.tsx index 74c93c25..eb6965ea 100644 --- a/src/components/Header/Center.tsx +++ b/src/components/Header/Center.tsx @@ -11,13 +11,13 @@ export interface Props { // Used for Android mostly const HeaderCenter = React.memo( ({ content, inverted = false }: Props) => { - const { theme } = useTheme() + const { colors } = useTheme() return ( diff --git a/src/components/Header/Left.tsx b/src/components/Header/Left.tsx index b89c8ead..6aabba0d 100644 --- a/src/components/Header/Left.tsx +++ b/src/components/Header/Left.tsx @@ -20,14 +20,14 @@ const HeaderLeft: React.FC = ({ background = false, onPress }) => { - const { theme } = useTheme() + const { colors, theme } = useTheme() const children = useMemo(() => { switch (type) { case 'icon': return ( @@ -35,7 +35,7 @@ const HeaderLeft: React.FC = ({ case 'text': return ( ) @@ -50,7 +50,7 @@ const HeaderLeft: React.FC = ({ styles.base, { backgroundColor: background - ? theme.backgroundOverlayDefault + ? colors.backgroundOverlayDefault : undefined, minHeight: 44, minWidth: 44, diff --git a/src/components/Header/Right.tsx b/src/components/Header/Right.tsx index dde2f58d..94ebf1d8 100644 --- a/src/components/Header/Right.tsx +++ b/src/components/Header/Right.tsx @@ -41,14 +41,14 @@ const HeaderRight: React.FC = ({ disabled, onPress }) => { - const { theme } = useTheme() + const { colors, theme } = useTheme() const loadingSpinkit = useMemo( () => ( ), @@ -64,7 +64,7 @@ const HeaderRight: React.FC = ({ name={content} style={{ opacity: loading ? 0 : 1 }} size={StyleConstants.Spacing.M * 1.25} - color={disabled ? theme.secondary : theme.primaryDefault} + color={disabled ? colors.secondary : colors.primaryDefault} /> {loading && loadingSpinkit} @@ -76,7 +76,7 @@ const HeaderRight: React.FC = ({ style={[ styles.text, { - color: disabled ? theme.secondary : theme.primaryDefault, + color: disabled ? colors.secondary : colors.primaryDefault, opacity: loading ? 0 : 1 } ]} @@ -101,7 +101,7 @@ const HeaderRight: React.FC = ({ styles.base, { backgroundColor: background - ? theme.backgroundOverlayDefault + ? colors.backgroundOverlayDefault : undefined, minHeight: 44, minWidth: 44, diff --git a/src/components/Input.tsx b/src/components/Input.tsx index dcdd0f20..123c8165 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -57,7 +57,7 @@ const Input: React.FC = ({ setValue, options }) => { - const { mode, theme } = useTheme() + const { colors, mode } = useTheme() const animateTitle = useAnimatedStyle(() => { if (value) { @@ -66,7 +66,7 @@ const Input: React.FC = ({ paddingHorizontal: withTiming(StyleConstants.Spacing.XS), left: withTiming(StyleConstants.Spacing.S), top: withTiming(-(StyleConstants.Font.Size.S / 2) - 2), - backgroundColor: withTiming(theme.backgroundDefault) + backgroundColor: withTiming(colors.backgroundDefault) } } else { return { @@ -74,7 +74,7 @@ const Input: React.FC = ({ paddingHorizontal: withTiming(0), left: withTiming(StyleConstants.Spacing.S), top: withTiming(StyleConstants.Spacing.S + 1), - backgroundColor: withTiming(theme.backgroundDefaultTransparent) + backgroundColor: withTiming(colors.backgroundDefaultTransparent) } } }, [mode, value]) @@ -109,7 +109,7 @@ const Input: React.FC = ({ style={[ styles.base, { - borderColor: theme.border, + borderColor: colors.border, flexDirection: multiline ? 'column' : 'row', alignItems: 'stretch' } @@ -127,7 +127,7 @@ const Input: React.FC = ({ style={[ styles.textInput, { - color: theme.primaryDefault, + color: colors.primaryDefault, minHeight: Platform.OS === 'ios' && multiline ? StyleConstants.Font.LineHeight.M * 5 @@ -149,14 +149,14 @@ const Input: React.FC = ({ {title ? ( {title} ) : null} {options?.maxLength && value?.length ? ( - + {value?.length} / {options.maxLength} ) : null} diff --git a/src/components/Instance.tsx b/src/components/Instance.tsx index 1b46c7d5..26c1f6fc 100644 --- a/src/components/Instance.tsx +++ b/src/components/Instance.tsx @@ -39,7 +39,7 @@ const ComponentInstance: React.FC = ({ goBack = false }) => { const { t } = useTranslation('componentInstance') - const { mode, theme } = useTheme() + const { colors, mode } = useTheme() const { screenReaderEnabled } = useAccessibility() const instances = useSelector(getInstances, () => true) @@ -149,10 +149,10 @@ const ComponentInstance: React.FC = ({ style={[ styles.prefix, { - color: theme.primaryDefault, + color: colors.primaryDefault, borderBottomColor: instanceQuery.isError - ? theme.red - : theme.border + ? colors.red + : colors.border } ]} editable={false} @@ -162,10 +162,10 @@ const ComponentInstance: React.FC = ({ style={[ styles.textInput, { - color: theme.primaryDefault, + color: colors.primaryDefault, borderBottomColor: instanceQuery.isError - ? theme.red - : theme.border + ? colors.red + : colors.border } ]} onChangeText={onChangeText} @@ -175,7 +175,7 @@ const ComponentInstance: React.FC = ({ textContentType='URL' onSubmitEditing={onSubmitEditing} placeholder={' ' + t('server.textInput.placeholder')} - placeholderTextColor={theme.secondary} + placeholderTextColor={colors.secondary} returnKeyType='go' keyboardAppearance={mode} {...(scrollViewRef && { @@ -234,11 +234,11 @@ const ComponentInstance: React.FC = ({ { if (screenReaderEnabled) { @@ -252,7 +252,7 @@ const ComponentInstance: React.FC = ({ {t('server.disclaimer.base')} { analytics('view_privacy') WebBrowser.openBrowserAsync( diff --git a/src/components/Instance/Info.tsx b/src/components/Instance/Info.tsx index 77f92ed4..7a2ca6b1 100644 --- a/src/components/Instance/Info.tsx +++ b/src/components/Instance/Info.tsx @@ -13,15 +13,15 @@ export interface Props { const InstanceInfo = React.memo( ({ style, header, content, potentialWidth }: Props) => { - const { theme } = useTheme() + const { colors } = useTheme() return ( - + {header} {content ? ( - + {content} ) : ( @@ -32,7 +32,7 @@ const InstanceInfo = React.memo( : undefined } height={StyleConstants.Font.LineHeight.M} - color={theme.shimmerDefault} + color={colors.shimmerDefault} noMargin style={{ borderRadius: 0 }} /> diff --git a/src/components/Menu/Header.tsx b/src/components/Menu/Header.tsx index fc455484..fca2e036 100644 --- a/src/components/Menu/Header.tsx +++ b/src/components/Menu/Header.tsx @@ -8,11 +8,11 @@ export interface Props { } const MenuHeader: React.FC = ({ heading }) => { - const { theme } = useTheme() + const { colors } = useTheme() return ( - {heading} + {heading} ) } diff --git a/src/components/Menu/Row.tsx b/src/components/Menu/Row.tsx index 04040091..b44e68d3 100644 --- a/src/components/Menu/Row.tsx +++ b/src/components/Menu/Row.tsx @@ -43,7 +43,7 @@ const MenuRow: React.FC = ({ loading = false, onPress }) => { - const { theme } = useTheme() + const { colors, theme } = useTheme() const { screenReaderEnabled } = useAccessibility() const loadingSpinkit = useMemo( @@ -51,7 +51,7 @@ const MenuRow: React.FC = ({ ), @@ -83,7 +83,7 @@ const MenuRow: React.FC = ({ )} @@ -92,7 +92,7 @@ const MenuRow: React.FC = ({ style={{ width: 8, height: 8, - backgroundColor: theme.red, + backgroundColor: colors.red, borderRadius: 8, marginRight: StyleConstants.Spacing.S }} @@ -100,7 +100,7 @@ const MenuRow: React.FC = ({ ) : null} {title} @@ -116,7 +116,7 @@ const MenuRow: React.FC = ({ style={[ styles.content, { - color: theme.secondary, + color: colors.secondary, opacity: !iconBack && loading ? 0 : 1 } ]} @@ -133,7 +133,7 @@ const MenuRow: React.FC = ({ value={switchValue} onValueChange={switchOnValueChange} disabled={switchDisabled} - trackColor={{ true: theme.blue, false: theme.disabled }} + trackColor={{ true: colors.blue, false: colors.disabled }} style={{ opacity: loading ? 0 : 1 }} /> ) : null} @@ -141,7 +141,7 @@ const MenuRow: React.FC = ({ ) : null} @@ -150,7 +150,7 @@ const MenuRow: React.FC = ({ ) : null} {description ? ( - + {description} ) : null} diff --git a/src/components/Message.tsx b/src/components/Message.tsx index db350f64..ab6c1468 100644 --- a/src/components/Message.tsx +++ b/src/components/Message.tsx @@ -1,7 +1,7 @@ import Icon from '@components/Icon' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' -import { getTheme } from '@utils/styles/themes' +import { getColors, Theme } from '@utils/styles/themes' import React, { RefObject } from 'react' import { AccessibilityInfo } from 'react-native' import FlashMessage, { @@ -17,7 +17,7 @@ const displayMessage = ({ message, description, onPress, - mode, + theme, type }: | { @@ -27,7 +27,7 @@ const displayMessage = ({ message: string description?: string onPress?: () => void - mode?: undefined + theme?: undefined type?: undefined } | { @@ -37,7 +37,7 @@ const displayMessage = ({ message: string description?: string onPress?: () => void - mode: 'light' | 'dark' + theme: Theme type: 'success' | 'error' | 'warning' }) => { AccessibilityInfo.announceForAccessibility(message + '.' + description) @@ -64,14 +64,14 @@ const displayMessage = ({ message, description, onPress, - ...(mode && + ...(theme && type && { renderFlashMessageIcon: () => { return ( ) @@ -85,14 +85,14 @@ const displayMessage = ({ message, description, onPress, - ...(mode && + ...(theme && type && { renderFlashMessageIcon: () => { return ( ) @@ -111,7 +111,7 @@ const removeMessage = () => { } const Message = React.forwardRef((_, ref) => { - const { mode, theme } = useTheme() + const { colors, theme } = useTheme() return ( ((_, ref) => { position='top' floating style={{ - backgroundColor: theme.backgroundDefault, - shadowColor: theme.primaryDefault, + backgroundColor: colors.backgroundDefault, + shadowColor: colors.primaryDefault, shadowOffset: { width: 0, height: 0 }, - shadowOpacity: mode === 'light' ? 0.16 : 0.24, + shadowOpacity: theme === 'light' ? 0.16 : 0.24, shadowRadius: 4 }} titleStyle={{ - color: theme.primaryDefault, + color: colors.primaryDefault, ...StyleConstants.FontStyle.M, fontWeight: StyleConstants.Font.Weight.Bold }} textStyle={{ - color: theme.primaryDefault, + color: colors.primaryDefault, ...StyleConstants.FontStyle.S }} // @ts-ignore diff --git a/src/components/Parse/Emojis.tsx b/src/components/Parse/Emojis.tsx index 79457eb5..0a06b02c 100644 --- a/src/components/Parse/Emojis.tsx +++ b/src/components/Parse/Emojis.tsx @@ -39,11 +39,11 @@ const ParseEmojis = React.memo( adaptiveSize ? adaptiveFontsize : 0 ) - const { mode, theme } = useTheme() + const { colors, theme } = useTheme() const styles = useMemo(() => { return StyleSheet.create({ text: { - color: theme.primaryDefault, + color: colors.primaryDefault, fontSize: adaptedFontsize, lineHeight: adaptedLineheight, ...(fontBold && { fontWeight: StyleConstants.Font.Weight.Bold }) @@ -54,7 +54,7 @@ const ParseEmojis = React.memo( transform: [{ translateY: -2 }] } }) - }, [mode, adaptiveFontsize]) + }, [theme, adaptiveFontsize]) return ( diff --git a/src/components/Parse/HTML.tsx b/src/components/Parse/HTML.tsx index 5c9f90e5..38d88536 100644 --- a/src/components/Parse/HTML.tsx +++ b/src/components/Parse/HTML.tsx @@ -18,7 +18,7 @@ import { useSelector } from 'react-redux' // Prevent going to the same hashtag multiple times const renderNode = ({ routeParams, - theme, + colors, node, index, adaptedFontsize, @@ -30,7 +30,7 @@ const renderNode = ({ disableDetails }: { routeParams?: any - theme: any + colors: any node: any index: number adaptedFontsize: number @@ -56,7 +56,7 @@ const renderNode = ({ accessible key={index} style={{ - color: theme.blue, + color: colors.blue, fontSize: adaptedFontsize, lineHeight: adaptedLineheight }} @@ -84,7 +84,8 @@ const renderNode = ({ - >() + const navigation = + useNavigation>() const route = useRoute() - const { mode, theme } = useTheme() + const { colors, theme } = useTheme() const { t, i18n } = useTranslation('componentParse') if (!expandHint) { expandHint = t('HTML.defaultHint') @@ -206,7 +206,7 @@ const ParseHTML = React.memo( (node, index) => renderNode({ routeParams: route.params, - theme, + colors, node, index, adaptedFontsize, @@ -271,14 +271,14 @@ const ParseHTML = React.memo( justifyContent: 'center', marginTop: expanded ? 0 : -adaptedLineheight, minHeight: 44, - backgroundColor: theme.backgroundDefault + backgroundColor: colors.backgroundDefault }} > ) }, - [mode, i18n.language] + [theme, i18n.language] ) return ( diff --git a/src/components/Relationship/Incoming.tsx b/src/components/Relationship/Incoming.tsx index d8d8f14f..feb97340 100644 --- a/src/components/Relationship/Incoming.tsx +++ b/src/components/Relationship/Incoming.tsx @@ -19,7 +19,7 @@ export interface Props { } const RelationshipIncoming: React.FC = ({ id }) => { - const { mode } = useTheme() + const { theme } = useTheme() const { t } = useTranslation() const queryKeyRelationship: QueryKeyRelationship = ['Relationship', { id }] @@ -40,7 +40,7 @@ const RelationshipIncoming: React.FC = ({ id }) => { haptics('Error') displayMessage({ type: 'error', - mode, + theme, message: t('common:message.error.message', { function: t(`relationship:${type}.function`) }), diff --git a/src/components/Relationship/Outgoing.tsx b/src/components/Relationship/Outgoing.tsx index 783e3951..13c9b229 100644 --- a/src/components/Relationship/Outgoing.tsx +++ b/src/components/Relationship/Outgoing.tsx @@ -19,7 +19,7 @@ export interface Props { const RelationshipOutgoing = React.memo( ({ id }: Props) => { - const { mode } = useTheme() + const { theme } = useTheme() const { t } = useTranslation('componentRelationship') const query = useRelationshipQuery({ id }) @@ -40,7 +40,7 @@ const RelationshipOutgoing = React.memo( }, onError: (err: any, { payload: { action } }) => { displayMessage({ - mode, + theme, type: 'error', message: t('common:message.error.message', { function: t(`${action}.function`) diff --git a/src/components/Separator.tsx b/src/components/Separator.tsx index 6cf64835..0241ce90 100644 --- a/src/components/Separator.tsx +++ b/src/components/Separator.tsx @@ -10,13 +10,13 @@ export interface Props { const ComponentSeparator = React.memo( ({ extraMarginLeft = 0, extraMarginRight = 0 }: Props) => { - const { theme } = useTheme() + const { colors } = useTheme() return ( = ({ lookback, customProps }) => { - const { theme } = useTheme() + const { colors } = useTheme() const { data, @@ -118,8 +118,8 @@ const Timeline: React.FC = ({ refreshControl: ( refetch()} /> diff --git a/src/components/Timeline/Conversation.tsx b/src/components/Timeline/Conversation.tsx index 01fc64d4..dea4c1c5 100644 --- a/src/components/Timeline/Conversation.tsx +++ b/src/components/Timeline/Conversation.tsx @@ -62,7 +62,7 @@ const TimelineConversation: React.FC = ({ getInstanceAccount, (prev, next) => prev?.id === next?.id ) - const { theme } = useTheme() + const { colors } = useTheme() const queryClient = useQueryClient() const fireMutation = useCallback(() => { @@ -77,9 +77,8 @@ const TimelineConversation: React.FC = ({ } }) - const navigation = useNavigation< - StackNavigationProp - >() + const navigation = + useNavigation>() const onPress = useCallback(() => { analytics('timeline_conversation_press') if (conversation.last_status) { @@ -95,10 +94,10 @@ const TimelineConversation: React.FC = ({ = ({ disableDetails = false, disableOnPress = false }) => { - const { theme } = useTheme() + const { colors } = useTheme() const instanceAccount = useSelector(getInstanceAccount, () => true) - const navigation = useNavigation< - StackNavigationProp - >() + const navigation = + useNavigation>() const actualStatus = item.reblog ? item.reblog : item @@ -78,7 +77,7 @@ const TimelineDefault: React.FC = ({ style={[ styles.statusView, { - backgroundColor: theme.backgroundDefault, + backgroundColor: colors.backgroundDefault, paddingBottom: disableDetails && disableOnPress ? StyleConstants.Spacing.Global.PagePadding diff --git a/src/components/Timeline/Empty.tsx b/src/components/Timeline/Empty.tsx index 18d9378a..8b7fdf4b 100644 --- a/src/components/Timeline/Empty.tsx +++ b/src/components/Timeline/Empty.tsx @@ -20,14 +20,17 @@ const TimelineEmpty = React.memo( options: { notifyOnChangeProps: ['status'] } }) - const { mode, theme } = useTheme() + const { colors, theme } = useTheme() const { t, i18n } = useTranslation('componentTimeline') const children = useMemo(() => { switch (status) { case 'loading': return ( - + ) case 'error': return ( @@ -35,9 +38,9 @@ const TimelineEmpty = React.memo( - + {t('empty.error.message')}