Skip to content

Commit 34a7824

Browse files
authored
Refactor the whole lib (#11)
* Refactor the whole lib * Update README.md
1 parent 48e41f2 commit 34a7824

File tree

75 files changed

+15834
-23359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+15834
-23359
lines changed

.flowconfig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
; Ignore metro
2020
.*/node_modules/metro/.*
2121

22+
; Ignore example folder
23+
.*/example/.*
24+
2225
[include]
2326

2427
[libs]
@@ -51,7 +54,7 @@ munge_underscores=true
5154

5255
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
5356
# Support the library import in examples
54-
module.name_mapper='^\@react-native-community/viewpager$' -> '<PROJECT_ROOT>/js/index.js'
57+
module.name_mapper='^\@react-native-community/react-native-segmented-control$' -> '<PROJECT_ROOT>/js/index.js'
5558

5659
module.file_ext=.js
5760
module.file_ext=.jsx
@@ -71,4 +74,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
7174
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
7275

7376
[version]
74-
^0.86.0
77+
^0.92.0

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ React Native SegmentedControlIOS library. Use SegmentedControlIOS to render a UI
77
<img src="https://github.com/react-native-community/react-native-segmented-control/blob/master/ScreenShots/Screen%20Shot%202019-02-26%20at%206.28.55%20PM.png" height="500" />
88

99
## Getting started
10+
1011
Install the library using either Yarn:
1112

1213
```
@@ -20,6 +21,7 @@ npm install --save @react-native-community/segmented-control
2021
```
2122

2223
## Migrating from the core `react-native` module
24+
2325
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:
2426

2527
```javascript
@@ -33,29 +35,32 @@ import SegmentedControlIOS from "@react-native-community/segmented-control";
3335
```
3436

3537
## Usage
38+
3639
Start by importing the library:
3740

3841
Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
3942

4043
#### Programmatically changing selected index
44+
4145
The selected index can be changed on the fly by assigning the
4246
selectedIndex prop to a state variable, then changing that variable.
4347
Note that the state variable would need to be updated as the user
4448
selects a value and changes the index, as shown in the example below.
4549

46-
4750
```javascript
4851
import SegmentedControlIOS from "@react-native-community/segmented-control";
4952

50-
<SegmentedControlIOS
51-
values={['One', 'Two']}
53+
return (
54+
<SegmentedControlIOS
55+
values={["One", "Two"]}
5256
selectedIndex={this.state.selectedIndex}
53-
onChange={(event) => {
54-
this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
55-
}}
56-
/>
57+
onChange={event => {
58+
this.setState({ selectedIndex: event.nativeEvent.selectedSegmentIndex });
59+
}}
60+
/>
61+
);
5762

58-
type SegmentedControlIOSProps = $ReadOnly<{|
63+
type SegmentedControlIOSProps = $ReadOnly<{|
5964
...ViewProps,
6065
/**
6166
* The labels for the control's segment buttons, in order.
@@ -94,7 +99,7 @@ import SegmentedControlIOS from "@react-native-community/segmented-control";
9499
95100
## Maintainers
96101
97-
* [M.Haris Baig](https://github.com/harisbaig100)
102+
- [M.Haris Baig](https://github.com/harisbaig100)
98103
99104
## Contributing
100105
@@ -103,4 +108,3 @@ Please see the [`contributing guide`](/CONTRIBUTING.md).
103108
## License
104109
105110
The library is released under the MIT licence. For more information see [`LICENSE`](/LICENSE).
106-

android/build.gradle

Lines changed: 0 additions & 41 deletions
This file was deleted.

android/gradle.properties

Lines changed: 0 additions & 4 deletions
This file was deleted.

android/src/main/java/com/reactnativecommunity/segmentedcontrol/BUCK

Lines changed: 0 additions & 24 deletions
This file was deleted.

babel.config.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
module.exports = {
2-
presets: ["module:metro-react-native-babel-preset"],
3-
plugins: [
4-
[
5-
"module-resolver",
6-
{
7-
alias: {
8-
"@react-native-community/segmented-control": "./js"
9-
},
10-
cwd: "babelrc"
11-
}
12-
]
13-
]
14-
};
2+
presets: ['module:metro-react-native-babel-preset'],
3+
};

example/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example/.flowconfig

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
21+
22+
[include]
23+
24+
[libs]
25+
node_modules/react-native/Libraries/react-native/react-native-interface.js
26+
node_modules/react-native/flow/
27+
28+
[options]
29+
emoji=true
30+
31+
esproposal.optional_chaining=enable
32+
esproposal.nullish_coalescing=enable
33+
34+
module.system=haste
35+
module.system.haste.use_name_reducers=true
36+
# get basename
37+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38+
# strip .js or .js.flow suffix
39+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40+
# strip .ios suffix
41+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44+
module.system.haste.paths.blacklist=.*/__tests__/.*
45+
module.system.haste.paths.blacklist=.*/__mocks__/.*
46+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
48+
49+
munge_underscores=true
50+
51+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
52+
53+
module.file_ext=.js
54+
module.file_ext=.jsx
55+
module.file_ext=.json
56+
module.file_ext=.native.js
57+
58+
suppress_type=$FlowIssue
59+
suppress_type=$FlowFixMe
60+
suppress_type=$FlowFixMeProps
61+
suppress_type=$FlowFixMeState
62+
63+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
66+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
67+
68+
[version]
69+
^0.92.0

example/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

example/.gitignore

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
1-
node_modules/**/*
2-
.expo/*
3-
npm-debug.*
4-
*.jks
5-
*.p12
6-
*.key
7-
*.mobileprovision
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
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/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

0 commit comments

Comments
 (0)