1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
Zhiyuan Zheng
2020-12-26 00:53:49 +01:00
parent 7f574576ef
commit f990ff0cb1
5 changed files with 58 additions and 47 deletions

View File

@ -74,7 +74,7 @@ const TimelineNotifications: React.FC<Props> = ({
{notification.status.media_attachments.length > 0 && ( {notification.status.media_attachments.length > 0 && (
<TimelineAttachment <TimelineAttachment
status={notification.status} status={notification.status}
width={contentWidth} contentWidth={contentWidth}
/> />
)} )}
{notification.status.card && ( {notification.status.card && (

View File

@ -4,6 +4,7 @@ import ParseContent from '@components/ParseContent'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { LinearGradient } from 'expo-linear-gradient' import { LinearGradient } from 'expo-linear-gradient'
import layoutAnimation from '@root/utils/styles/layoutAnimation'
export interface Props { export interface Props {
status: Mastodon.Status status: Mastodon.Status
@ -16,7 +17,7 @@ const TimelineContent: React.FC<Props> = ({
numberOfLines, numberOfLines,
highlighted = false highlighted = false
}) => { }) => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) layoutAnimation()
const { theme } = useTheme() const { theme } = useTheme()
const [spoilerCollapsed, setSpoilerCollapsed] = useState(false) const [spoilerCollapsed, setSpoilerCollapsed] = useState(false)
const lineHeight = 28 const lineHeight = 28

View File

@ -1,5 +1,5 @@
import React, { useRef, useState } from 'react' 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 { useSelector } from 'react-redux'
import { getLocalUrl } from '@utils/slices/instancesSlice' import { getLocalUrl } from '@utils/slices/instancesSlice'
@ -12,9 +12,10 @@ import Logout from '@screens/Me/Root/Logout'
import { useScrollToTop } from '@react-navigation/native' import { useScrollToTop } from '@react-navigation/native'
import { AccountState } from '../Shared/Account' import { AccountState } from '../Shared/Account'
import AccountNav from '../Shared/Account/Nav' import AccountNav from '../Shared/Account/Nav'
import layoutAnimation from '@root/utils/styles/layoutAnimation'
const ScreenMeRoot: React.FC = () => { const ScreenMeRoot: React.FC = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) layoutAnimation()
const localRegistered = useSelector(getLocalUrl) const localRegistered = useSelector(getLocalUrl)
const scrollRef = useRef<ScrollView>(null) const scrollRef = useRef<ScrollView>(null)

View File

@ -1,5 +1,5 @@
import React, { useEffect, useReducer, useRef, useState } from 'react' 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 { useQuery } from 'react-query'
import { accountFetch } from '@utils/fetches/accountFetch' import { accountFetch } from '@utils/fetches/accountFetch'
@ -13,6 +13,7 @@ import BottomSheet from '@root/components/BottomSheet'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { getLocalAccountId } from '@root/utils/slices/instancesSlice' import { getLocalAccountId } from '@root/utils/slices/instancesSlice'
import HeaderDefaultActionsAccount from '@root/components/Timelines/Timeline/Shared/HeaderDefault/ActionsAccount' 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 // Moved account example: https://m.cmx.im/web/accounts/27812
@ -73,7 +74,7 @@ const ScreenSharedAccount: React.FC<Props> = ({
}, },
navigation navigation
}) => { }) => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) layoutAnimation()
const localAccountId = useSelector(getLocalAccountId) const localAccountId = useSelector(getLocalAccountId)
const { data } = useQuery(['Account', { id: account.id }], accountFetch) const { data } = useQuery(['Account', { id: account.id }], accountFetch)

View File

@ -4,6 +4,7 @@ import React, {
Dispatch, Dispatch,
ReactNode, ReactNode,
RefObject, RefObject,
useCallback,
useEffect, useEffect,
useReducer, useReducer,
useState useState
@ -13,7 +14,6 @@ import {
Alert, Alert,
Keyboard, Keyboard,
KeyboardAvoidingView, KeyboardAvoidingView,
LayoutAnimation,
StyleSheet, StyleSheet,
Text, Text,
TextInput TextInput
@ -333,7 +333,6 @@ export interface Props {
} }
const Compose: React.FC<Props> = ({ route: { params }, navigation }) => { const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
const { theme } = useTheme() const { theme } = useTheme()
const queryClient = useQueryClient() const queryClient = useQueryClient()
@ -538,17 +537,8 @@ const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
edit: '发嘟嘟' edit: '发嘟嘟'
} }
return ( const headerLeft = useCallback(
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }}> () => (
<SafeAreaView
style={{ flex: 1 }}
edges={hasKeyboard ? ['left', 'right'] : ['left', 'right', 'bottom']}
>
<Stack.Navigator>
<Stack.Screen
name='PostMain'
options={{
headerLeft: () => (
<HeaderLeft <HeaderLeft
onPress={() => onPress={() =>
Alert.alert('确认取消编辑?', '', [ Alert.alert('确认取消编辑?', '', [
@ -563,7 +553,10 @@ const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
text='退出编辑' text='退出编辑'
/> />
), ),
headerCenter: () => ( []
)
const headerCenter = useCallback(
() => (
<Text <Text
style={[ style={[
styles.count, styles.count,
@ -575,7 +568,10 @@ const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
{totalTextCount} / 500 {totalTextCount} / 500
</Text> </Text>
), ),
headerRight: () => [totalTextCount]
)
const headerRight = useCallback(
() =>
isSubmitting ? ( isSubmitting ? (
<ActivityIndicator /> <ActivityIndicator />
) : ( ) : (
@ -584,8 +580,20 @@ const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
text={params?.type ? postButtonText[params.type] : '发嘟嘟'} text={params?.type ? postButtonText[params.type] : '发嘟嘟'}
disabled={rawCount < 1 || totalTextCount > 500} disabled={rawCount < 1 || totalTextCount > 500}
/> />
),
[isSubmitting, rawCount, totalTextCount]
) )
}}
return (
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }}>
<SafeAreaView
style={{ flex: 1 }}
edges={hasKeyboard ? ['left', 'right'] : ['left', 'right', 'bottom']}
>
<Stack.Navigator>
<Stack.Screen
name='PostMain'
options={{ headerLeft, headerCenter, headerRight }}
> >
{() => ( {() => (
<ComposeContext.Provider <ComposeContext.Provider