11import React from 'react' ;
2- import { Dimensions , Text , TouchableOpacity , View } from "react-native" ;
2+ import { useWindowDimensions , Text , TouchableOpacity , View } from "react-native" ;
33import { getOpacity } from "../helpers/getOpacity" ;
44
5- const width = Dimensions . get ( 'window' ) . width ;
6-
75export default function StaticPills ( { data, style, x, currentIndex, onPillPress} ) {
6+ const width = useWindowDimensions ( ) . width ;
87 return (
98 < View style = { styles . container } >
109 { ! ! data ?. length && data . map ( ( item , index ) => (
1110 < View key = { index } >
12- < TouchableOpacity key = { index } onPress = { onPillPress ( index ) } style = { [
11+ < TouchableOpacity onPress = { onPillPress ( index ) } style = { [
1312 {
1413 paddingHorizontal : 5 ,
15- width : width / data . length - 20 ,
14+ width : width / data . length ,
1615 alignItems : 'center' ,
1716 } ,
1817 style ?. pillButton ,
@@ -26,8 +25,9 @@ export default function StaticPills({data, style, x, currentIndex, onPillPress})
2625 </ TouchableOpacity >
2726 < View style = { [
2827 {
28+ marginTop : 5 ,
2929 marginHorizontal : 10 ,
30- borderColor : 'white ' ,
30+ borderColor : 'red ' ,
3131 borderBottomWidth : 2 ,
3232 // for fade in and fade out animation
3333 opacity : getOpacity ( index , x ) ,
@@ -44,7 +44,6 @@ const styles = {
4444 container : {
4545 flexDirection : 'row' ,
4646 justifyContent : 'space-around' ,
47- width : width - 20 ,
4847 paddingBottom : 8 ,
4948 } ,
5049 pillLabel : {
@@ -54,8 +53,4 @@ const styles = {
5453 color : 'red' ,
5554 marginBottom : 10 ,
5655 } ,
57- activeBorder : {
58- borderColor : 'red' ,
59- borderBottomWidth : 2 ,
60- } ,
6156} ;
0 commit comments