Skip to content

Commit 86904c5

Browse files
committed
added sample project
1 parent 8ebcff0 commit 86904c5

File tree

5,137 files changed

+56760
-0
lines changed

Some content is hidden

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

5,137 files changed

+56760
-0
lines changed

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import SegmentControl from './src/segmentcontrol';
2+
export default SegmentControl;

package.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "react-native-segment-controller",
3+
"version": "1.0.0",
4+
"description": "A segment controller component for both android and ios react-native applications",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/csath/react-native-segment-controller.git"
12+
},
13+
"keywords": [
14+
"react-native",
15+
"segement-controll",
16+
"tabs",
17+
"tab-view",
18+
"android",
19+
"ios"
20+
],
21+
"author": "Chanaka Athurugiriya <chanakaathurugiriya@gmail.com>",
22+
"license": "ISC",
23+
"bugs": {
24+
"url": "https://github.com/csath/react-native-segment-controller/issues"
25+
},
26+
"homepage": "https://github.com/csath/react-native-segment-controller#readme"
27+
}

samples/.DS_Store

8 KB
Binary file not shown.

samples/App.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import React, { Component } from 'react';
2+
import {
3+
StyleSheet,
4+
View,
5+
Text
6+
} from 'react-native';
7+
import SegmentControl from 'react-native-segment-controller';
8+
9+
export default class App extends Component<{}> {
10+
11+
constructor() {
12+
super();
13+
14+
this.state = {
15+
index: 0,
16+
content: ''
17+
}
18+
this.handlePress = this.handlePress.bind(this);
19+
}
20+
21+
handlePress(index) {
22+
this.setState({ content: `Segment ${index + 1} selected !!!`, index});
23+
}
24+
25+
render() {
26+
return (
27+
<View style={styles.container}>
28+
<Text style={styles.title}>react-native-segment-controller</Text>
29+
<SegmentControl
30+
values={['One', 'Two', 'Three', 'Four']}
31+
badges={[0, 5, 0, 2]}
32+
selectedIndex={this.state.index}
33+
height={30}
34+
onTabPress={this.handlePress}
35+
borderRadius={5}
36+
tabBadgeContainerStyle={{ backgroundColor: 'red'}}
37+
/>
38+
<View style={{ marginTop: 20, marginBottom: -50}}>
39+
<Text style={styles.tab}>{this.state.content}</Text>
40+
<Text style={styles.info}>Author: csath</Text>
41+
<Text style={styles.info}>Email: chanakaathurugiriya@gmail.com</Text>
42+
</View>
43+
</View>
44+
);
45+
}
46+
}
47+
48+
const styles = StyleSheet.create({
49+
container: {
50+
flex: 1,
51+
justifyContent: 'center',
52+
padding: 20,
53+
backgroundColor: '#F5FCFF',
54+
},
55+
title: {
56+
fontSize: 20,
57+
fontWeight: '700',
58+
alignSelf: 'center',
59+
marginTop: -200,
60+
marginBottom: 60
61+
},
62+
info: {
63+
fontSize: 14,
64+
fontWeight: '500',
65+
color: 'grey',
66+
padding: 5
67+
},
68+
tab: {
69+
padding: 30,
70+
alignSelf: 'center'
71+
}
72+
});

samples/__tests__/App.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import App from '../App';
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+
<App />
11+
);
12+
});

samples/android/app/BUCK

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

