Skip to content

Commit cd07503

Browse files
committed
summed up the libaray, added example app.
1 parent 9bb6bc7 commit cd07503

31 files changed

+27252
-27
lines changed

.circleci/scripts/wait-for-avd.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
boot=""
4+
5+
echo "Waiting for AVD to finish booting"
6+
export PATH=$(dirname $(dirname $(command -v android)))/platform-tools:$PATH
7+
8+
until [[ "$boot" =~ "1" ]]; do
9+
sleep 5
10+
boot=$(adb -e shell getprop sys.boot_completed 2>&1)
11+
done
12+
13+
# extra time to let the OS settle
14+
sleep 15
15+
16+
adb shell settings put global window_animation_scale 0
17+
adb shell settings put global transition_animation_scale 0
18+
adb shell settings put global animator_duration_scale 0
19+
20+
echo "Android Virtual Device is now ready."

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
typings
2+
node_modules
3+
example/android-bundle.js
4+
example/ios-bundle.js

.eslintrc.js

Lines changed: 298 additions & 0 deletions
Large diffs are not rendered by default.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Overview
2+
<!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. -->
3+
<!-- Help us understand your motivation by explaining why you decided to make this change -->
4+
5+
6+
# Test Plan
7+
<!-- Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos! Increase test coverage whenever possible. -->

.gitignore

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
12
# OSX
23
#
34
.DS_Store
45

6+
# node.js
7+
#
8+
node_modules/
9+
npm-debug.log
10+
yarn-error.log
11+
12+
513
# Xcode
614
#
715
build/
@@ -22,6 +30,7 @@ DerivedData
2230
*.xcuserstate
2331
project.xcworkspace
2432

33+
2534
# Android/IntelliJ
2635
#
2736
build/
@@ -30,27 +39,19 @@ build/
3039
local.properties
3140
*.iml
3241

33-
# node.js
34-
#
35-
node_modules/
36-
npm-debug.log
37-
yarn-error.log
38-
3942
# BUCK
4043
buck-out/
4144
\.buckd/
42-
*.keystore
45+
debug.keystore
4346

44-
# fastlane
45-
#
46-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47-
# screenshots whenever they are needed.
48-
# For more information about the recommended setup visit:
49-
# https://docs.fastlane.tools/best-practices/source-control/
47+
# Editor config
48+
.vscode
5049

51-
*/fastlane/report.xml
52-
*/fastlane/Preview.html
53-
*/fastlane/screenshots
50+
# Outputs
51+
coverage
5452

55-
# Bundle artifact
56-
*.jsbundle
53+
.tmp
54+
example/android-bundle.js
55+
example/ios-bundle.js
56+
index.android.bundle
57+
index.ios.bundle

