11/* eslint-disable react-native/no-inline-styles */
2- /* eslint-disable @typescript-eslint/no-explicit-any */
32
4- import React , { useCallback , useState , useMemo } from 'react' ;
3+ import { useCallback , useState } from 'react' ;
4+
55import {
66 StyleSheet ,
77 View ,
88 Text ,
99 StatusBar ,
1010 Image ,
11+ FlatList ,
1112 TouchableOpacity ,
1213} from 'react-native' ;
13- import { Palette , PencilLine , Swap } from '@/components/icons ' ;
14+ import { SafeAreaView } from 'react-native-safe-area-context ' ;
1415import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png' ;
15-
16+ import Swap from '@/components/icons/icons/Swap' ;
17+ import Acorn from '@/components/icons/icons/Acorn' ;
18+ import Palette from '@/components/icons/icons/Palette' ;
1619const 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 ) ;
1724
18- export default function HomeScreen ( ) {
19- const [ weightIdx , setWeightIdx ] = useState ( 2 ) ;
20-
21- const weight : IconWeight = useMemo (
22- ( ) => weights [ weightIdx ] as any ,
23- [ weightIdx ]
24- ) ;
25-
26- const handleChangeWeight = useCallback ( ( ) => {
27- setWeightIdx ( ( weightIdx + 1 ) % weights . length ) ;
28- } , [ weightIdx ] ) ;
29-
30- const handleChangeIconColor = useCallback ( ( ) => {
31- setIconColor ( `#${ Math . floor ( Math . random ( ) * 16777215 ) . toString ( 16 ) } ` ) ;
32- } , [ ] ) ;
33-
25+ const handleToggle = useCallback ( ( ) => {
26+ setToggleActive ( ! toggleActive ) ;
27+ } , [ toggleActive ] ) ;
3428 return (
3529 < View style = { styles . rootView } >
3630 < StatusBar barStyle = "light-content" />
37-
38- < View style = { styles . headerContainer } >
31+ < SafeAreaView style = { styles . headerContainer } >
3932 < View style = { styles . header } >
4033 < Image source = { PhosphorLogo } style = { styles . logoImage } />
4134 < View
@@ -54,26 +47,32 @@ export default function HomeScreen() {
5447 textTransform : 'capitalize' ,
5548 } }
5649 >
57- { weight }
50+ Single imports
5851 </ Text >
5952 </ View >
60- < TouchableOpacity
61- style = { styles . weightSelect }
62- onPress = { handleChangeIconColor }
63- >
64- < Palette color = "#FFF" weight = { weight } />
65- </ TouchableOpacity >
66- < TouchableOpacity
67- style = { styles . weightSelect }
68- onPress = { handleChangeWeight }
69- >
70- < PencilLine color = "#FFF" weight = { weight } />
71- </ TouchableOpacity >
72- < TouchableOpacity style = { styles . weightSelect } >
73- < Swap color = "#FFF" weight = { weight } />
53+ < TouchableOpacity style = { styles . weightSelect } onPress = { handleToggle } >
54+ < Swap color = "#FFF" weight = { 'regular' } />
7455 </ TouchableOpacity >
7556 </ View >
76- </ 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+ />
7776 </ View >
7877 ) ;
7978}
0 commit comments