master 48fe527bcd2d cached
11 files
11.0 KB
3.0k tokens
1 symbols
1 requests
Download .txt
Repository: silentcloud/react-native-page-control
Branch: master
Commit: 48fe527bcd2d
Files: 11
Total size: 11.0 KB

Directory structure:
gitextract_0g9tg8ce/

├── .babelrc
├── .gitignore
├── .npmignore
├── LICENSE
├── PageControl.js
├── README.md
├── index.android.js
├── index.d.ts
├── index.ios.js
├── index.js
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .babelrc
================================================
{
  "presets": ["react-native"]
}


================================================
FILE: .gitignore
================================================
# OSX
#
.DS_Store
.idea

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
.idea
*.xcuserstate
project.xcworkspace

# node.js
#
node_modules/
npm-debug.log
yarn.lock
iOS
android


================================================
FILE: .npmignore
================================================
# OSX
#
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# node.js
#
node_modules/
npm-debug.log
iOS
android


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2015-2016 silentcloud

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



================================================
FILE: PageControl.js
================================================
var React = require('react');
var ReactNative = require('react-native');
var PropTypes = require('prop-types');
var createReactClass = require('create-react-class');

var { StyleSheet, View, TouchableWithoutFeedback, ViewPropTypes } = ReactNative;

var PageControl = createReactClass({
    propTypes: {
        numberOfPages: PropTypes.number.isRequired,
        currentPage: PropTypes.number,
        hidesForSinglePage: PropTypes.bool,
        pageIndicatorTintColor: PropTypes.string,
        currentPageIndicatorTintColor: PropTypes.string,
        indicatorSize: PropTypes.object,
        indicatorStyle: ViewPropTypes.style,
        currentIndicatorStyle: ViewPropTypes.style,
        onPageIndicatorPress: PropTypes.func
    },

    getDefaultProps: function () {
        return {
            numberOfPages: 0,
            currentPage: 0,
            hidesForSinglePage: false,
            pageIndicatorTintColor: 'gray',
            currentPageIndicatorTintColor: 'white',
            indicatorSize: {width: 8, height: 8},
            indicatorStyle: {},
            currentIndicatorStyle: {},
            onPageIndicatorPress: function() {}
        };
    },

    onPageIndicatorPress: function(idx) {
        this.props.onPageIndicatorPress(idx);
    },

    render: function () {
        var { style, ...props } = this.props;

        var defaultStyle = {
            height: this.props.indicatorSize.height
        };

        var indicatorItemStyle = {
            width: this.props.indicatorSize.width,
            height: this.props.indicatorSize.height,
            borderRadius: this.props.indicatorSize.height / 2,
            marginLeft: 5,
            marginRight: 5
        };

        var indicatorStyle = {
          ...indicatorItemStyle,
          ...this.props.indicatorStyle,
          ...{
            backgroundColor: this.props.pageIndicatorTintColor
          }
        };

        var currentIndicatorStyle = {
          ...indicatorItemStyle,
          ...this.props.currentIndicatorStyle,
          ...{
            backgroundColor: this.props.currentPageIndicatorTintColor
          }
        };

        var pages = [];
        for (var i = 0; i < this.props.numberOfPages; i++) {
            pages.push(i);
        }

        return (
          this.props.hidesForSinglePage && pages.length <= 1 ? null : <View style={[styles.container, defaultStyle, style]}>
            {pages.map((el, i) => <TouchableWithoutFeedback key={i} onPress={this.onPageIndicatorPress.bind(this, i)}>
              <View style={i == this.props.currentPage ? currentIndicatorStyle: indicatorStyle} />
            </TouchableWithoutFeedback>
            )}
          </View>
        );
    }
});

var styles = StyleSheet.create({
    container: {
        backgroundColor: 'transparent',
        alignItems: 'center',
        justifyContent: 'center',
        flexDirection: 'row'
    }
});

module.exports = PageControl;


================================================
FILE: README.md
================================================
# react-native-page-control

Page Control for React Native, like iOS UIPageControl, APIs are same as UIPageControl

## Installation

```bash
$ npm install react-native-page-control --save
```

## Demo

