diff --git a/src/components/Timelines/Timeline/Notifications.tsx b/src/components/Timelines/Timeline/Notifications.tsx index ed50a12a..430b86f0 100644 --- a/src/components/Timelines/Timeline/Notifications.tsx +++ b/src/components/Timelines/Timeline/Notifications.tsx @@ -74,7 +74,7 @@ const TimelineNotifications: React.FC = ({ {notification.status.media_attachments.length > 0 && ( )} {notification.status.card && ( diff --git a/src/components/Timelines/Timeline/Shared/Content.tsx b/src/components/Timelines/Timeline/Shared/Content.tsx index 3a3bc872..9fb27973 100644 --- a/src/components/Timelines/Timeline/Shared/Content.tsx +++ b/src/components/Timelines/Timeline/Shared/Content.tsx @@ -4,6 +4,7 @@ import ParseContent from '@components/ParseContent' import { useTheme } from '@utils/styles/ThemeManager' import { StyleConstants } from '@utils/styles/constants' import { LinearGradient } from 'expo-linear-gradient' +import layoutAnimation from '@root/utils/styles/layoutAnimation' export interface Props { status: Mastodon.Status @@ -16,7 +17,7 @@ const TimelineContent: React.FC = ({ numberOfLines, highlighted = false }) => { - LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) + layoutAnimation() const { theme } = useTheme() const [spoilerCollapsed, setSpoilerCollapsed] = useState(false) const lineHeight = 28 diff --git a/src/screens/Me/Root.tsx b/src/screens/Me/Root.tsx index 97fe26e8..4b8365f0 100644 --- a/src/screens/Me/Root.tsx +++ b/src/screens/Me/Root.tsx @@ -1,5 +1,5 @@ import React, { useRef, useState } from 'react' -import { Animated, LayoutAnimation, ScrollView } from 'react-native' +import { Animated, ScrollView } from 'react-native' import { useSelector } from 'react-redux' import { getLocalUrl } from '@utils/slices/instancesSlice' @@ -12,9 +12,10 @@ import Logout from '@screens/Me/Root/Logout' import { useScrollToTop } from '@react-navigation/native' import { AccountState } from '../Shared/Account' import AccountNav from '../Shared/Account/Nav' +import layoutAnimation from '@root/utils/styles/layoutAnimation' const ScreenMeRoot: React.FC = () => { - LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) + layoutAnimation() const localRegistered = useSelector(getLocalUrl) const scrollRef = useRef(null) diff --git a/src/screens/Shared/Account.tsx b/src/screens/Shared/Account.tsx index 6d66a973..ce6156db 100644 --- a/src/screens/Shared/Account.tsx +++ b/src/screens/Shared/Account.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useReducer, useRef, useState } from 'react' -import { Animated, LayoutAnimation, ScrollView } from 'react-native' +import { Animated, ScrollView } from 'react-native' import { useQuery } from 'react-query' import { accountFetch } from '@utils/fetches/accountFetch' @@ -13,6 +13,7 @@ import BottomSheet from '@root/components/BottomSheet' import { useSelector } from 'react-redux' import { getLocalAccountId } from '@root/utils/slices/instancesSlice' import HeaderDefaultActionsAccount from '@root/components/Timelines/Timeline/Shared/HeaderDefault/ActionsAccount' +import layoutAnimation from '@root/utils/styles/layoutAnimation' // Moved account example: https://m.cmx.im/web/accounts/27812 @@ -73,7 +74,7 @@ const ScreenSharedAccount: React.FC = ({ }, navigation }) => { - LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) + layoutAnimation() const localAccountId = useSelector(getLocalAccountId) const { data } = useQuery(['Account', { id: account.id }], accountFetch) diff --git a/src/screens/Shared/Compose.tsx b/src/screens/Shared/Compose.tsx index 55868bdd..32975a98 100644 --- a/src/screens/Shared/Compose.tsx +++ b/src/screens/Shared/Compose.tsx @@ -4,6 +4,7 @@ import React, { Dispatch, ReactNode, RefObject, + useCallback, useEffect, useReducer, useState @@ -13,7 +14,6 @@ import { Alert, Keyboard, KeyboardAvoidingView, - LayoutAnimation, StyleSheet, Text, TextInput @@ -333,7 +333,6 @@ export interface Props { } const Compose: React.FC = ({ route: { params }, navigation }) => { - LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) const { theme } = useTheme() const queryClient = useQueryClient() @@ -538,6 +537,53 @@ const Compose: React.FC = ({ route: { params }, navigation }) => { edit: '发嘟嘟' } + const headerLeft = useCallback( + () => ( + + Alert.alert('确认取消编辑?', '', [ + { text: '继续编辑', style: 'cancel' }, + { + text: '退出编辑', + style: 'destructive', + onPress: () => navigation.goBack() + } + ]) + } + text='退出编辑' + /> + ), + [] + ) + const headerCenter = useCallback( + () => ( + 500 ? theme.red : theme.secondary + } + ]} + > + {totalTextCount} / 500 + + ), + [totalTextCount] + ) + const headerRight = useCallback( + () => + isSubmitting ? ( + + ) : ( + tootPost()} + text={params?.type ? postButtonText[params.type] : '发嘟嘟'} + disabled={rawCount < 1 || totalTextCount > 500} + /> + ), + [isSubmitting, rawCount, totalTextCount] + ) + return ( = ({ route: { params }, navigation }) => { ( - - Alert.alert('确认取消编辑?', '', [ - { text: '继续编辑', style: 'cancel' }, - { - text: '退出编辑', - style: 'destructive', - onPress: () => navigation.goBack() - } - ]) - } - text='退出编辑' - /> - ), - headerCenter: () => ( - 500 ? theme.red : theme.secondary - } - ]} - > - {totalTextCount} / 500 - - ), - headerRight: () => - isSubmitting ? ( - - ) : ( - tootPost()} - text={params?.type ? postButtonText[params.type] : '发嘟嘟'} - disabled={rawCount < 1 || totalTextCount > 500} - /> - ) - }} + options={{ headerLeft, headerCenter, headerRight }} > {() => (