Skip to content

Commit e3f400f

Browse files
committed
Updated hello world sample to include ReactXP extension example.
1 parent 797d769 commit e3f400f

11 files changed

Lines changed: 152 additions & 337 deletions

File tree

samples/hello-world/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ android {
126126
}
127127

128128
dependencies {
129+
compile project(':react-native-svg')
129130
compile fileTree(dir: "libs", include: ["*.jar"])
130131
compile "com.android.support:appcompat-v7:23.0.1"
131132
compile "com.facebook.react:react-native:+" // From node_modules

samples/hello-world/android/app/src/main/java/com/rxphelloworld/MainApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import com.horcrux.svg.RNSvgPackage;
67
import com.facebook.react.ReactNativeHost;
78
import com.facebook.react.ReactPackage;
89
import com.facebook.react.shell.MainReactPackage;
@@ -22,7 +23,8 @@ public boolean getUseDeveloperSupport() {
2223
@Override
2324
protected List<ReactPackage> getPackages() {
2425
return Arrays.<ReactPackage>asList(
25-
new MainReactPackage()
26+
new MainReactPackage(),
27+
new RNSvgPackage()
2628
);
2729
}
2830
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
rootProject.name = 'RXPHelloWorld'
2+
include ':react-native-svg'
3+
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
24

35
include ':app'

samples/hello-world/ios/RXPHelloWorld.xcodeproj/project.pbxproj

Lines changed: 42 additions & 316 deletions
Large diffs are not rendered by default.

samples/hello-world/ios/RXPHelloWorld.xcodeproj/xcshareddata/xcschemes/RXPHelloWorld-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0830"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

samples/hello-world/ios/RXPHelloWorld.xcodeproj/xcshareddata/xcschemes/RXPHelloWorld.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0620"
3+
LastUpgradeVersion = "0830"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

samples/hello-world/ios/RXPHelloWorld/Info.plist

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>CFBundleExecutable</key>
1010
<string>$(EXECUTABLE_NAME)</string>
1111
<key>CFBundleIdentifier</key>
12-
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1313
<key>CFBundleInfoDictionaryVersion</key>
1414
<string>6.0</string>
1515
<key>CFBundleName</key>
@@ -24,6 +24,19 @@
2424
<string>1</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true/>
27+
<key>NSAppTransportSecurity</key>
28+
<dict>
29+
<key>NSExceptionDomains</key>
30+
<dict>
31+
<key>localhost</key>
32+
<dict>
33+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
34+
<true/>
35+
</dict>
36+
</dict>
37+
</dict>
38+
<key>NSLocationWhenInUseUsageDescription</key>
39+
<string></string>
2740
<key>UILaunchStoryboardName</key>
2841
<string>LaunchScreen</string>
2942
<key>UIRequiredDeviceCapabilities</key>
@@ -38,19 +51,5 @@
3851
</array>
3952
<key>UIViewControllerBasedStatusBarAppearance</key>
4053
<false/>
41-
<key>NSLocationWhenInUseUsageDescription</key>
42-
<string></string>
43-
<key>NSAppTransportSecurity</key>
44-
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
45-
<dict>
46-
<key>NSExceptionDomains</key>
47-
<dict>
48-
<key>localhost</key>
49-
<dict>
50-
<key>NSExceptionAllowsInsecureHTTPLoads</key>
51-
<true/>
52-
</dict>
53-
</dict>
54-
</dict>
5554
</dict>
5655
</plist>

samples/hello-world/ios/RXPHelloWorldTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

samples/hello-world/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react-addons-test-utils": "^15.4.1",
2525
"react-dom": "^15.4.1",
2626
"react-native": "^0.42.0",
27-
"react-native-windows": "^0.33.0"
27+
"react-native-windows": "^0.33.0",
28+
"reactxp-imagesvg": "^0.2.0"
2829
}
2930
}

samples/hello-world/src/App.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
import RX = require('reactxp');
66

7+
import ProgressIndicator from './ProgressIndicator';
78
import ToggleSwitch from './ToggleSwitch';
89

910
interface AppState {
1011
toggleValue?: boolean;
12+
progressValue?: number;
1113
}
1214

1315
const styles = {
@@ -39,12 +41,16 @@ const styles = {
3941
toggleTitle: RX.Styles.createTextStyle({
4042
fontSize: 16,
4143
color: 'black'
44+
}),
45+
progressMargin: RX.Styles.createViewStyle({
46+
margin: 16
4247
})
4348
};
4449

4550
class App extends RX.Component<null, AppState> {
4651
private _translationValue: RX.Animated.Value;
4752
private _animatedStyle: RX.Types.AnimatedTextStyleRuleSet;
53+
private _progressTimerToken: number;
4854

4955
constructor() {
5056
super();
@@ -59,7 +65,8 @@ class App extends RX.Component<null, AppState> {
5965
});
6066

6167
this.state = {
62-
toggleValue: true
68+
toggleValue: true,
69+
progressValue: 0
6370
};
6471
}
6572

@@ -72,6 +79,12 @@ class App extends RX.Component<null, AppState> {
7279
);
7380

7481
animation.start();
82+
83+
this._startProgressIndicator();
84+
}
85+
86+
componentWillUnmount() {
87+
this._stopProgressIndicator();
7588
}
7689

7790
render(): JSX.Element | null {
@@ -97,10 +110,34 @@ class App extends RX.Component<null, AppState> {
97110
value={ this.state.toggleValue }
98111
onChange={ this._onChangeToggle }
99112
/>
113+
114+
<RX.Text style={ styles.toggleTitle }>
115+
Here is an SVG image using a ReactXP extension
116+
</RX.Text>
117+
<ProgressIndicator
118+
style={ styles.progressMargin }
119+
progress={ this.state.progressValue }
120+
fillColor={ '#ccc' }
121+
size={ 32 }
122+
/>
100123
</RX.View>
101124
);
102125
}
103126

127+
private _startProgressIndicator() {
128+
this._progressTimerToken = window.setInterval(() => {
129+
const newProgressValue = (this.state.progressValue + 0.02) % 1;
130+
this.setState({ progressValue: newProgressValue });
131+
}, 1000 / 15);
132+
}
133+
134+
private _stopProgressIndicator() {
135+
if (this._progressTimerToken) {
136+
window.clearInterval(this._progressTimerToken);
137+
this._progressTimerToken = undefined;
138+
}
139+
}
140+
104141
// Note that we define this as a variable rather than a normal method. Using this
105142
// method, we prebind the method to this component instance. This prebinding ensures
106143
// that each time we pass the variable as a prop in the render function, it will

0 commit comments

Comments
 (0)