Skip to content

Commit

Permalink
feat: optimize selectable text
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoliao666 committed Oct 3, 2023
1 parent 7d54c01 commit 37c2ed9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.liaoliao666.v2ex",
"buildNumber": "1.5.1.1"
"buildNumber": "1.5.1.2"
},
"android": {
"adaptiveIcon": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"expo-device": "~5.4.0",
"expo-file-system": "~15.4.4",
"expo-font": "~11.4.0",
"expo-image": "~1.3.3",
"expo-image": "~1.3.4",
"expo-image-manipulator": "~11.3.0",
"expo-image-picker": "~14.3.2",
"expo-linking": "~5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion screens/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export default function LoginScreen() {
)}
/>

{(Platform.OS === 'android' || dayjs().isAfter('2023-9-30')) && (
{(Platform.OS === 'android' || dayjs().isAfter('2023-10-06')) && (
<TouchableOpacity
style={tw`w-full mt-4 flex-row justify-center items-center h-[52px] px-8`}
onPress={() => {
Expand Down
19 changes: 17 additions & 2 deletions screens/SelectableTextScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import { RouteProp, useRoute } from '@react-navigation/native'
import { ScrollView, TextInput, View } from 'react-native'
import { createContext, useContext } from 'react'
import { ScrollView, Text, TextInput, View } from 'react-native'
import {
CustomTextualRenderer,
getNativePropsForTNode,
} from 'react-native-render-html'
import { SafeAreaView } from 'react-native-safe-area-context'

import Html from '@/components/Html'
import NavBar from '@/components/NavBar'
import { RootStackParamList } from '@/types'
import tw from '@/utils/tw'

const IsNestedTextContext = createContext(false)

const TextRenderer: CustomTextualRenderer = props => {
const renderProps = getNativePropsForTNode(props)

const isNestedText = useContext(IsNestedTextContext)

if (isNestedText) return <Text {...renderProps} />

return (
<TextInput {...getNativePropsForTNode(props)} multiline editable={false} />
<IsNestedTextContext.Provider value={true}>
<TextInput editable={false} multiline>
<Text {...renderProps} />
</TextInput>
</IsNestedTextContext.Provider>
)
}

Expand All @@ -32,6 +46,7 @@ export default function SelectableTextScreen() {
_TEXT_: TextRenderer,
}}
/>
<SafeAreaView edges={['bottom']} />
</ScrollView>
</View>
)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4332,10 +4332,10 @@ expo-image-picker@~14.3.2:
dependencies:
expo-image-loader "~4.3.0"

expo-image@~1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/expo-image/-/expo-image-1.3.3.tgz#16884056a6c379d516cae7e4b0f9eb245bec81d5"
integrity sha512-H/w/4XGPRrOv8PsBnoVrctLKtsLYhavrhTK/SkizF3F5u81aHItBACgV8HVrh1qzPXbP40hp/Oyua/ttz61zMQ==
expo-image@~1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/expo-image/-/expo-image-1.3.4.tgz#50f8468b118972698a4382853773db2f39e46190"
integrity sha512-2N6etMJA5OWbbvL9IdPVchNoJd18kVo5gcN4uC9Xtv1VM/ik6PRB3Tz+qP/0Uglkzh/yyJjw7aDTqWozj5nLZw==

expo-json-utils@~0.7.0:
version "0.7.1"
Expand Down

0 comments on commit 37c2ed9

Please sign in to comment.