Skip to content

Commit 340cd95

Browse files
committed
Working simple example
1 parent 1b4a7f2 commit 340cd95

13 files changed

+6686
-152
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "interactive"
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
connection.project.dir=
1+
connection.project.dir=../example/android
22
eclipse.preferences.version=1

android/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ buildscript {
1212
apply plugin: 'com.android.library'
1313

1414
android {
15-
compileSdkVersion 23
16-
buildToolsVersion "23.0.1"
15+
compileSdkVersion 26
1716

1817
defaultConfig {
1918
minSdkVersion 16
20-
targetSdkVersion 22
19+
targetSdkVersion 26
2120
versionCode 1
2221
versionName "1.0"
2322
}
@@ -31,6 +30,6 @@ repositories {
3130
}
3231

3332
dependencies {
34-
compile 'com.facebook.react:react-native:+'
33+
implementation 'com.facebook.react:react-native:+'
3534
}
3635

example/ProgressBarAndroidExample.android.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
var ProgressBar = require('../../Libraries/Components/ProgressBarAndroid/ProgressBarAndroid');
13+
var ProgressBar = require('../js/RNCProgressBarAndroid.android');
1414
var React = require('react');
1515
var createReactClass = require('create-react-class');
1616
var RNTesterBlock = require('./RNTesterBlock');
@@ -40,7 +40,7 @@ var MovingBar = createReactClass({
4040
},
4141
});
4242

43-
class ProgressBarAndroidExample extends React.Component<{}> {
43+
export default class ProgressBarAndroidExample extends React.Component<{}> {
4444
static title = '<ProgressBarAndroid>';
4545
static description = 'Horizontal bar to show the progress of some operation.';
4646

example/android/app/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ project.ext.react = [
7676
entryFile: "example/index.js"
7777
]
7878

79-
apply from: "../../../../node_modules/react-native/react.gradle"
79+
apply from: "../../../node_modules/react-native/react.gradle"
8080

8181
/**
8282
* Set this to true to create two separate APKs instead of one:

example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rootProject.name = 'AndroidProgressBarExample'
22

3-
include ':react-native-netinfo'
4-
project(':react-native-netinfo').projectDir = new File(rootProject.projectDir, '../../android')
3+
include ':react-native-progress-bar-android'
4+
project(':react-native-progress-bar-android').projectDir = new File(rootProject.projectDir, '../../android')
55
// For your application the line above will most likely be:
66
// project(':react-native-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/!react-native-community/netinfo/android')
77

example/index.js

Lines changed: 7 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,14 @@
1-
/**
2-
* Copyright (c) Facebook, Inc. and its affiliates.
3-
*
4-
* This source code is licensed under the MIT license found in the
5-
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @format
8-
* @flow
9-
*/
10-
111
import React from 'react';
12-
import {
13-
AppRegistry,
14-
Button,
15-
SafeAreaView,
16-
ScrollView,
17-
StyleSheet,
18-
Text,
19-
View,
20-
} from 'react-native';
21-
22-
import ProgressBarTestModule from './ProgressBarTestModule.js';
23-
import ProgressBarAndroidExample from './ProgressBarAndroidExample.android.js';
24-
import RNTesterBlock from './RNTesterBlock.js';
25-
import RNTesterPage from './RNTesterPage.js';
26-
import RNTesterTitle from './RNTesterTitle.js';
27-
28-
// Examples which show the user how to correctly use the library
29-
const EXAMPLES = [
30-
{
31-
id: 'ProgressBarTestModule',
32-
title: 'Progress Bar Test Module',
33-
description: 'Multiple progress bars with different style attributes.',
34-
render() {
35-
return <ProgressBarTestModule />;
36-
},
37-
},
38-
{
39-
id: 'ProgressBarAndroidExample',
40-
title: 'Simple progress bar',
41-
description: 'Horizontal bar to show the progress of some operation.',
42-
render() {
43-
return <ProgressBarAndroidExample />;
44-
},
45-
},
46-
];
47-
48-
// Test cases for the e2e tests. THESE ARE NOT EXAMPLES OF BEST PRACTICE
49-
import TEST_CASES from './testCases';
50-
51-
type State = {
52-
showExamples: boolean,
53-
};
54-
55-
class ExampleApp extends React.Component<{}, State> {
56-
constructor(props) {
57-
super(props);
2+
import {AppRegistry} from 'react-native';
583

59-
this.state = {
60-
showExamples: true,
61-
};
62-
}
63-
64-
_toggleMode = () => {
65-
this.setState(state => ({showExamples: !state.showExamples}));
66-
};
4+
import {name as appName} from './app.json';
5+
import ProgressBarAndroidExample from "./ProgressBarAndroidExample.android";
676

7+
class ExampleApp extends React.Component<{}> {
688
render() {
69-
const {showExamples} = this.state;
709
return (
71-
<ScrollView testID="scrollView" style={styles.container}>
72-
<SafeAreaView>
73-
<Button
74-
testID="modeToggle"
75-
onPress={this._toggleMode}
76-
title={showExamples ? 'Switch to Test Cases' : 'Switch to Examples'}
77-
/>
78-
{showExamples ? (
79-
<>
80-
<Text testID="examplesTitle" style={styles.sectionTitle}>
81-
Examples
82-
</Text>
83-
{EXAMPLES.map(this._renderExample)}
84-
</>
85-
) : (
86-
<>
87-
<Text testID="testCasesTitle" style={styles.sectionTitle}>
88-
Test Cases
89-
</Text>
90-
{TEST_CASES.map(this._renderExample)}
91-
</>
92-
)}
93-
</SafeAreaView>
94-
</ScrollView>
95-
);
10+
<ProgressBarAndroidExample />
11+
)
9612
}
97-
98-
_renderExample = example => {
99-
return (
100-
<View
101-
testID={`example-${example.id}`}
102-
key={example.title}
103-
style={styles.exampleContainer}>
104-
<Text style={styles.exampleTitle}>{example.title}</Text>
105-
<Text style={styles.exampleDescription}>{example.description}</Text>
106-
<View style={styles.exampleInnerContainer}>{example.render()}</View>
107-
</View>
108-
);
109-
};
11013
}
111-
112-
const styles = StyleSheet.create({
113-
container: {
114-
flex: 1,
115-
backgroundColor: '#F5FCFF',
116-
},
117-
sectionTitle: {
118-
fontSize: 24,
119-
marginHorizontal: 8,
120-
marginTop: 24,
121-
},
122-
exampleContainer: {
123-
padding: 16,
124-
marginVertical: 4,
125-
backgroundColor: '#FFF',
126-
borderColor: '#EEE',
127-
borderTopWidth: 1,
128-
borderBottomWidth: 1,
129-
},
130-
exampleTitle: {
131-
fontSize: 18,
132-
},
133-
exampleDescription: {
134-
color: '#333333',
135-
marginBottom: 16,
136-
},
137-
exampleInnerContainer: {
138-
borderColor: '#EEE',
139-
borderTopWidth: 1,
140-
paddingTop: 16,
141-
},
142-
});
143-
144-
AppRegistry.registerComponent(appName, () => ExampleApp);
14+
AppRegistry.registerComponent(appName, () => ExampleApp);

example/testCases.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const TEST_CASES = [
2+
{
3+
id: 'ProgressBarTestModule',
4+
title: 'Progress Bar Test Module',
5+
description: 'Multiple progress bars with different style attributes.',
6+
render() {
7+
return <ProgressBarTestModule />;
8+
},
9+
},
10+
{
11+
id: 'ProgressBarAndroidExample',
12+
title: 'Simple progress bar',
13+
description: 'Horizontal bar to show the progress of some operation.',
14+
render() {
15+
return <ProgressBarAndroidExample />;
16+
},
17+
},
18+
];
19+
20+
module.exports = TEST_CASES;

0 commit comments

Comments
 (0)