.npmignore

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# JS
2+
node_modules
3+
yarn.lock
4+
5+
# Project files
6+
CONTRIBUTING.md
7+
CODE_OF_CONDUCT.md
8+
README.md
9+
10+
# Config files
11+
.babelrc
12+
babel.config.js
13+
.editorconfig
14+
.eslintrc
15+
.flowconfig
16+
.watchmanconfig
17+
jsconfig.json
18+
.npmrc
19+
.gitattributes
20+
.circleci
21+
*.coverage.json
22+
.opensource
23+
.circleci
24+
.eslintignore
25+
codecov.yml
26+
27+
# Example
28+
example/
29+
30+
#ScreenShots
31+
ScreenShots/
32+
33+
# Android
34+
android/*/build/
35+
android/gradlew
36+
android/build
37+
android/gradlew.bat
38+
android/gradle/
39+
android/com_crashlytics_export_strings.xml
40+
android/local.properties
41+
android/.gradle/
42+
android/.signing/
43+
android/.idea/gradle.xml
44+
android/.idea/libraries/
45+
android/.idea/workspace.xml
46+
android/.idea/tasks.xml
47+
android/.idea/.name
48+
android/.idea/compiler.xml
49+
android/.idea/copyright/profiles_settings.xml
50+
android/.idea/encodings.xml
51+
android/.idea/misc.xml
52+
android/.idea/modules.xml
53+
android/.idea/scopes/scope_settings.xml
54+
android/.idea/vcs.xml
55+
android/*.iml
56+
android/.settings
57+
58+
# iOS
59+
ios/*.xcodeproj/xcuserdata
60+
*.pbxuser
61+
*.mode1v3
62+
*.mode2v3
63+
*.perspectivev3
64+
*.xcuserstate
65+
project.xcworkspace/
66+
xcuserdata/
67+
68+
# Misc
69+
.DS_Store
70+
.DS_Store?
71+
*.DS_Store
72+
coverage.android.json
73+
coverage.ios.json
74+
coverage
75+
npm-debug.log
76+
.github
77+
._*
78+
.Spotlight-V100
79+
.Trashes
80+
ehthumbs.db
81+
Thumbs.dbandroid/gradle
82+
docs
83+
.idea
84+
tests/
85+
bin/test.js
86+
codorials
87+
.vscode
88+
.nyc_output
89+
.tmp

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"requirePragma": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"bracketSpacing": false,
6+
"jsxBracketSameLine": true,
7+
"parser": "flow"
8+
}

.releaserc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
"@semantic-release/npm",
6+
"@semantic-release/github",
7+
[
8+
"@semantic-release/git",
9+
{
10+
"assets": "package.json",
11+
"message": "chore(release): ${nextRelease.version} [skip ci] \n\n${nextRelease.notes}"
12+
}
13+
]
14+
]
15+
}

CONTRIBUTING.MD

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing to React Native NetInfo
2+
3+
## Development Process
4+
All work on React Native NetInfo happens directly on GitHub. Contributors send pull requests which go through a review process.
5+
6+
> **Working on your first pull request?** You can learn how from this *free* series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
7+
8+
1. Fork the repo and create your branch from `master` (a guide on [how to fork a repository](https://help.github.com/articles/fork-a-repo/)).
9+
2. Run `yarn` or `npm install` to install all required dependencies.
10+
3. Now you are ready to make your changes!
11+
12+
## Tests & Verifications
13+
Currently we use `flow` for typechecking, `eslint` with `prettier` for linting and formatting the code, and `jest` for unit testing. We also use `detox` for end-to-end testing. All of these are run on CircleCI for all opened pull requests, but you should use them locally when making changes.
14+
15+
* `yarn test`: Run all tests and validations.
16+
* `yarn validate:eslint`: Run `eslint`.
17+
* `yarn validate:eslint --fix`: Run `eslint` and automatically fix issues. This is useful for correcting code formatting.
18+
* `yarn validate:flow`: Run `flow` typechecking.
19+
* `yarn validate:typescript`: Run `typescript` typechecking.
20+
* `yarn test:jest`: Run unit tests with `jest`.
21+
* `yarn test:detox:<android|ios>:build:<debug|release>`: Build the `debug` or `release` app for end-to-end tests with `detox` on either `android` or `ios`. You need to run this before running the test command and whenever you make changes to the native code.
22+
* `yarn test:detox:<android|ios>:test:<debug|release>`: Run the `debug` or `release` end-to-end tests with `detox` on either `android` or `ios`.
23+
24+
## Sending a pull request
25+
When you're sending a pull request:
26+
27+
* Prefer small pull requests focused on one change.
28+
* Verify that all tests and validations are passing.
29+
* Follow the pull request template when opening a pull request.
30+
31+
## Commit message convention
32+
We prefix our commit messages with one of the following to signify the kind of change:
33+
34+
* **build**: Changes that affect the build system or external dependencies.
35+
* **ci**, **chore**: Changes to our CI configuration files and scripts.
36+
* **docs**: Documentation only changes.
37+
* **feat**: A new feature.
38+
* **fix**: A bug fix.
39+
* **perf**: A code change that improves performance.
40+
* **refactor**: A code change that neither fixes a bug nor adds a feature.
41+
* **style**: Changes that do not affect the meaning of the code.
42+
* **test**: Adding missing tests or correcting existing tests.
43+
44+
## Release process
45+
We use [Semantic Release](http://semantic-release.org) to automatically release new versions of the library when changes are merged into master. Using the commit message convention described above, it will detect if we need to release a patch, minor, or major version of the library.
46+
47+
## Reporting issues
48+
You can report issues on our [bug tracker](https://github.com/react-native-community/react-native-netinfo/issues). Please search for existing issues and follow the issue template when opening an issue.
49+
50+
## License
51+
By contributing to React Native NetInfo, you agree that your contributions will be licensed under the **MIT** license.

README.md

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,102 @@
1-
# react-native-segmented-control
1+
# `@react-native-segmented-control`
2+
3+
React Native SegmentedControlIos library. Use SegmentedControlIOS to render a UISegmentedControl iOS.
4+
5+
## Getting started
6+
Install the library using either Yarn:
7+
8+
```
9+
yarn add @react-native-community/segmented-control
10+
```
11+
12+
or npm:
13+
14+
```
15+
npm install --save @react-native-community/segmented-control
16+
```
17+
18+
## Migrating from the core `react-native` module
19+
This module was created when the segmentedControlIos was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change you imports from:
20+
21+
```javascript
22+
import { SegmentedControlIOS } from "react-native";
23+
```
24+
25+
to:
26+
27+
```javascript
28+
import SegmentedControlIOS from "@react-native-community/segmented-control";
29+
```
30+
31+
## Usage
32+
Start by importing the library:
33+
34+
Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
35+
36+
#### Programmatically changing selected index
37+
The selected index can be changed on the fly by assigning the
38+
selectedIndex prop to a state variable, then changing that variable.
39+
Note that the state variable would need to be updated as the user
40+
selects a value and changes the index, as shown in the example below.
41+
42+
43+
```javascript
44+
import SegmentedControlIOS from "@react-native-community/segmented-control";
45+
46+
<SegmentedControlIOS
47+
values={['One', 'Two']}
48+
selectedIndex={this.state.selectedIndex}
49+
onChange={(event) => {
50+
this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
51+
}}
52+
/>
53+
54+
type SegmentedControlIOSProps = $ReadOnly<{|
55+
...ViewProps,
56+
/**
57+
* The labels for the control's segment buttons, in order.
58+
*/
59+
values?: $ReadOnlyArray<string>,
60+
/**
61+
* The index in `props.values` of the segment to be (pre)selected.
62+
*/
63+
selectedIndex?: ?number,
64+
/**
65+
* Callback that is called when the user taps a segment;
66+
* passes the segment's value as an argument
67+
*/
68+
onValueChange?: ?(value: number) => mixed,
69+
/**
70+
* Callback that is called when the user taps a segment;
71+
* passes the event as an argument
72+
*/
73+
onChange?: ?(event: Event) => mixed,
74+
/**
75+
* If false the user won't be able to interact with the control.
76+
* Default value is true.
77+
*/
78+
enabled?: boolean,
79+
/**
80+
* Accent color of the control.
81+
*/
82+
tintColor?: ?string,
83+
/**
84+
* If true, then selecting a segment won't persist visually.
85+
* The `onValueChange` callback will still work as expected.
86+
*/
87+
momentary?: ?boolean,
88+
|}>;
89+
```
90+
91+
## Maintainers
92+
93+
* [M.Haris Baig](https://github.com/harisbaig100)
94+
95+
## Contributing
96+
97+
Please see the [`contributing guide`](/CONTRIBUTING.md).
98+
99+
## License
100+
101+
The library is released under the MIT licence. For more information see [`LICENSE`](/LICENSE).
102+
Loading

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
"module-resolver",
66
{
77
alias: {
8-
"@react-native-community/viewpager": "./js"
8+
"@react-native-community/segmented-control": "./js"
99
},
1010
cwd: "babelrc"
1111
}

example/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+
*.jks
5+
*.p12
6+
*.key
7+
*.mobileprovision

example/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)