diff --git a/examples/ExampleApp/android/app/app.iml b/examples/ExampleApp/android/app/app.iml index a4d654b..37ecc41 100644 --- a/examples/ExampleApp/android/app/app.iml +++ b/examples/ExampleApp/android/app/app.iml @@ -114,6 +114,7 @@ + \ No newline at end of file diff --git a/examples/ExampleApp/android/app/build.gradle b/examples/ExampleApp/android/app/build.gradle index c08b31b..0cc8b19 100644 --- a/examples/ExampleApp/android/app/build.gradle +++ b/examples/ExampleApp/android/app/build.gradle @@ -31,4 +31,5 @@ dependencies { compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.facebook.react:react-native:0.13.+' compile project(':react-native-dialogs') + compile project(':RNMaterialKit') } diff --git a/examples/ExampleApp/android/app/src/main/java/com/exampleapp/MainActivity.java b/examples/ExampleApp/android/app/src/main/java/com/exampleapp/MainActivity.java index 7368435..992d374 100644 --- a/examples/ExampleApp/android/app/src/main/java/com/exampleapp/MainActivity.java +++ b/examples/ExampleApp/android/app/src/main/java/com/exampleapp/MainActivity.java @@ -13,6 +13,7 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.aakashns.reactnativedialogs.Test; +import com.github.xinthink.rnmk.ReactMaterialKitPackage; public class MainActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler { @@ -31,6 +32,7 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac .setJSMainModuleName("index.android") .addPackage(new MainReactPackage()) .addPackage(new ReactNativeDialogsPackage(this)) + .addPackage(new ReactMaterialKitPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED) .build(); diff --git a/examples/ExampleApp/android/settings.gradle b/examples/ExampleApp/android/settings.gradle index b759f4d..d07eb54 100644 --- a/examples/ExampleApp/android/settings.gradle +++ b/examples/ExampleApp/android/settings.gradle @@ -1,4 +1,5 @@ rootProject.name = 'ExampleApp' -include ':react-native-dialogs', ':app' +include ':react-native-dialogs', ':RNMaterialKit', ':app' project(':react-native-dialogs').projectDir = new File(rootProject.projectDir, '../../../android') +project(':RNMaterialKit').projectDir = file('../node_modules/react-native-material-kit/android') diff --git a/examples/ExampleApp/dialogData.js b/examples/ExampleApp/dialogData.js index 0b24ceb..d7886af 100644 --- a/examples/ExampleApp/dialogData.js +++ b/examples/ExampleApp/dialogData.js @@ -3,6 +3,12 @@ import { ToastAndroid } from 'react-native'; var toastCallback = (id, text) => ToastAndroid.show(id + ": " + text, ToastAndroid.SHORT); +var toastMultiChoiceCallback = (ids, items) => { + ToastAndroid.show( + ids.map((id, i) => String(id) + " : " + String(items[i])).toString(), + ToastAndroid.SHORT); +} + var socialNetworks = [ "Twitter", "Google+", @@ -222,7 +228,7 @@ export default [ items: socialNetworks, positiveText: "Choose", title: "Social Networks", - itemsCallbackMultiChoice: toastCallback, + itemsCallbackMultiChoice: toastMultiChoiceCallback, positiveCallback: () => 23, "multiChoiceClearButton": true } @@ -233,7 +239,7 @@ export default [ items: socialNetworksLong, positiveText: "Choose", title: "Social Networks", - itemsCallbackMultiChoice: toastCallback + itemsCallbackMultiChoice: toastMultiChoiceCallback } }, ] diff --git a/examples/ExampleApp/index.android.js b/examples/ExampleApp/index.android.js index 5a075f9..1d31f76 100644 --- a/examples/ExampleApp/index.android.js +++ b/examples/ExampleApp/index.android.js @@ -6,37 +6,20 @@ var { View, NativeModules, TouchableNativeFeedback, + ScrollView, } = React; import DialogAndroid from 'react-native-dialogs'; import dialogData from './dialogData.js'; +import {MKButton } from 'react-native-material-kit'; + + class ExampleApp extends React.Component { constructor(props) { super(props); - - this.state = {selected: 0}; - } - - handleClick() { - var dialog = new DialogAndroid(); - - dialog.set({ - title: "Country", - items: [ - "India", - "United States", - "China", - "Russia", - ], - positiveText: "Hola", - selectedIndex: this.state.selected, - itemsCallbackSingleChoice: (i) => this.setState({selected: i}), - }); - - dialog.show(); } showDialog(options) { @@ -48,19 +31,19 @@ class ExampleApp extends React.Component { render() { var dialogs = dialogData.map((section, i) => { - var sectionDialogNodes = section.dialogs.map((op, j) => - this.showDialog( - op.data || { title: "NOT IMPLEMENTED!! :-(", positiveText: "OK"})}> - - - {op.buttonText} - + var sectionDialogNodes = section.dialogs.map((op, j) => { + const ColoredRaisedButton = MKButton.coloredButton() + .withText(op.buttonText) + .withOnPress(c => this.showDialog( + op.data || { title: "NOT IMPLEMENTED!! :-(", positiveText: "OK"})) + .withStyle({width: 200}) + .build(); + return ( + + - - ); + ); + }); return ( @@ -71,22 +54,11 @@ class ExampleApp extends React.Component { }); return ( - - - Welcome to React Native! - - this.handleClick(c)}> - - - To get started, edit index.android.js - - - - - {"Selected : " + this.state.selected} - - {dialogs} - + + + {dialogs} + + ); } } @@ -110,7 +82,7 @@ var styles = StyleSheet.create({ textAlign: 'center', color: '#333333', marginBottom: 5, - }, + } }); AppRegistry.registerComponent('ExampleApp', () => ExampleApp); diff --git a/examples/ExampleApp/package.json b/examples/ExampleApp/package.json index 961f266..7934528 100644 --- a/examples/ExampleApp/package.json +++ b/examples/ExampleApp/package.json @@ -7,6 +7,7 @@ }, "dependencies": { "react-native": "^0.13.2", - "react-native-dialogs": "file:///Users/aakashns/workspace/opensource/react-native-dialogs" + "react-native-dialogs": "file:///Users/aakashns/workspace/opensource/react-native-dialogs", + "react-native-material-kit": "^0.2.2" } }