1- import React from 'react' ;
2- import { Text , StyleSheet , Pressable } from 'react-native' ;
3- import { useNavigation } from '@react-navigation/native' ;
1+ import React from 'react'
42
5- import { ThemeContext } from '~/contexts/theme' ;
6- import CustomFlat from '~/components/lists/CustomFlat' ;
7- import size from '~/styles/size' ;
8- import mainStyles from '~/styles/main' ;
3+ import { ThemeContext } from '~/contexts/theme'
4+ import CustomFlat from '~/components/lists/CustomFlat'
5+ import GenreItem from '~/components/item/GenreItem'
6+ import size from '~/styles/size'
7+
8+ const colorBakcground = [
9+ '#FF5733' ,
10+ '#3357FF' ,
11+ '#FF33A1' ,
12+ '#A133FF' ,
13+ '#FF8F33' ,
14+ '#338FFF' ,
15+ '#FF33D4' ,
16+ '#D433FF' ,
17+ ]
918
1019const HorizontalGenres = ( { genres } ) => {
11- const navigation = useNavigation ( ) ;
1220 const theme = React . useContext ( ThemeContext )
1321
14- const renderItem = React . useCallback ( ( { item } ) => (
15- < Pressable
16- style = { ( { pressed } ) => ( [ mainStyles . opacity ( { pressed } ) , styles . genreBox ( theme ) ] ) }
17- onPress = { ( ) => navigation . navigate ( 'Genre' , { name : item . value , songCount : item . songCount , albumCount : item . albumCount } ) }
18- >
19- < Text numberOfLines = { 1 } style = { styles . genreText ( theme ) } > { item . value } </ Text >
20- </ Pressable >
22+ const renderItem = React . useCallback ( ( { item, index } ) => (
23+ < GenreItem genre = { item } color = { colorBakcground [ index % colorBakcground . length ] } />
2124 ) , [ theme ] )
2225
2326 return (
2427 < CustomFlat
25- style = { styles . genreList }
26- contentContainerStyle = { styles . scrollContainer }
2728 data = { genres }
2829 renderItem = { renderItem }
30+ widthItem = { size . image . large + 10 }
2931 />
3032 )
3133}
3234
33- const styles = StyleSheet . create ( {
34- genreList : {
35- width : '100%' ,
36- } ,
37- scrollContainer : {
38- height : 55 * 2 + 10 ,
39- paddingStart : 20 ,
40- paddingEnd : 20 ,
41- flexDirection : 'column' ,
42- flexWrap : 'wrap' ,
43- columnGap : 10 ,
44- rowGap : 10 ,
45- } ,
46- genreBox : theme => ( {
47- flex : 1 ,
48- height : 55 ,
49- borderRadius : 3 ,
50- paddingHorizontal : 40 ,
51- backgroundColor : theme . primaryTouch ,
52- justifyContent : 'center' ,
53- alignItems : 'center' ,
54- } ) ,
55- genreText : theme => ( {
56- color : theme . innerTouch ,
57- fontSize : size . text . large ,
58- fontWeight : 'bold' ,
59- } ) ,
60- } )
61-
62- export default HorizontalGenres ;
35+ export default HorizontalGenres
0 commit comments