11import * as React from 'react' ;
2- import { Animated , ScrollView , StyleSheet , View } from 'react-native' ;
2+ import { ScrollView , StyleSheet , View } from 'react-native' ;
33
44import { Surface , Text , Palette , List , IconButton } from 'react-native-paper' ;
55import type { Elevation } from 'react-native-paper' ;
@@ -12,19 +12,14 @@ const AnimatedSurface = () => {
1212 const [ index , setIndex ] = React . useState ( 3 ) ;
1313
1414 const level = elevationLevels [ index ] ;
15- const elevation = React . useRef ( new Animated . Value ( level ) ) . current ;
16-
17- React . useEffect ( ( ) => {
18- Animated . timing ( elevation , {
19- toValue : level ,
20- duration : 250 ,
21- useNativeDriver : false ,
22- } ) . start ( ) ;
23- } , [ elevation , level ] ) ;
2415
2516 return (
2617 < View style = { styles . scroll } >
27- < Surface style = { styles . surface } elevation = { elevation } >
18+ < Surface
19+ style = { styles . surface }
20+ contentStyle = { styles . surfaceContent }
21+ elevation = { level }
22+ >
2823 < Text variant = "bodySmall" > { `Elevation ${ level } ` } </ Text >
2924 </ Surface >
3025 < View style = { styles . actions } >
@@ -49,7 +44,13 @@ const SurfaceExample = () => {
4944 const elevationValues : Elevation [ ] = [ 0 , 1 , 2 , 3 , 4 , 5 ] ;
5045
5146 const renderSurface = ( index : Elevation , mode : 'flat' | 'elevated' ) => (
52- < Surface key = { index } style = { styles . surface } mode = { mode } elevation = { index } >
47+ < Surface
48+ key = { index }
49+ style = { styles . surface }
50+ contentStyle = { styles . surfaceContent }
51+ mode = { mode }
52+ elevation = { index }
53+ >
5354 < Text variant = "bodySmall" > { `Elevation ${ index } ` } </ Text >
5455 </ Surface >
5556 ) ;
@@ -93,10 +94,16 @@ const SurfaceExample = () => {
9394 </ Surface >
9495 </ View >
9596 < View style = { styles . verticalSurfacesContainer } >
96- < Surface style = { styles . verticalSurface } >
97+ < Surface
98+ style = { styles . verticalSurface }
99+ contentStyle = { styles . verticalSurfaceContent }
100+ >
97101 < Text style = { styles . centerText } > Top</ Text >
98102 </ Surface >
99- < Surface style = { styles . verticalSurface } >
103+ < Surface
104+ style = { styles . verticalSurface }
105+ contentStyle = { styles . verticalSurfaceContent }
106+ >
100107 < Text style = { styles . centerText } > Bottom</ Text >
101108 </ Surface >
102109 </ View >
@@ -122,6 +129,10 @@ const styles = StyleSheet.create({
122129 height : 120 ,
123130 width : 120 ,
124131 borderRadius : 8 ,
132+ } ,
133+ surfaceContent : {
134+ flex : 1 ,
135+ borderRadius : 8 ,
125136 alignItems : 'center' ,
126137 justifyContent : 'center' ,
127138 } ,
@@ -153,6 +164,9 @@ const styles = StyleSheet.create({
153164 } ,
154165 verticalSurface : {
155166 height : '48%' ,
167+ } ,
168+ verticalSurfaceContent : {
169+ flex : 1 ,
156170 justifyContent : 'center' ,
157171 } ,
158172
0 commit comments