1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Fine tune compose more

This commit is contained in:
Zhiyuan Zheng
2020-12-06 22:32:36 +01:00
parent e5eaf162f4
commit 37ad208f8b
8 changed files with 92 additions and 66 deletions

View File

@ -3,6 +3,7 @@ import React, { createElement, Dispatch } from 'react'
import { Text } from 'react-native'
import { RefetchOptions } from 'react-query/types/core/query'
import Autolinker from 'src/modules/autolinker'
import { useTheme } from 'src/utils/styles/ThemeManager'
import { PostAction, PostState } from '../Compose'
export interface Params {
@ -12,6 +13,16 @@ export interface Params {
disableDebounce?: boolean
}
const TagText = ({ text }: { text: string }) => {
const { theme } = useTheme()
return (
<Text style={{ color: theme.link }} key={Math.random()}>
{text}
</Text>
)
}
const debouncedSuggestions = debounce(
(postDispatch, tag) => {
postDispatch({ type: 'tag', payload: tag })
@ -77,11 +88,7 @@ const formatText = ({
const prevPart = parts.shift()
children.push(prevPart)
contentLength = contentLength + (prevPart ? prevPart.length : 0)
children.push(
<Text style={{ color: 'red' }} key={Math.random()}>
{tag!.text}
</Text>
)
children.push(<TagText text={tag!.text} />)
switch (tag!.type) {
case 'url':
contentLength = contentLength + 23