Skip to content

Commit 543ae77

Browse files
committed
feat(example): init react native project
1 parent bfe6eff commit 543ae77

Some content is hidden

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

44 files changed

+2163
-12
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
# react-native-snap-carousel
2-
Simple carousel component with snapping effect on Android & iOS for React Native
2+
Simple carousel component for React Native with **previews** and **snapping effect**. Compatible with Android & iOS.
3+
Pull requests are very welcome!
34

4-
![react-native-snap-carousel](https://zippy.gfycat.com/BoringBasicKiskadee.gif)
5-
![react-native-snap-carousel](https://zippy.gfycat.com/IncompatibleVengefulBasenji.gif)
5+
## Table of contents
6+
7+
1. [Showcase](#showcase)
8+
1. [Usage](#usage)
9+
1. [Props](#props)
10+
1. [Methods](#methods)
11+
1. [Properties](#properties)
12+
1. [Tips and tricks](#tips-and-tricks)
13+
1. [TODO](#todo)
14+
15+
## Showcase
16+
17+
![react-native-snap-carousel](http://i.imgur.com/Fope3uj.gif)
18+
![react-native-snap-carousel](https://media.giphy.com/media/3o6ZsU9gWWrvYtogow/giphy.gif)
19+
![react-native-snap-carousel](https://media.giphy.com/media/3o7TKUAlvi1tYLFCTK/giphy.gif)
620

721
## Usage
822

@@ -40,6 +54,7 @@ items | Array of items to loop on | Array | Required
4054
sliderWidth | The width in pixels of your slider | Number | Required
4155
itemWidth | Width in pixels of your items | Number | Required
4256
renderItem | Function returning a react element. The entry data is the 1st parameter, its index is the 2nd | Function | Required
57+
shouldOptimizeUpdates | whether to implement a `shouldComponentUpdate` strategy to minimize updates | Boolean | `true`
4358
slideStyle | Style of each item's container | Number | Required
4459
swipeThreshold | Delta x when swiping to trigger the snap | Number | `20`
4560
animationFunc | Animated animation to use. Provide the name of the method | String | `Timing`
@@ -61,6 +76,12 @@ onSnapToItem(slideIndex, itemData) | Callback fired when navigating to an item |
6176
* `startAutoplay (instantly = false)` Start the autoplay manually
6277
* `stopAutoplay ()` Stop the autoplay manually
6378
* `snapToItem (index, animated = true)` Snap to an item manually
79+
* `snapToNext (animated = true)` Snap to next item manually
80+
* `snapToPrev (animated = true)` Snap to previous item manually
81+
82+
## Properties
83+
84+
* `currentIndex` Current active item (`int`, starts at 0)
6485

6586
## Tips and tricks
6687

@@ -86,7 +107,7 @@ const styles = Stylesheet.create({
86107

87108
```
88109
89-
## TODO :
110+
## TODO
90111
91112
- [ ] Improve snap on Android
92113
- [ ] Handle changing props on-the-fly

example/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react-native"]
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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*[.]android.js
5+
6+
# Ignore templates with `@flow` in header
7+
.*/local-cli/generator.*
8+
9+
# Ignore malformed json
10+
.*/node_modules/y18n/test/.*\.json
11+
12+
# Ignore the website subdir
13+
<PROJECT_ROOT>/website/.*
14+
15+
# Ignore BUCK generated dirs
16+
<PROJECT_ROOT>/\.buckd/
17+
18+
# Ignore unexpected extra @providesModule
19+
.*/node_modules/commoner/test/source/widget/share.js
20+
.*/node_modules/.*/node_modules/fbjs/.*
21+
22+
# Ignore duplicate module providers
23+
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
24+
.*/Libraries/react-native/React.js
25+
.*/Libraries/react-native/ReactNative.js
26+
.*/node_modules/jest-runtime/build/__tests__/.*
27+
28+
[include]
29+
30+
[libs]
31+
node_modules/react-native/Libraries/react-native/react-native-interface.js
32+
node_modules/react-native/flow
33+
flow/
34+
35+
[options]
36+
module.system=haste
37+
38+
esproposal.class_static_fields=enable
39+
esproposal.class_instance_fields=enable
40+
41+
experimental.strict_type_args=true
42+
43+
munge_underscores=true
44+
45+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
46+
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'
47+
48+
suppress_type=$FlowIssue
49+
suppress_type=$FlowFixMe
50+
suppress_type=$FixMe
51+
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
54+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
55+
56+
unsafe.enable_getters_and_setters=true
57+
58+
[version]
59+
^0.33.0

example/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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/IJ
26+
#
27+
*.iml
28+
.idea
29+
.gradle
30+
local.properties
31+
32+
# node.js
33+
#
34+
node_modules/
35+
npm-debug.log
36+
37+
# BUCK
38+
buck-out/
39+
\.buckd/
40+
android/app/libs
41+
*.keystore

example/.watchmanconfig

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

example/__tests__/index.android.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import Index from '../index.android.js';
4+
5+
// Note: test renderer must be required after react-native.
6+
import renderer from 'react-test-renderer';
7+
8+
it('renders correctly', () => {
9+
const tree = renderer.create(
10+
<Index />
11+
);
12+
});

example/__tests__/index.ios.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import Index from '../index.ios.js';
4+
5+
// Note: test renderer must be required after react-native.
6+
import renderer from 'react-test-renderer';
7+
8+
it('renders correctly', () => {
9+
const tree = renderer.create(
10+
<Index />
11+
);
12+
});

example/android/app/BUCK

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import re
2+
3+
# To learn about Buck see [Docs](https://buckbuild.com/).
4+
# To run your application with Buck:
5+
# - install Buck
6+
# - `npm start` - to start the packager
7+
# - `cd android`
8+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
9+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10+
# - `buck install -r android/app` - compile, install and run application
11+
#
12+
13+
lib_deps = []
14+
for jarfile in glob(['libs/*.jar']):
15+
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
16+
lib_deps.append(':' + name)
17+
prebuilt_jar(
18+
name = name,
19+
binary_jar = jarfile,
20+
)
21+
22+
for aarfile in glob(['libs/*.aar']):
23+
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
24+
lib_deps.append(':' + name)
25+
android_prebuilt_aar(
26+
name = name,
27+
aar = aarfile,
28+
)
29+
30+
android_library(
31+
name = 'all-libs',
32+
exported_deps = lib_deps
33+
)
34+
35+
android_library(
36+
name = 'app-code',
37+
srcs = glob([
38+
'src/main/java/**/*.java',
39+
]),
40+
deps = [
41+
':all-libs',
42+
':build_config',
43+
':res',
44+
],
45+
)
46+
47+
android_build_config(
48+
name = 'build_config',
49+
package = 'com.example',
50+
)
51+
52+
android_resource(
53+
name = 'res',
54+
res = 'src/main/res',
55+
package = 'com.example',
56+
)
57+
58+
android_binary(
59+
name = 'app',
60+
package_type = 'debug',
61+
manifest = 'src/main/AndroidManifest.xml',
62+
keystore = '//android/keystores:debug',
63+
deps = [
64+
':app-code',
65+
],
66+
)

0 commit comments

Comments
 (0)