![page control demo](http://silentcloud.github.io/upload/pagecontrol.gif)

## Example

```jsx
import PageControl from 'react-native-page-control';

<PageControl
  style={{position:'absolute', left:0, right:0, bottom:10}}
  numberOfPages={3}
  currentPage={1}
  hidesForSinglePage
  pageIndicatorTintColor='gray'
  currentPageIndicatorTintColor='white'
  indicatorStyle={{borderRadius: 5}}
  currentIndicatorStyle={{borderRadius: 5}}
  indicatorSize={{width:8, height:8}}
  onPageIndicatorPress={this.onItemTap}
/>
```

## API (props)

| Prop | Required | Default  | Type | Description |
| :------------ |:---:|:---------------:| :---------------:| :-----|
| numberOfPages | YES | `0` | `number` | The number of pages the receiver shows (as dots) |
| currentPage | NO | `0` | `number` |The current page, shown by the receiver as a white dot |
| hidesForSinglePage | NO | `false` | `bool` | A Boolean value that controls whether the page control is hidden when there is only one page |
| pageIndicatorTintColor | NO | `gray` | `string` | The tint color to be used for the page indicator. |
| currentPageIndicatorTintColor | NO |`white` | `string`  | The tint color to be used for the current page indicator. |
| indicatorStyle | NO | `{}` | `object` | style for the page indicator |
| currentIndicatorStyle | NO |`{}` | `object`  | style for the current page indicator. |
| onPageIndicatorPress | NO | function(index){} | `func`  | page indicator press hook function. `param: index` current press indicator index|

## Development

  ```bash
  $ yarn
  $ npm run init
  $ npm run start
  $ react-native run-ios
  ```  


================================================
FILE: index.android.js
================================================
require('./index.ios');


================================================
FILE: index.d.ts
================================================
declare interface Props {
  /** Style for the current page indicator. */
  currentIndicatorStyle?: object

  /**
   * The current page, shown by the receiver as a white dot.
   *
   * @default 0
   */
  currentPage?: number

  /**
   * The tint color to be used for the page indicator.
   *
   * @default 'white'
   */
  currentPageIndicatorTintColor?: string

  /**
   * Whether the page control is hidden when there is only one page.
   *
   * @default false
   */
  hidesForSinglePage?: boolean

  /**
   * Size of the page indicator.
   *
   * @default { width: 8, height: 8 }
   */
  indicatorSize?: { width: number, height: number }

  /** Style for the page indicator. */
  indicatorStyle?: object

  /** The number of pages the receiver shows (as dots). */
  numberOfPages: number

  /** Callback when a specifc page indicator is pressed. */
  onPageIndicatorPress?: (index: number) => void

  /**
   * The tint color to be used for the page indicator.
   *
   * @default 'gray'
   */
  pageIndicatorTintColor?: string

  /** Style for the page control container. */
  style?: object
}

declare const PageControl: React.FC<Props>

export = PageControl


================================================
FILE: index.ios.js
================================================
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
  AppRegistry,
  ScrollView,
  StyleSheet,
  View,
  Text
} = ReactNative;
var screen = require('Dimensions').get('window');
var createReactClass = require('create-react-class');
var PageControl = require('./');

