1
0
mirror of https://github.com/tooot-app/app synced 2025-04-25 07:28:41 +02:00

Merge pull request #70 from tooot-app/main

nightly-210319
This commit is contained in:
xmflsct 2021-03-19 00:20:14 +01:00 committed by GitHub
commit d3f4b85515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 138 additions and 120 deletions

View File

@ -1,9 +1,15 @@
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import React, { useCallback, useMemo, useRef, useState } from 'react' import React, { useCallback, useMemo, useRef, useState } from 'react'
import { Pressable, StyleProp, StyleSheet, ViewStyle } from 'react-native' import {
Image,
ImageStyle,
Pressable,
StyleProp,
StyleSheet,
ViewStyle
} from 'react-native'
import { Blurhash } from 'react-native-blurhash' import { Blurhash } from 'react-native-blurhash'
import FastImage, { ImageStyle } from 'react-native-fast-image'
// blurhas -> if blurhash, show before any loading succeed // blurhas -> if blurhash, show before any loading succeed
// original -> load original // original -> load original
@ -70,7 +76,7 @@ const GracefullyImage = React.memo(
const previewView = useMemo( const previewView = useMemo(
() => () =>
uri.preview && !imageLoaded ? ( uri.preview && !imageLoaded ? (
<FastImage <Image
source={{ uri: uri.preview }} source={{ uri: uri.preview }}
style={[{ flex: 1 }, imageStyle]} style={[{ flex: 1 }, imageStyle]}
/> />
@ -79,14 +85,14 @@ const GracefullyImage = React.memo(
) )
const originalView = useMemo( const originalView = useMemo(
() => ( () => (
<FastImage <Image
source={source} source={source}
style={[{ flex: imageLoaded ? 1 : undefined }, imageStyle]} style={[{ flex: 1 }, imageStyle]}
onLoad={onLoad} onLoad={onLoad}
onError={onError} onError={onError}
/> />
), ),
[source, imageLoaded] [source]
) )
const blurhashView = useMemo(() => { const blurhashView = useMemo(() => {
return blurhash && (hidden || !imageLoaded) ? ( return blurhash && (hidden || !imageLoaded) ? (

View File

@ -23,7 +23,7 @@ const HeaderCenter = React.memo(
/> />
) )
}, },
() => true (prev, next) => prev.content === next.content
) )
const styles = StyleSheet.create({ const styles = StyleSheet.create({

View File

@ -340,6 +340,12 @@ const ScreenCompose: React.FC<ScreenComposeProp> = ({
[totalTextCount, composeState] [totalTextCount, composeState]
) )
const headerContent = useMemo(() => {
return `${totalTextCount} / ${maxTootChars}${
__DEV__ ? ` Dirty: ${composeState.dirty.toString()}` : ''
}`
}, [totalTextCount, maxTootChars, composeState.dirty])
return ( return (
<KeyboardAvoidingView <KeyboardAvoidingView
style={styles.base} style={styles.base}
@ -358,10 +364,9 @@ const ScreenCompose: React.FC<ScreenComposeProp> = ({
name='Screen-Compose-Root' name='Screen-Compose-Root'
component={ComposeRoot} component={ComposeRoot}
options={{ options={{
headerLeft, ...Platform.select({
headerTitle: `${totalTextCount} / ${maxTootChars}${ ios: {
__DEV__ ? ` Dirty: ${composeState.dirty.toString()}` : '' headerTitle: headerContent,
}`,
headerTitleStyle: { headerTitleStyle: {
fontWeight: fontWeight:
totalTextCount > maxTootChars totalTextCount > maxTootChars
@ -370,14 +375,15 @@ const ScreenCompose: React.FC<ScreenComposeProp> = ({
fontSize: StyleConstants.Font.Size.M fontSize: StyleConstants.Font.Size.M
}, },
headerTintColor: headerTintColor:
totalTextCount > maxTootChars ? theme.red : theme.secondary, totalTextCount > maxTootChars
headerCenter: () => ( ? theme.red
<HeaderCenter : theme.secondary
content={`${totalTextCount} / ${maxTootChars}${ },
__DEV__ ? ` Dirty: ${composeState.dirty.toString()}` : '' android: {
}`} headerCenter: () => <HeaderCenter content={headerContent} />
/> }
), }),
headerLeft,
headerRight headerRight
}} }}
/> />

View File

@ -9,7 +9,7 @@ import {
} from '@utils/slices/instancesSlice' } from '@utils/slices/instancesSlice'
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import React, { useCallback, useContext, useEffect, useState } from 'react' import React, { useCallback, useContext, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { import {
Dimensions, Dimensions,
@ -42,12 +42,6 @@ const ComposeDraftsListRoot: React.FC<Props> = ({ timestamp }) => {
draft => draft.timestamp !== timestamp draft => draft.timestamp !== timestamp
) )
useEffect(() => {
if (instanceDrafts?.length === 0) {
navigation.goBack()
}
}, [instanceDrafts?.length])
const actionWidth = const actionWidth =
StyleConstants.Font.Size.L + StyleConstants.Spacing.Global.PagePadding * 4 StyleConstants.Font.Size.L + StyleConstants.Spacing.Global.PagePadding * 4

View File

@ -1,7 +1,7 @@
import AttachmentVideo from '@components/Timeline/Shared/Attachment/Video' import AttachmentVideo from '@components/Timeline/Shared/Attachment/Video'
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import React, { useContext, useMemo } from 'react' import React, { useContext, useMemo, useRef } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { ScrollView, StyleSheet, Text, TextInput, View } from 'react-native' import { ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'
import ComposeContext from '../utils/createContext' import ComposeContext from '../utils/createContext'
@ -55,8 +55,10 @@ const ComposeEditAttachmentRoot: React.FC<Props> = ({ index }) => {
} }
}) })
const scrollViewRef = useRef<ScrollView>(null)
return ( return (
<ScrollView> <ScrollView ref={scrollViewRef}>
{mediaDisplay} {mediaDisplay}
<View style={styles.altTextContainer}> <View style={styles.altTextContainer}>
<Text style={[styles.altTextInputHeading, { color: theme.primary }]}> <Text style={[styles.altTextInputHeading, { color: theme.primary }]}>
@ -67,6 +69,7 @@ const ComposeEditAttachmentRoot: React.FC<Props> = ({ index }) => {
styles.altTextInput, styles.altTextInput,
{ borderColor: theme.border, color: theme.primary } { borderColor: theme.border, color: theme.primary }
]} ]}
onFocus={() => scrollViewRef.current?.scrollToEnd()}
autoCapitalize='none' autoCapitalize='none'
autoCorrect={false} autoCorrect={false}
maxLength={1500} maxLength={1500}

View File

@ -4,7 +4,13 @@ import { useSearchQuery } from '@utils/queryHooks/search'
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import { forEach, groupBy, sortBy } from 'lodash' import { forEach, groupBy, sortBy } from 'lodash'
import React, { useCallback, useContext, useEffect, useMemo } from 'react' import React, {
useCallback,
useContext,
useEffect,
useMemo,
useRef
} from 'react'
import { FlatList, Image, StyleSheet, View } from 'react-native' import { FlatList, Image, StyleSheet, View } from 'react-native'
import { Circle } from 'react-native-animated-spinkit' import { Circle } from 'react-native-animated-spinkit'
import ComposeActions from './Root/Actions' import ComposeActions from './Root/Actions'
@ -30,7 +36,8 @@ const prefetchEmojis = (
}) })
} }
const ComposeRoot: React.FC = () => { const ComposeRoot = React.memo(
() => {
const { theme } = useTheme() const { theme } = useTheme()
const { composeState, composeDispatch } = useContext(ComposeContext) const { composeState, composeDispatch } = useContext(ComposeContext)
@ -100,7 +107,7 @@ const ComposeRoot: React.FC = () => {
<FlatList <FlatList
renderItem={listItem} renderItem={listItem}
ListEmptyComponent={listEmpty} ListEmptyComponent={listEmpty}
keyboardShouldPersistTaps='handled' keyboardShouldPersistTaps='always'
ListHeaderComponent={ComposeRootHeader} ListHeaderComponent={ComposeRootHeader}
ListFooterComponent={ComposeRootFooter} ListFooterComponent={ComposeRootFooter}
ItemSeparatorComponent={ComponentSeparator} ItemSeparatorComponent={ComponentSeparator}
@ -113,7 +120,9 @@ const ComposeRoot: React.FC = () => {
<ComposePosting /> <ComposePosting />
</View> </View>
) )
} },
() => true
)
const styles = StyleSheet.create({ const styles = StyleSheet.create({
base: { base: {

View File

@ -246,7 +246,7 @@ const ComposeAttachments: React.FC = () => {
snapToAlignment='center' snapToAlignment='center'
renderItem={renderAttachment} renderItem={renderAttachment}
snapToOffsets={snapToOffsets} snapToOffsets={snapToOffsets}
keyboardShouldPersistTaps='handled' keyboardShouldPersistTaps='always'
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
data={composeState.attachments.uploads} data={composeState.attachments.uploads}
keyExtractor={item => keyExtractor={item =>

View File

@ -76,7 +76,7 @@ const ComposeEmojis: React.FC = () => {
<View style={styles.base}> <View style={styles.base}>
<SectionList <SectionList
horizontal horizontal
keyboardShouldPersistTaps='handled' keyboardShouldPersistTaps='always'
sections={composeState.emoji.emojis || []} sections={composeState.emoji.emojis || []}
keyExtractor={item => item.shortcode} keyExtractor={item => item.shortcode}
renderSectionHeader={listHeader} renderSectionHeader={listHeader}

View File

@ -46,7 +46,7 @@ const ComposeSpoilerInput: React.FC = () => {
}) })
}} }}
ref={composeState.textInputFocus.refs.spoiler} ref={composeState.textInputFocus.refs.spoiler}
scrollEnabled scrollEnabled={false}
onFocus={() => onFocus={() =>
composeDispatch({ composeDispatch({
type: 'textInputFocus', type: 'textInputFocus',

View File

@ -52,7 +52,7 @@ const ComposeTextInput: React.FC = () => {
}) })
}} }}
ref={composeState.textInputFocus.refs.text} ref={composeState.textInputFocus.refs.text}
scrollEnabled scrollEnabled={false}
> >
<Text>{composeState.text.formatted}</Text> <Text>{composeState.text.formatted}</Text>
</TextInput> </TextInput>

View File

@ -86,9 +86,9 @@ const HeaderComponent = React.memo(
analytics('imageviewer_more_share_press') analytics('imageviewer_more_share_press')
switch (Platform.OS) { switch (Platform.OS) {
case 'ios': case 'ios':
return Share.share({ url: imageUrls[currentIndex].url }) Share.share({ url: imageUrls[currentIndex].url })
case 'android': case 'android':
return Share.share({ message: imageUrls[currentIndex].url }) Share.share({ message: imageUrls[currentIndex].url })
} }
break break
} }

View File

@ -54,7 +54,7 @@ const ScreenMeSwitchRoot: React.FC = () => {
const instanceActive = useSelector(getInstanceActive) const instanceActive = useSelector(getInstanceActive)
return ( return (
<ScrollView style={styles.base} keyboardShouldPersistTaps='handled'> <ScrollView style={styles.base} keyboardShouldPersistTaps='always'>
<View style={[styles.firstSection, { borderBottomColor: theme.border }]}> <View style={[styles.firstSection, { borderBottomColor: theme.border }]}>
<Text style={[styles.header, { color: theme.primary }]}> <Text style={[styles.header, { color: theme.primary }]}>
{t('content.existing')} {t('content.existing')}