Skip to content

Commit 0fa80e5

Browse files
christianbaroniosdnk
authored andcommitted
feat: add style prop (#1)
1 parent b603480 commit 0fa80e5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ However, there are few more additional props:
2727

2828
|Prop|Description|Platform|
2929
|-|:-----:|:---:|
30+
|`style: object`|Style to apply to ViewPager|both
3031
|`pageMargin: number`|Blank space to be shown between pages|both
3132
|`orientation: Orientation`|Set `horizontal` or `vertical` scrolling orientation (it does **not** work dynamically)|both
3233
|`transitionStyle: TransitionStyle`|Use `scroll` or `curl` to change transition style (it does **not** work dynamically)|iOS

src/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Keyboard } from 'react-native';
2+
import { Keyboard, StyleProp } from 'react-native';
33
import ViewPager from '@react-native-community/viewpager';
44
import Animated from 'react-native-reanimated';
55

@@ -29,6 +29,7 @@ type Props<T extends Route> = PagerCommonProps & {
2929
jumpTo: (key: string) => void;
3030
}
3131
) => React.ReactNode;
32+
style?: StyleProp<ViewStyle>;
3233
orientation?: 'vertical' | 'horizontal';
3334
transitionStyle?: 'scroll' | 'curl';
3435
showPageIndicator?: boolean;
@@ -148,6 +149,7 @@ export default class ViewPagerBackend<T extends Route> extends React.Component<
148149

149150
render() {
150151
const {
152+
style,
151153
keyboardDismissMode,
152154
swipeEnabled,
153155
children,
@@ -166,7 +168,7 @@ export default class ViewPagerBackend<T extends Route> extends React.Component<
166168
<AnimatedViewPager
167169
ref={this.ref}
168170
lazy={false}
169-
style={{ flex: 1 }}
171+
style={{ flex: 1, ...style }}
170172
initialPage={this.props.navigationState.index}
171173
keyboardDismissMode={
172174
// ViewPager does not accept auto mode

0 commit comments

Comments
 (0)