Skip to content

Commit b983027

Browse files
troZeeferrannp
authored andcommitted
fix: Rename ViewPagerAndroid to ViewPager (#64)
1 parent 1a922bf commit b983027

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

example/ViewPagerExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Image,
1717
SafeAreaView,
1818
} from 'react-native'
1919

20-
import ViewPagerAndroid from '@react-native-community/viewpager';
20+
import ViewPager from '@react-native-community/viewpager';
2121
import { PAGES, BGCOLOR, IMAGE_URIS, createPage } from "./utils";
2222
import { Button } from "./src/component/Button";
2323
import { LikeCount } from "./src/component/LikeCount";
@@ -39,7 +39,7 @@ type State = {
3939

4040
export default class ViewPagerExample extends React.Component<*, State> {
4141

42-
viewPager: React.Ref<typeof ViewPagerAndroid>;
42+
viewPager: React.Ref<typeof ViewPager>;
4343

4444
constructor(props: any) {
4545
super(props);
@@ -113,7 +113,7 @@ export default class ViewPagerExample extends React.Component<*, State> {
113113
const {page, pages, animationsAreEnabled} = this.state;
114114
return (
115115
<SafeAreaView style={styles.container}>
116-
<ViewPagerAndroid
116+
<ViewPager
117117
style={styles.viewPager}
118118
initialPage={0}
119119
scrollEnabled={this.state.scrollEnabled}
@@ -127,7 +127,7 @@ export default class ViewPagerExample extends React.Component<*, State> {
127127
transitionStyle="scroll"
128128
ref={this.viewPager}>
129129
{ pages.map( page => this.renderPage(page)) }
130-
</ViewPagerAndroid>
130+
</ViewPager>
131131
<View style={styles.buttons}>
132132
<Button
133133
enabled={true}

js/ViewPagerAndroid.js renamed to js/ViewPager.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const dismissKeyboard = require('react-native/Libraries/Utilities/dismissKeyboar
2727

2828
import {childrenWithOverriddenStyle} from "./utils";
2929

30-
const NativeAndroidViewPager = require('./AndroidViewPagerNativeComponent');
30+
const NativeViewPager = require('./ViewPagerNativeComponent');
3131

3232
const VIEW_PAGER_REF = 'viewPager';
3333
const VIEW_MANAGER_NAME = Platform.OS === 'android' ? 'AndroidViewPager' : 'RNCViewPager';
@@ -42,8 +42,8 @@ function getViewManagerConfig(viewManagerName) {
4242

4343
/**
4444
* Container that allows to flip left and right between child views. Each
45-
* child view of the `ViewPagerAndroid` will be treated as a separate page
46-
* and will be stretched to fill the `ViewPagerAndroid`.
45+
* child view of the `ViewPager` will be treated as a separate page
46+
* and will be stretched to fill the `ViewPager`.
4747
*
4848
* It is important all children are `<View>`s and not composite components.
4949
* You can set style properties like `padding` or `backgroundColor` for each
@@ -54,7 +54,7 @@ function getViewManagerConfig(viewManagerName) {
5454
* ```
5555
* render: function() {
5656
* return (
57-
* <ViewPagerAndroid
57+
* <ViewPager
5858
* style={styles.viewPager}
5959
* initialPage={0}>
6060
* <View style={styles.pageStyle} key="1">
@@ -63,7 +63,7 @@ function getViewManagerConfig(viewManagerName) {
6363
* <View style={styles.pageStyle} key="2">
6464
* <Text>Second page</Text>
6565
* </View>
66-
* </ViewPagerAndroid>
66+
* </ViewPager>
6767
* );
6868
* }
6969
*
@@ -82,7 +82,7 @@ function getViewManagerConfig(viewManagerName) {
8282
* ```
8383
*/
8484

85-
class ViewPagerAndroid extends React.Component<ViewPagerProps> {
85+
class ViewPager extends React.Component<ViewPagerProps> {
8686
componentDidMount() {
8787
// On iOS we do it directly on the native side
8888
if (Platform.OS === 'android') {
@@ -149,7 +149,7 @@ class ViewPagerAndroid extends React.Component<ViewPagerProps> {
149149

150150
render() {
151151
return (
152-
<NativeAndroidViewPager
152+
<NativeViewPager
153153
{...this.props}
154154
ref={VIEW_PAGER_REF}
155155
style={this.props.style}
@@ -162,4 +162,4 @@ class ViewPagerAndroid extends React.Component<ViewPagerProps> {
162162
}
163163
}
164164

165-
module.exports = ViewPagerAndroid;
165+
module.exports = ViewPager;
File renamed without changes.

js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export type PageSelectedEvent = _PageSelectedEvent;
2121
export type TransitionStyle = _TransitionStyle;
2222
export type Orientation = _Orientation;
2323

24-
module.exports = require('./ViewPagerAndroid');
24+
module.exports = require('./ViewPager');

typings/index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import * as React from "react";
22
import * as ReactNative from "react-native";
33

4-
export interface ViewPagerAndroidOnPageScrollEventData {
4+
export interface ViewPagerOnPageScrollEventData {
55
position: number;
66
offset: number;
77
}
88

9-
export interface ViewPagerAndroidOnPageSelectedEventData {
9+
export interface ViewPagerOnPageSelectedEventData {
1010
position: number;
1111
}
1212

13-
export interface ViewPagerAndroidProps extends ReactNative.ViewProps {
13+
export interface ViewPagerProps extends ReactNative.ViewProps {
1414
/**
1515
* Index of initial page that should be selected. Use `setPage` method to
1616
* update the page, and `onPageSelected` to monitor page changes
@@ -32,15 +32,15 @@ export interface ViewPagerAndroidProps extends ReactNative.ViewProps {
3232
* Value x means that (1 - x) fraction of the page at "position" index is
3333
* visible, and x fraction of the next page is visible.
3434
*/
35-
onPageScroll?: (event: ReactNative.NativeSyntheticEvent<ViewPagerAndroidOnPageScrollEventData>) => void;
35+
onPageScroll?: (event: ReactNative.NativeSyntheticEvent<ViewPagerOnPageScrollEventData>) => void;
3636

3737
/**
3838
* This callback will be called once ViewPager finish navigating to selected page
3939
* (when user swipes between pages). The `event.nativeEvent` object passed to this
4040
* callback will have following fields:
4141
* - position - index of page that has been selected
4242
*/
43-
onPageSelected?: (event: ReactNative.NativeSyntheticEvent<ViewPagerAndroidOnPageSelectedEventData>) => void;
43+
onPageSelected?: (event: ReactNative.NativeSyntheticEvent<ViewPagerOnPageSelectedEventData>) => void;
4444

4545
/**
4646
* Function called when the page scrolling state has changed.
@@ -66,9 +66,9 @@ export interface ViewPagerAndroidProps extends ReactNative.ViewProps {
6666
pageMargin?: number;
6767
}
6868

69-
declare class ViewPagerAndroidComponent extends React.Component<ViewPagerAndroidProps> {}
70-
declare const ViewPagerAndroidBase: ReactNative.Constructor<ReactNative.NativeMethodsMixin> & typeof ViewPagerAndroidComponent;
71-
export default class ViewPagerAndroid extends ViewPagerAndroidBase {
69+
declare class ViewPagerComponent extends React.Component<ViewPagerProps> {}
70+
declare const ViewPagerBase: ReactNative.Constructor<ReactNative.NativeMethodsMixin> & typeof ViewPagerComponent;
71+
export default class ViewPager extends ViewPagerBase {
7272
/**
7373
* A helper function to scroll to a specific page in the ViewPager.
7474
* The transition between pages will be animated.

0 commit comments

Comments
 (0)