Skip to content

Commit

Permalink
Merge pull request #24 from incorelabs/master
Browse files Browse the repository at this point in the history
Added Expo Demo, small updated to Sample and Screenshots
  • Loading branch information
douglasjunior committed Oct 21, 2018
2 parents 59ab30c + 20a0071 commit 8e7b3ab
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 85 deletions.
10 changes: 7 additions & 3 deletions README.md
Expand Up @@ -12,13 +12,17 @@ Cross-platform simple dialogs for React Native based on the Modal component. ⚛
- [Confirm Dialog](#confirm-dialog)
- [Progress Dialog](#progress-dialog)

## Expo Snack
An
[Expo Demo Link](https://snack.expo.io/@incorelabs/react-native-simple-dialogs-example)

## Screenshots

| Android | iOS |
| - | - |
| <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/android-dialog.png' width='240' /> | <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/ios-dialog.png' width='240' /> |
| <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/android-confirm.png' width='240' /> | <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/ios-confirm.png' width='240' /> |
| <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/android-progress.png' width='240' /> | <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/ios-progress.png' width='240' /> |
| <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/android-dialog.png' width='320' /> | <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/ios-dialog.png' width='320' /> |
| <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/android-confirm.png' width='320' /> | <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/ios-confirm.png' width='320' /> |
| <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/android-progress.png' width='320' /> | <img src='https://raw.githubusercontent.com/douglasjunior/react-native-simple-dialogs/master/screenshots/ios-progress.png' width='320' /> |

## Requirements

Expand Down
219 changes: 137 additions & 82 deletions Sample/src/App.js
@@ -1,141 +1,196 @@
import React, { Component } from 'react';
import React, { Component } from "react";
import {
Alert,
AppRegistry,
Button,
Image,
StyleSheet,
Text,
View,
Button,
Image,
} from 'react-native';
} from "react-native";
import { Dialog, ProgressDialog, ConfirmDialog } from "react-native-simple-dialogs";

import {
Dialog,
ProgressDialog,
ConfirmDialog,
} from 'react-native-simple-dialogs'
const styles = StyleSheet.create({
container: {
alignItems: "center",
backgroundColor: "#F5FCFF",
flex: 1,
justifyContent: "center",
},
welcomeText: {
fontSize: 20,
margin: 10,
textAlign: "center",
},
exampleText: {
fontSize: 20,
marginBottom: 25,
textAlign: "center",
},
instructionsText: {
color: "#333333",
fontSize: 16,
marginBottom: 40,
textAlign: "center",
},
});

export default class App extends Component {

state = {}

openDialog = show => {
this.setState({ showDialog: show })
openDialog = (show) => {
this.setState({ showDialog: show });
}

openConfirm = show => {
this.setState({ showConfirm: show })
openConfirm = (show) => {
this.setState({ showConfirm: show });
}

openProgress = () => {
this.setState({ showProgress: true })
this.setState({ showProgress: true });

setTimeout(
() => this.setState({ showProgress: false }),
4000
() => {
this.setState({ showProgress: false });
},
4000,
);
}

optionYes = () => {
this.openConfirm(false);
// Yes, this is a workaround :(
// Why? See this https://github.com/facebook/react-native/issues/10471
setTimeout(() => alert("Yes touched!"), 100);
setTimeout(
() => {
Alert.alert("The YES Button touched!");
},
300,
);
}

optionNo = () => {
this.openConfirm(false);
// Yes, this is a workaround :(
// Why? See this https://github.com/facebook/react-native/issues/10471
setTimeout(() => alert("No touched!"), 100);
setTimeout(
() => {
Alert.alert("The NO Button touched!");
},
300,
);
}

render() {
return (
<View style={styles.container}>

<Text style={styles.welcome}>Welcome to React Native Simple Dialogs!</Text>
<Text style={styles.instructions}>To get started, touch on the buttons</Text>

<Button onPress={() => this.openDialog(true)} title="Custom Dialog" />
<View style={ styles.container }>

<Text style={ styles.welcomeText }>
Welcome to React Native Simple Dialogs!
</Text>
<Text style={ styles.exampleText }>
Examples
</Text>
<Text style={ styles.instructionsText }>
To get started, touch on the buttons
</Text>

<Button
onPress={ () => this.openDialog(true) }
title="Custom Dialog"
/>

<View style={{ height: 10 }}></View>
<View style={ { height: 40 } } />

<Button onPress={() => this.openConfirm(true)} title="Confirm Dialog" />
<Button
onPress={ () => this.openConfirm(true) }
title="Confirm Dialog"
/>

<View style={{ height: 10 }}></View>
<View style={ { height: 40 } } />

<Button onPress={this.openProgress} title="Progress Dialog" />
<Button
onPress={ this.openProgress }
title="Progress Dialog"
/>

<Dialog
visible={this.state.showDialog}
title="Custom Dialog"
onTouchOutside={() => this.openDialog(false)}
contentStyle={{ justifyContent: 'center', alignItems: 'center', }}
animationType="fade">
animationType="fade"
contentStyle={
{
alignItems: "center",
justifyContent: "center",
}
}
onTouchOutside={ () => this.openDialog(false) }
visible={ this.state.showDialog }
>
<Image
source={{ uri: "http://facebook.github.io/react-native/img/opengraph.png" }}
resizeMode="contain"
resizeMethod="scale"
style={{ marginBottom: 10, height: 50, width: 100 }} />
<Text style={{ marginBottom: 10 }}>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</Text>
<Button onPress={() => this.openDialog(false)} style={{ marginTop: 10 }} title="CLOSE" />
source={
{
uri: "https://facebook.github.io/react-native/img/header_logo.png",
}
}
style={
{
width: 99,
height: 87,
backgroundColor: "black",
marginTop: 10,
resizeMode: "contain",
}
}
/>
<Text style={ { marginVertical: 30 } }>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</Text>
<Button
onPress={ () => this.openDialog(false) }
style={ { marginTop: 10 } }
title="CLOSE"
/>
</Dialog>

<ConfirmDialog
title="Confirm Dialog"
message="Are you sure about that?"
visible={this.state.showConfirm}
onTouchOutside={() => this.openConfirm(false)}
positiveButton={{
title: "YES",
onPress: this.optionYes
}}
negativeButton={{
title: "NO",
onPress: this.optionNo,
disabled: true,
titleStyle: {
color: 'blue',
colorDisabled: 'aqua',
},
style: {
backgroundColor: 'transparent',
backgroundColorDisabled: 'transparent',
},
}}
onTouchOutside={ () => this.openConfirm(false) }
visible={ this.state.showConfirm }
negativeButton={
{
title: "NO",
onPress: this.optionNo,
// disabled: true,
titleStyle: {
color: "blue",
colorDisabled: "aqua",
},
style: {
backgroundColor: "transparent",
backgroundColorDisabled: "transparent",
},
}
}
positiveButton={
{
title: "YES",
onPress: this.optionYes,
}
}
/>

<ProgressDialog
visible={this.state.showProgress}
title="Progress Dialog"
message="Please, wait..."
animationType="slide"
activityIndicatorSize="large"
activityIndicatorColor="blue"
activityIndicatorSize="large"
animationType="slide"
message="Please, wait..."
visible={ this.state.showProgress }
/>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 20,
},
});

AppRegistry.registerComponent('Sample', () => App);
Binary file modified screenshots/android-confirm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/android-dialog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/android-progress.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/ios-confirm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/ios-dialog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/ios-progress.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8e7b3ab

Please sign in to comment.