|
| 1 | +'use strict'; |
| 2 | +import {Text, View, StyleSheet, PlatformColor} from 'react-native'; |
| 3 | +import React from 'react'; |
| 4 | +import {useTheme} from '../Navigation'; |
| 5 | +import {ScreenWrapper} from '../components/ScreenWrapper'; |
| 6 | + |
| 7 | +/** |
| 8 | + * This page demonstrates new parity props that works in Fabric. |
| 9 | + */ |
| 10 | +export const NewParityPropsPage: React.FunctionComponent<{}> = () => { |
| 11 | + const {colors} = useTheme(); |
| 12 | + |
| 13 | + const styles = StyleSheet.create({ |
| 14 | + container: { |
| 15 | + flex: 1, |
| 16 | + padding: 20, |
| 17 | + }, |
| 18 | + title: { |
| 19 | + fontSize: 28, |
| 20 | + fontWeight: '600', |
| 21 | + color: PlatformColor('TextControlForeground'), |
| 22 | + marginBottom: 8, |
| 23 | + }, |
| 24 | + description: { |
| 25 | + fontSize: 14, |
| 26 | + color: PlatformColor('TextControlForeground'), |
| 27 | + marginBottom: 24, |
| 28 | + opacity: 0.8, |
| 29 | + }, |
| 30 | + section: { |
| 31 | + marginBottom: 24, |
| 32 | + padding: 16, |
| 33 | + backgroundColor: colors.card, |
| 34 | + borderRadius: 8, |
| 35 | + borderWidth: 1, |
| 36 | + borderColor: colors.border, |
| 37 | + }, |
| 38 | + sectionTitle: { |
| 39 | + fontSize: 18, |
| 40 | + fontWeight: '600', |
| 41 | + color: PlatformColor('TextControlForeground'), |
| 42 | + marginBottom: 12, |
| 43 | + }, |
| 44 | + textItem: { |
| 45 | + marginBottom: 12, |
| 46 | + }, |
| 47 | + label: { |
| 48 | + fontSize: 12, |
| 49 | + color: PlatformColor('TextControlForeground'), |
| 50 | + opacity: 0.6, |
| 51 | + marginBottom: 4, |
| 52 | + }, |
| 53 | + selectableText: { |
| 54 | + fontSize: 16, |
| 55 | + color: PlatformColor('TextControlForeground'), |
| 56 | + }, |
| 57 | + codeText: { |
| 58 | + fontFamily: 'Consolas', |
| 59 | + fontSize: 12, |
| 60 | + color: colors.primary, |
| 61 | + backgroundColor: colors.border, |
| 62 | + padding: 8, |
| 63 | + borderRadius: 4, |
| 64 | + marginTop: 8, |
| 65 | + }, |
| 66 | + }); |
| 67 | + |
| 68 | + return ( |
| 69 | + <ScreenWrapper> |
| 70 | + <View style={styles.container}> |
| 71 | + <Text style={styles.title}>New Parity Props</Text> |
| 72 | + <Text style={styles.description}> |
| 73 | + This page demonstrates newly implemented parity props for Fabric. |
| 74 | + Text selection examples are placed outside ScrollView for proper functionality. |
| 75 | + </Text> |
| 76 | + |
| 77 | + {/* Text Selection Section */} |
| 78 | + <View style={styles.section}> |
| 79 | + <Text style={styles.sectionTitle}>Text Selection (selectable prop)</Text> |
| 80 | + |
| 81 | + <View style={styles.textItem}> |
| 82 | + <Text style={styles.label}>Basic selectable text:</Text> |
| 83 | + <Text selectable={true} style={styles.selectableText}> |
| 84 | + This text is selectable. Click and drag to select, or double-click to select a word. |
| 85 | + </Text> |
| 86 | + </View> |
| 87 | + |
| 88 | + <View style={styles.textItem}> |
| 89 | + <Text style={styles.label}>CJK word selection:</Text> |
| 90 | + <Text selectable={true} style={styles.selectableText}> |
| 91 | + Hello 世界世界 World - Double-click to test CJK word boundaries! |
| 92 | + </Text> |
| 93 | + </View> |
| 94 | + |
| 95 | + <View style={styles.textItem}> |
| 96 | + <Text style={styles.label}>Non-selectable text:</Text> |
| 97 | + <Text selectable={false} style={[styles.selectableText, {opacity: 0.7}]}> |
| 98 | + This text is NOT selectable (selectable=false). |
| 99 | + </Text> |
| 100 | + </View> |
| 101 | + |
| 102 | + <Text style={styles.codeText}> |
| 103 | + {'<Text selectable={true}>Selectable text</Text>'} |
| 104 | + </Text> |
| 105 | + </View> |
| 106 | + |
| 107 | + {/* Selection Color Section */} |
| 108 | + <View style={styles.section}> |
| 109 | + <Text style={styles.sectionTitle}>Selection Color (selectionColor prop)</Text> |
| 110 | + |
| 111 | + <View style={styles.textItem}> |
| 112 | + <Text style={styles.label}>Red selection color:</Text> |
| 113 | + <Text selectable={true} selectionColor="red" style={styles.selectableText}> |
| 114 | + Select this text to see red highlight! |
| 115 | + </Text> |
| 116 | + </View> |
| 117 | + |
| 118 | + <View style={styles.textItem}> |
| 119 | + <Text style={styles.label}>Green selection color (#00FF00):</Text> |
| 120 | + <Text selectable={true} selectionColor="#00FF00" style={styles.selectableText}> |
| 121 | + Select this text to see green highlight! |
| 122 | + </Text> |
| 123 | + </View> |
| 124 | + |
| 125 | + <View style={styles.textItem}> |
| 126 | + <Text style={styles.label}>Orange with 50% opacity:</Text> |
| 127 | + <Text selectable={true} selectionColor="rgba(255, 165, 0, 0.5)" style={styles.selectableText}> |
| 128 | + Select this text to see semi-transparent orange highlight! |
| 129 | + </Text> |
| 130 | + </View> |
| 131 | + |
| 132 | + <View style={styles.textItem}> |
| 133 | + <Text style={styles.label}>Default selection color:</Text> |
| 134 | + <Text selectable={true} style={styles.selectableText}> |
| 135 | + No selectionColor prop - uses system default (Windows accent color). |
| 136 | + </Text> |
| 137 | + </View> |
| 138 | + |
| 139 | + <Text style={styles.codeText}> |
| 140 | + {'<Text selectable={true} selectionColor="red">Red highlight</Text>'} |
| 141 | + </Text> |
| 142 | + </View> |
| 143 | + </View> |
| 144 | + </ScreenWrapper> |
| 145 | + ); |
| 146 | +}; |
0 commit comments