samples/android/app/build.gradle

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
apply plugin: "com.android.application"
2+
3+
import com.android.build.OutputFile
4+
5+
/**
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
8+
* These basically call `react-native bundle` with the correct arguments during the Android build
9+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10+
* bundle directly from the development server. Below you can see all the possible configurations
11+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
13+
*
14+
* project.ext.react = [
15+
* // the name of the generated asset file containing your JS bundle
16+
* bundleAssetName: "index.android.bundle",
17+
*
18+
* // the entry file for bundle generation
19+
* entryFile: "index.android.js",
20+
*
21+
* // whether to bundle JS and assets in debug mode
22+
* bundleInDebug: false,
23+
*
24+
* // whether to bundle JS and assets in release mode
25+
* bundleInRelease: true,
26+
*
27+
* // whether to bundle JS and assets in another build variant (if configured).
28+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29+
* // The configuration property can be in the following formats
30+
* // 'bundleIn${productFlavor}${buildType}'
31+
* // 'bundleIn${buildType}'
32+
* // bundleInFreeDebug: true,
33+
* // bundleInPaidRelease: true,
34+
* // bundleInBeta: true,
35+
*
36+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
37+
* // for example: to disable dev mode in the staging build type (if configured)
38+
* devDisabledInStaging: true,
39+
* // The configuration property can be in the following formats
40+
* // 'devDisabledIn${productFlavor}${buildType}'
41+
* // 'devDisabledIn${buildType}'
42+
*
43+
* // the root of your project, i.e. where "package.json" lives
44+
* root: "../../",
45+
*
46+
* // where to put the JS bundle asset in debug mode
47+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
48+
*
49+
* // where to put the JS bundle asset in release mode
50+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
51+
*
52+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
53+
* // require('./image.png')), in debug mode
54+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
55+
*
56+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
57+
* // require('./image.png')), in release mode
58+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
59+
*
60+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
61+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
62+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
63+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
64+
* // for example, you might want to remove it from here.
65+
* inputExcludes: ["android/**", "ios/**"],
66+
*
67+
* // override which node gets called and with what additional arguments
68+
* nodeExecutableAndArgs: ["node"],
69+
*
70+
* // supply additional arguments to the packager
71+
* extraPackagerArgs: []
72+
* ]
73+
*/
74+
75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
79+
apply from: "../../node_modules/react-native/react.gradle"
80+
81+
/**
82+
* Set this to true to create two separate APKs instead of one:
83+
* - An APK that only works on ARM devices
84+
* - An APK that only works on x86 devices
85+
* The advantage is the size of the APK is reduced by about 4MB.
86+
* Upload all the APKs to the Play Store and people will download
87+
* the correct one based on the CPU architecture of their device.
88+
*/
89+
def enableSeparateBuildPerCPUArchitecture = false
90+
91+
/**
92+
* Run Proguard to shrink the Java bytecode in release builds.
93+
*/
94+
def enableProguardInReleaseBuilds = false
95+
96+
android {
97+
compileSdkVersion 23
98+
buildToolsVersion "23.0.1"
99+
100+
defaultConfig {
101+
applicationId "com.firstapp"
102+
minSdkVersion 16
103+
targetSdkVersion 22
104+
versionCode 1
105+
versionName "1.0"
106+
ndk {
107+
abiFilters "armeabi-v7a", "x86"
108+
}
109+
}
110+
splits {
111+
abi {
112+
reset()
113+
enable enableSeparateBuildPerCPUArchitecture
114+
universalApk false // If true, also generate a universal APK
115+
include "armeabi-v7a", "x86"
116+
}
117+
}
118+
buildTypes {
119+
release {
120+
minifyEnabled enableProguardInReleaseBuilds
121+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
122+
}
123+
}
124+
// applicationVariants are e.g. debug, release
125+
applicationVariants.all { variant ->
126+
variant.outputs.each { output ->
127+
// For each separate APK per architecture, set a unique version code as described here:
128+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
129+
def versionCodes = ["armeabi-v7a":1, "x86":2]
130+
def abi = output.getFilter(OutputFile.ABI)
131+
if (abi != null) { // null for the universal-debug, universal-release variants
132+
output.versionCodeOverride =
133+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
134+
}
135+
}
136+
}
137+
}
138+
139+
dependencies {
140+
compile fileTree(dir: "libs", include: ["*.jar"])
141+
compile "com.android.support:appcompat-v7:23.0.1"
142+
compile "com.facebook.react:react-native:+" // From node_modules
143+
}
144+
145+
// Run this once to be able to run the application with BUCK
146+
// puts all compile dependencies into folder libs for BUCK to use
147+
task copyDownloadableDepsToLibs(type: Copy) {
148+
from configurations.compile
149+
into 'libs'
150+
}

0 commit comments

Comments
 (0)