var PageControlDemo = createReactClass({
  getInitialState: function () {
    return {
      currentPage: 0
    };
  },
  onScroll: function(event){
    var offsetX = event.nativeEvent.contentOffset.x,
        pageWidth = screen.width - 10;
    this.setState({
      currentPage: Math.floor((offsetX - pageWidth / 2) / pageWidth) + 1
    });
  },
  onItemTap: function(index) {
    console.log(index);
  },
  render: function() {
    return (
      <View style={styles.container}>
        <View style={{backgroundColor:'red', width:screen.width - 10, marginLeft:5,height: 160}}>
          <ScrollView
            ref="ad"
            pagingEnabled
            horizontal
            showsHorizontalScrollIndicator={false}
            bounces={false}
            onScroll={this.onScroll}
            scrollEventThrottle={16}
          >
            <View style={{width:screen.width-10,  height:164}}>
              <Text>page1</Text>
            </View>
            <View style={{width:screen.width-10,  height:164,backgroundColor:'yellow'}}>
              <Text>page2</Text>
            </View>
            <View style={{width:screen.width-10,  height:164,backgroundColor:'blue'}}>
              <Text>page3</Text>
            </View>
          </ScrollView>
          <PageControl
            style={{ position:'absolute', left:0, right:0, bottom:10 }}
            numberOfPages={3} currentPage={this.state.currentPage}
            hidesForSinglePage
            pageIndicatorTintColor='gray'
            indicatorSize={{ width:8, height:8 }}
            currentPageIndicatorTintColor='black'
            onPageIndicatorPress={this.onItemTap}
          />
        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  scrollView: {
    backgroundColor:'yellow'
  }
});

AppRegistry.registerComponent('index', () => PageControlDemo);


================================================
FILE: index.js
================================================
var PageControl = require('./PageControl');

module.exports = PageControl;


================================================
FILE: package.json
================================================
{
  "name": "react-native-page-control",
  "version": "1.1.1",
  "description": "React native page control, like ios  UIPageControl",
  "author": "silentcloud",
  "repository": {
    "type": "git",
    "url": "https://github.com/silentcloud/react-native-page-control.git"
  },
  "keywords": [
    "react",
    "react-native",
    "react-component",
    "page-control",
    "PageControl",
    "UIPageControl"
  ],
  "files": [
    "index.d.ts",
    "index.js",
    "PageControl.js"
  ],
  "main": "index.js",
  "types": "index.d.ts",
  "readmeFilename": "README.md",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/silentcloud/react-native-page-control/issues"
  },
  "homepage": "https://github.com/silentcloud/react-native-page-control",
  "dependencies": {
    "create-react-class": "^15.6.0",
    "prop-types": "^15.5.10"
  },
  "devDependencies": {
    "babel-preset-react-native": "^2.1.0",
    "rc-tools": "6.x",
    "react": "^15.5.0",
    "react-dom": "^15.5.0",
    "react-native": "~0.42.0",
    "react-native-index-page": "~0.2.0"
  },
  "scripts": {
    "init": "rc-tools run react-native-init",
    "start": "react-native start"
  }
}
Download .txt
gitextract_0g9tg8ce/

├── .babelrc
├── .gitignore
├── .npmignore
├── LICENSE
├── PageControl.js
├── README.md
├── index.android.js
├── index.d.ts
├── index.ios.js
├── index.js
└── package.json
Download .txt
SYMBOL INDEX (1 symbols across 1 files)

FILE: index.d.ts
  type Props (line 1) | interface Props {
Condensed preview — 11 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (12K chars).
[
  {
    "path": ".babelrc",
    "chars": 34,
    "preview": "{\n  \"presets\": [\"react-native\"]\n}\n"
  },
  {
    "path": ".gitignore",
    "chars": 328,
    "preview": "# 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.mode2"
  },
  {
    "path": ".npmignore",
    "chars": 284,
    "preview": "# 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*.per"
  },
  {
    "path": "LICENSE",
    "chars": 1084,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2015-2016 silentcloud\n\nPermission is hereby granted, free of charge, to any person "
  },
  {
    "path": "PageControl.js",
    "chars": 2934,
    "preview": "var React = require('react');\nvar ReactNative = require('react-native');\nvar PropTypes = require('prop-types');\nvar crea"
  },
  {
    "path": "README.md",
    "chars": 1818,
    "preview": "# react-native-page-control\n\nPage Control for React Native, like iOS UIPageControl, APIs are same as UIPageControl\n\n## I"
  },
  {
    "path": "index.android.js",
    "chars": 24,
    "preview": "require('./index.ios');\n"
  },
  {
    "path": "index.d.ts",
    "chars": 1160,
    "preview": "declare interface Props {\n  /** Style for the current page indicator. */\n  currentIndicatorStyle?: object\n\n  /**\n   * Th"
  },
  {
    "path": "index.ios.js",
    "chars": 2327,
    "preview": "/**\n * Sample React Native App\n * https://github.com/facebook/react-native\n */\n'use strict';\n\nvar React = require('react"
  },
  {
    "path": "index.js",
    "chars": 75,
    "preview": "var PageControl = require('./PageControl');\n\nmodule.exports = PageControl;\n"
  },
  {
    "path": "package.json",
    "chars": 1163,
    "preview": "{\n  \"name\": \"react-native-page-control\",\n  \"version\": \"1.1.1\",\n  \"description\": \"React native page control, like ios  UI"
  }
]

About this extraction

This page contains the full source code of the silentcloud/react-native-page-control GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 11 files (11.0 KB), approximately 3.0k tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!