Commit c01dd8a7 authored by xwenliang's avatar xwenliang

example debug

parent 0be959c1
...@@ -5,7 +5,7 @@ import re ...@@ -5,7 +5,7 @@ import re
# - install Buck # - install Buck
# - `npm start` - to start the packager # - `npm start` - to start the packager
# - `cd android` # - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US` # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application # - `buck install -r android/app` - compile, install and run application
# #
......
...@@ -55,7 +55,13 @@ import com.android.build.OutputFile ...@@ -55,7 +55,13 @@ import com.android.build.OutputFile
* // date; if you have any other folders that you want to ignore for performance reasons (gradle * // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here. * // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"] * inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"]
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ] * ]
*/ */
...@@ -120,6 +126,7 @@ android { ...@@ -120,6 +126,7 @@ android {
} }
dependencies { dependencies {
compile project(':react-native-picker')
compile fileTree(dir: "libs", include: ["*.jar"]) compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1" compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules compile "com.facebook.react:react-native:+" // From node_modules
......
...@@ -26,11 +26,14 @@ ...@@ -26,11 +26,14 @@
# See http://sourceforge.net/p/proguard/bugs/466/ # See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
# Do not strip any method/class that is annotated with @DoNotStrip # Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class * -keep @com.facebook.proguard.annotations.DoNotStrip class *
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * { -keepclassmembers class * {
@com.facebook.proguard.annotations.DoNotStrip *; @com.facebook.proguard.annotations.DoNotStrip *;
@com.facebook.common.internal.DoNotStrip *;
} }
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
...@@ -51,9 +54,9 @@ ...@@ -51,9 +54,9 @@
-keepattributes Signature -keepattributes Signature
-keepattributes *Annotation* -keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; } -keep class okhttp3.** { *; }
-keep interface com.squareup.okhttp.** { *; } -keep interface okhttp3.** { *; }
-dontwarn com.squareup.okhttp.** -dontwarn okhttp3.**
# okio # okio
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
android:targetSdkVersion="22" /> android:targetSdkVersion="22" />
<application <application
android:name=".MainApplication"
android:allowBackup="true" android:allowBackup="true"
android:label="@string/app_name" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
......
package com.pickertest; package com.pickertest;
import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;
public class MainActivity extends ReactActivity { public class MainActivity extends ReactActivity {
...@@ -17,24 +12,4 @@ public class MainActivity extends ReactActivity { ...@@ -17,24 +12,4 @@ public class MainActivity extends ReactActivity {
protected String getMainComponentName() { protected String getMainComponentName() {
return "PickerTest"; return "PickerTest";
} }
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
} }
package com.pickertest;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.beefe.picker.PickerViewPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new PickerViewPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
<resources> <resources>
<string name="app_name">PickerTest</string> <string name="app_name">PickerTest</string>
</resources> </resources>
...@@ -18,7 +18,7 @@ allprojects { ...@@ -18,7 +18,7 @@ allprojects {
jcenter() jcenter()
maven { maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../../node_modules/react-native/android" url "$rootDir/../node_modules/react-native/android"
} }
} }
} }
rootProject.name = 'PickerTest' rootProject.name = 'PickerTest'
include ':app' include ':app'
include ':react-native-picker'
project(':react-native-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-picker/android')
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* https://github.com/facebook/react-native * https://github.com/facebook/react-native
*/ */
import React, {Component} from 'react' import React, {Component} from 'react';
import { import {
View, View,
Text, Text,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* https://github.com/facebook/react-native * https://github.com/facebook/react-native
*/ */
import React, {Component} from 'react' import React, {Component} from 'react';
import { import {
View, View,
Text, Text,
...@@ -50,27 +50,31 @@ class PickerTest extends Component { ...@@ -50,27 +50,31 @@ class PickerTest extends Component {
} }
_onPressHandle() { _onPressHandle() {
this.picker.toggle(); Picker.init({
pickerData: createDateData(),
selectedValue: ['2015年', '12月', '12日'],
onPickerConfirm: pickedValue => {
alert(JSON.stringify(pickedValue));
console.log(pickedValue);
},
onPickerCancel: pickedValue => {
alert(JSON.stringify(pickedValue));
console.log(pickedValue);
},
onPickerSelect: pickedValue => {
alert(JSON.stringify(pickedValue));
console.log(pickedValue);
}
});
Picker.show();
} }
render(){ render() {
return ( return (
<View style={{height: Dimensions.get('window').height}}> <View style={{height: Dimensions.get('window').height}}>
<TouchableOpacity style={{marginTop: 20}} onPress={this._onPressHandle.bind(this)}> <TouchableOpacity style={{marginTop: 20}} onPress={this._onPressHandle.bind(this)}>
<Text>Click Me</Text> <Text>Click Me</Text>
</TouchableOpacity> </TouchableOpacity>
<Picker
ref={picker => this.picker = picker}
style={{height: 260}}
showMask={true}
showDuration={300}
pickerData={createDateData()}
selectedValue={['2015年', '12月', '12日']}
onPickerDone={(pickedValue) => {
alert(JSON.stringify(pickedValue));
console.log(pickedValue);
}}
/>
</View> </View>
); );
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h" #import "RCTRootView.h"
@implementation AppDelegate @implementation AppDelegate
...@@ -17,36 +18,13 @@ ...@@ -17,36 +18,13 @@
{ {
NSURL *jsCodeLocation; NSURL *jsCodeLocation;
/** jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
/**
* OPTION 2
* Load from pre-bundled file on disk. The static bundle is automatically
* generated by the "Bundle React Native code and images" build step when
* running the project on an actual device or running the project on the
* simulator in the "Release" build configuration.
*/
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"PickerTest" moduleName:@"PickerTest"
initialProperties:nil initialProperties:nil
launchOptions:launchOptions]; launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new]; UIViewController *rootViewController = [UIViewController new];
......
...@@ -38,11 +38,17 @@ ...@@ -38,11 +38,17 @@
<false/> <false/>
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationWhenInUseUsageDescription</key>
<string></string> <string></string>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>
<dict> <!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ --> <dict>
<key>NSAllowsArbitraryLoads</key> <key>NSExceptionDomains</key>
<true/> <dict>
</dict> <key>localhost</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict> </dict>
</plist> </plist>
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
"start": "node_modules/react-native/packager/packager.sh" "start": "node_modules/react-native/packager/packager.sh"
}, },
"dependencies": { "dependencies": {
"react": "15.0.2", "react": "15.3.1",
"react-native": "^0.26.1", "react-native": "^0.32.0",
"react-native-picker": "beefe/react-native-picker" "react-native-picker": "beefe/react-native-picker"
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment