|
| 1 | +/* eslint-disable react-native/no-inline-styles */ |
| 2 | + |
| 3 | +import { useCallback, useState } from 'react'; |
| 4 | + |
| 5 | +import { |
| 6 | + StyleSheet, |
| 7 | + View, |
| 8 | + Text, |
| 9 | + StatusBar, |
| 10 | + Image, |
| 11 | + FlatList, |
| 12 | + TouchableOpacity, |
| 13 | +} from 'react-native'; |
| 14 | +import { SafeAreaView } from 'react-native-safe-area-context'; |
| 15 | +import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png'; |
| 16 | +import Swap from '@/components/icons/icons/Swap'; |
| 17 | +import Acorn from '@/components/icons/icons/Acorn'; |
| 18 | +import Palette from '@/components/icons/icons/Palette'; |
| 19 | +const weights = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone']; |
| 20 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 21 | +const singleIcons = [Acorn, Palette, Swap] |
| 22 | +export default function SingleImportsScreen() { |
| 23 | + const [toggleActive, setToggleActive] = useState(false); |
| 24 | + |
| 25 | + const handleToggle = useCallback(() => { |
| 26 | + setToggleActive(!toggleActive); |
| 27 | + }, [toggleActive]); |
| 28 | + return ( |
| 29 | + <View style={styles.rootView}> |
| 30 | + <StatusBar barStyle="light-content" /> |
| 31 | + <SafeAreaView style={styles.headerContainer}> |
| 32 | + <View style={styles.header}> |
| 33 | + <Image source={PhosphorLogo} style={styles.logoImage} /> |
| 34 | + <View |
| 35 | + style={{ |
| 36 | + flex: 1, |
| 37 | + alignItems: 'flex-start', |
| 38 | + justifyContent: 'center', |
| 39 | + paddingStart: 10, |
| 40 | + }} |
| 41 | + > |
| 42 | + <Text style={styles.headerText}>Phosphor React Native</Text> |
| 43 | + <Text |
| 44 | + style={{ |
| 45 | + color: '#fff', |
| 46 | + opacity: 0.8, |
| 47 | + textTransform: 'capitalize', |
| 48 | + }} |
| 49 | + > |
| 50 | + Single imports |
| 51 | + </Text> |
| 52 | + </View> |
| 53 | + <TouchableOpacity style={styles.weightSelect} onPress={handleToggle}> |
| 54 | + <Swap color="#FFF" weight={'regular'} /> |
| 55 | + </TouchableOpacity> |
| 56 | + </View> |
| 57 | + </SafeAreaView> |
| 58 | + <FlatList |
| 59 | + style={styles.scrollView} |
| 60 | + contentContainerStyle={styles.main} |
| 61 | + data={singleIcons} |
| 62 | + keyExtractor={(item) => item} |
| 63 | + numColumns={3} |
| 64 | + renderItem={({ item: Icon }) => ( |
| 65 | + <View style={styles.iconItem}> |
| 66 | + <Icon |
| 67 | + size={48} |
| 68 | + weight={weights[Math.floor(Math.random() * 6)]} |
| 69 | + color={`#${Math.floor(Math.random() * 16777215).toString(16)}`} |
| 70 | + duotoneColor={`#${Math.floor(Math.random() * 16777215).toString(16)}`} |
| 71 | + duotoneOpacity={Math.random()} |
| 72 | + /> |
| 73 | + </View> |
| 74 | + )} |
| 75 | + /> |
| 76 | + </View> |
| 77 | + ); |
| 78 | +} |
| 79 | + |
| 80 | +const styles = StyleSheet.create({ |
| 81 | + rootView: { |
| 82 | + flex: 1, |
| 83 | + backgroundColor: '#FFF', |
| 84 | + }, |
| 85 | + headerContainer: { |
| 86 | + backgroundColor: '#e76f51', |
| 87 | + }, |
| 88 | + header: { |
| 89 | + backgroundColor: '#e76f51', |
| 90 | + alignItems: 'center', |
| 91 | + justifyContent: 'center', |
| 92 | + flexDirection: 'row', |
| 93 | + paddingBottom: 16, |
| 94 | + paddingHorizontal: 16, |
| 95 | + }, |
| 96 | + logoImage: { |
| 97 | + width: 40, |
| 98 | + height: 40, |
| 99 | + borderRadius: 20, |
| 100 | + }, |
| 101 | + headerText: { |
| 102 | + color: '#FFF', |
| 103 | + fontSize: 18, |
| 104 | + fontWeight: 'bold', |
| 105 | + flex: 1, |
| 106 | + textAlign: 'center', |
| 107 | + }, |
| 108 | + weightSelect: { |
| 109 | + width: 35, |
| 110 | + }, |
| 111 | + scrollView: { |
| 112 | + flex: 1, |
| 113 | + }, |
| 114 | + main: { |
| 115 | + backgroundColor: 'white', |
| 116 | + paddingHorizontal: 8, |
| 117 | + paddingBottom: 16, |
| 118 | + }, |
| 119 | + iconItem: { |
| 120 | + width: '33%', |
| 121 | + height: 100, |
| 122 | + alignItems: 'center', |
| 123 | + justifyContent: 'center', |
| 124 | + padding: 8, |
| 125 | + }, |
| 126 | + iconName: { |
| 127 | + textAlign: 'center', |
| 128 | + opacity: 0.8, |
| 129 | + marginTop: 4, |
| 130 | + }, |
| 131 | +}); |
0 commit comments