[
  {
    "path": ".babelrc",
    "content": "{\n  \"presets\": [\"react-native\"]\n}\n"
  },
  {
    "path": ".gitignore",
    "content": "# OSX\n#\n.DS_Store\n.idea\n\n# Xcode\n#\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\n*.moved-aside\nDerivedData\n*.hmap\n*.ipa\n.idea\n*.xcuserstate\nproject.xcworkspace\n\n# node.js\n#\nnode_modules/\nnpm-debug.log\nyarn.lock\niOS\nandroid\n"
  },
  {
    "path": ".npmignore",
    "content": "# OSX\n#\n.DS_Store\n\n# Xcode\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\n*.moved-aside\nDerivedData\n*.hmap\n*.ipa\n*.xcuserstate\n\n# node.js\n#\nnode_modules/\nnpm-debug.log\niOS\nandroid\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015-2016 silentcloud\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "PageControl.js",
    "content": "var React = require('react');\nvar ReactNative = require('react-native');\nvar PropTypes = require('prop-types');\nvar createReactClass = require('create-react-class');\n\nvar { StyleSheet, View, TouchableWithoutFeedback, ViewPropTypes } = ReactNative;\n\nvar PageControl = createReactClass({\n    propTypes: {\n        numberOfPages: PropTypes.number.isRequired,\n        currentPage: PropTypes.number,\n        hidesForSinglePage: PropTypes.bool,\n        pageIndicatorTintColor: PropTypes.string,\n        currentPageIndicatorTintColor: PropTypes.string,\n        indicatorSize: PropTypes.object,\n        indicatorStyle: ViewPropTypes.style,\n        currentIndicatorStyle: ViewPropTypes.style,\n        onPageIndicatorPress: PropTypes.func\n    },\n\n    getDefaultProps: function () {\n        return {\n            numberOfPages: 0,\n            currentPage: 0,\n            hidesForSinglePage: false,\n            pageIndicatorTintColor: 'gray',\n            currentPageIndicatorTintColor: 'white',\n            indicatorSize: {width: 8, height: 8},\n            indicatorStyle: {},\n            currentIndicatorStyle: {},\n            onPageIndicatorPress: function() {}\n        };\n    },\n\n    onPageIndicatorPress: function(idx) {\n        this.props.onPageIndicatorPress(idx);\n    },\n\n    render: function () {\n        var { style, ...props } = this.props;\n\n        var defaultStyle = {\n            height: this.props.indicatorSize.height\n        };\n\n        var indicatorItemStyle = {\n            width: this.props.indicatorSize.width,\n            height: this.props.indicatorSize.height,\n            borderRadius: this.props.indicatorSize.height / 2,\n            marginLeft: 5,\n            marginRight: 5\n        };\n\n        var indicatorStyle = {\n          ...indicatorItemStyle,\n          ...this.props.indicatorStyle,\n          ...{\n            backgroundColor: this.props.pageIndicatorTintColor\n          }\n        };\n\n        var currentIndicatorStyle = {\n          ...indicatorItemStyle,\n          ...this.props.currentIndicatorStyle,\n          ...{\n            backgroundColor: this.props.currentPageIndicatorTintColor\n          }\n        };\n\n        var pages = [];\n        for (var i = 0; i < this.props.numberOfPages; i++) {\n            pages.push(i);\n        }\n\n        return (\n          this.props.hidesForSinglePage && pages.length <= 1 ? null : <View style={[styles.container, defaultStyle, style]}>\n            {pages.map((el, i) => <TouchableWithoutFeedback key={i} onPress={this.onPageIndicatorPress.bind(this, i)}>\n              <View style={i == this.props.currentPage ? currentIndicatorStyle: indicatorStyle} />\n            </TouchableWithoutFeedback>\n            )}\n          </View>\n        );\n    }\n});\n\nvar styles = StyleSheet.create({\n    container: {\n        backgroundColor: 'transparent',\n        alignItems: 'center',\n        justifyContent: 'center',\n        flexDirection: 'row'\n    }\n});\n\nmodule.exports = PageControl;\n"
  },
  {
    "path": "README.md",
    "content": "# react-native-page-control\n\nPage Control for React Native, like iOS UIPageControl, APIs are same as UIPageControl\n\n## Installation\n\n```bash\n$ npm install react-native-page-control --save\n```\n\n## Demo\n\n![page control demo](http://silentcloud.github.io/upload/pagecontrol.gif)\n\n## Example\n\n```jsx\nimport PageControl from 'react-native-page-control';\n\n<PageControl\n  style={{position:'absolute', left:0, right:0, bottom:10}}\n  numberOfPages={3}\n  currentPage={1}\n  hidesForSinglePage\n  pageIndicatorTintColor='gray'\n  currentPageIndicatorTintColor='white'\n  indicatorStyle={{borderRadius: 5}}\n  currentIndicatorStyle={{borderRadius: 5}}\n  indicatorSize={{width:8, height:8}}\n  onPageIndicatorPress={this.onItemTap}\n/>\n```\n\n## API (props)\n\n| Prop | Required | Default  | Type | Description |\n| :------------ |:---:|:---------------:| :---------------:| :-----|\n| numberOfPages | YES | `0` | `number` | The number of pages the receiver shows (as dots) |\n| currentPage | NO | `0` | `number` |The current page, shown by the receiver as a white dot |\n| hidesForSinglePage | NO | `false` | `bool` | A Boolean value that controls whether the page control is hidden when there is only one page |\n| pageIndicatorTintColor | NO | `gray` | `string` | The tint color to be used for the page indicator. |\n| currentPageIndicatorTintColor | NO |`white` | `string`  | The tint color to be used for the current page indicator. |\n| indicatorStyle | NO | `{}` | `object` | style for the page indicator |\n| currentIndicatorStyle | NO |`{}` | `object`  | style for the current page indicator. |\n| onPageIndicatorPress | NO | function(index){} | `func`  | page indicator press hook function. `param: index` current press indicator index|\n\n## Development\n\n  ```bash\n  $ yarn\n  $ npm run init\n  $ npm run start\n  $ react-native run-ios\n  ```  \n"
  },
  {
    "path": "index.android.js",
    "content": "require('./index.ios');\n"
  },
  {
    "path": "index.d.ts",
    "content": "declare interface Props {\n  /** Style for the current page indicator. */\n  currentIndicatorStyle?: object\n\n  /**\n   * The current page, shown by the receiver as a white dot.\n   *\n   * @default 0\n   */\n  currentPage?: number\n\n  /**\n   * The tint color to be used for the page indicator.\n   *\n   * @default 'white'\n   */\n  currentPageIndicatorTintColor?: string\n\n  /**\n   * Whether the page control is hidden when there is only one page.\n   *\n   * @default false\n   */\n  hidesForSinglePage?: boolean\n\n  /**\n   * Size of the page indicator.\n   *\n   * @default { width: 8, height: 8 }\n   */\n  indicatorSize?: { width: number, height: number }\n\n  /** Style for the page indicator. */\n  indicatorStyle?: object\n\n  /** The number of pages the receiver shows (as dots). */\n  numberOfPages: number\n\n  /** Callback when a specifc page indicator is pressed. */\n  onPageIndicatorPress?: (index: number) => void\n\n  /**\n   * The tint color to be used for the page indicator.\n   *\n   * @default 'gray'\n   */\n  pageIndicatorTintColor?: string\n\n  /** Style for the page control container. */\n  style?: object\n}\n\ndeclare const PageControl: React.FC<Props>\n\nexport = PageControl\n"
  },
  {
    "path": "index.ios.js",
    "content": "/**\n * Sample React Native App\n * https://github.com/facebook/react-native\n */\n'use strict';\n\nvar React = require('react');\nvar ReactNative = require('react-native');\nvar {\n  AppRegistry,\n  ScrollView,\n  StyleSheet,\n  View,\n  Text\n} = ReactNative;\nvar screen = require('Dimensions').get('window');\nvar createReactClass = require('create-react-class');\nvar PageControl = require('./');\n\nvar PageControlDemo = createReactClass({\n  getInitialState: function () {\n    return {\n      currentPage: 0\n    };\n  },\n  onScroll: function(event){\n    var offsetX = event.nativeEvent.contentOffset.x,\n        pageWidth = screen.width - 10;\n    this.setState({\n      currentPage: Math.floor((offsetX - pageWidth / 2) / pageWidth) + 1\n    });\n  },\n  onItemTap: function(index) {\n    console.log(index);\n  },\n  render: function() {\n    return (\n      <View style={styles.container}>\n        <View style={{backgroundColor:'red', width:screen.width - 10, marginLeft:5,height: 160}}>\n          <ScrollView\n            ref=\"ad\"\n            pagingEnabled\n            horizontal\n            showsHorizontalScrollIndicator={false}\n            bounces={false}\n            onScroll={this.onScroll}\n            scrollEventThrottle={16}\n          >\n            <View style={{width:screen.width-10,  height:164}}>\n              <Text>page1</Text>\n            </View>\n            <View style={{width:screen.width-10,  height:164,backgroundColor:'yellow'}}>\n              <Text>page2</Text>\n            </View>\n            <View style={{width:screen.width-10,  height:164,backgroundColor:'blue'}}>\n              <Text>page3</Text>\n            </View>\n          </ScrollView>\n          <PageControl\n            style={{ position:'absolute', left:0, right:0, bottom:10 }}\n            numberOfPages={3} currentPage={this.state.currentPage}\n            hidesForSinglePage\n            pageIndicatorTintColor='gray'\n            indicatorSize={{ width:8, height:8 }}\n            currentPageIndicatorTintColor='black'\n            onPageIndicatorPress={this.onItemTap}\n          />\n        </View>\n      </View>\n    );\n  }\n});\n\nvar styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    justifyContent: 'center',\n    alignItems: 'center'\n  },\n  scrollView: {\n    backgroundColor:'yellow'\n  }\n});\n\nAppRegistry.registerComponent('index', () => PageControlDemo);\n"
  },
  {
    "path": "index.js",
    "content": "var PageControl = require('./PageControl');\n\nmodule.exports = PageControl;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"react-native-page-control\",\n  \"version\": \"1.1.1\",\n  \"description\": \"React native page control, like ios  UIPageControl\",\n  \"author\": \"silentcloud\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/silentcloud/react-native-page-control.git\"\n  },\n  \"keywords\": [\n    \"react\",\n    \"react-native\",\n    \"react-component\",\n    \"page-control\",\n    \"PageControl\",\n    \"UIPageControl\"\n  ],\n  \"files\": [\n    \"index.d.ts\",\n    \"index.js\",\n    \"PageControl.js\"\n  ],\n  \"main\": \"index.js\",\n  \"types\": \"index.d.ts\",\n  \"readmeFilename\": \"README.md\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/silentcloud/react-native-page-control/issues\"\n  },\n  \"homepage\": \"https://github.com/silentcloud/react-native-page-control\",\n  \"dependencies\": {\n    \"create-react-class\": \"^15.6.0\",\n    \"prop-types\": \"^15.5.10\"\n  },\n  \"devDependencies\": {\n    \"babel-preset-react-native\": \"^2.1.0\",\n    \"rc-tools\": \"6.x\",\n    \"react\": \"^15.5.0\",\n    \"react-dom\": \"^15.5.0\",\n    \"react-native\": \"~0.42.0\",\n    \"react-native-index-page\": \"~0.2.0\"\n  },\n  \"scripts\": {\n    \"init\": \"rc-tools run react-native-init\",\n    \"start\": \"react-native start\"\n  }\n}\n"
  }
]