11/* eslint-disable react-native/no-inline-styles */
22import * as React from 'react' ;
3- import { Dimensions , Image , ImageSourcePropType , View } from 'react-native' ;
3+ import {
4+ Button ,
5+ Dimensions ,
6+ Image ,
7+ ImageSourcePropType ,
8+ View ,
9+ } from 'react-native' ;
410import Carousel from '../../src/index' ;
511import type { ICarouselInstance } from '../../src/Carousel' ;
612import Animated , {
@@ -10,7 +16,7 @@ import Animated, {
1016 useSharedValue ,
1117} from 'react-native-reanimated' ;
1218
13- const { width } = Dimensions . get ( 'window' ) ;
19+ const window = Dimensions . get ( 'window' ) ;
1420
1521const data : ImageSourcePropType [ ] = [
1622 require ( '../assets/carousel-0.jpg' ) ,
@@ -30,11 +36,11 @@ export default function App() {
3036 paddingTop : 100 ,
3137 } }
3238 >
33- < View style = { { height : 300 } } >
39+ < View style = { { height : 240 } } >
3440 < Carousel < ImageSourcePropType >
3541 defaultIndex = { 1 }
3642 ref = { r }
37- width = { width }
43+ width = { window . width }
3844 data = { data }
3945 parallaxScrollingScale = { 0.8 }
4046 renderItem = { ( source ) => (
@@ -50,13 +56,13 @@ export default function App() {
5056 ) }
5157 />
5258 </ View >
53- < View style = { { height : 300 } } >
59+ < View style = { { height : 240 } } >
5460 < Carousel < ImageSourcePropType >
5561 onProgressChange = { ( _ , absoluteProgress ) => {
5662 progressValue . value = absoluteProgress ;
5763 } }
5864 mode = "parallax"
59- width = { width }
65+ width = { window . width }
6066 data = { data }
6167 parallaxScrollingScale = { 0.8 }
6268 renderItem = { ( source ) => (
@@ -92,6 +98,16 @@ export default function App() {
9298 } ) }
9399 </ View >
94100 ) }
101+ < View
102+ style = { {
103+ marginTop : 24 ,
104+ flexDirection : 'row' ,
105+ justifyContent : 'space-evenly' ,
106+ } }
107+ >
108+ < Button title = "Prev" onPress = { ( ) => r . current ?. prev ( ) } />
109+ < Button title = "Next" onPress = { ( ) => r . current ?. next ( ) } />
110+ </ View >
95111 </ View >
96112 </ View >
97113 ) ;
0 commit comments