Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from incorelabs/master
Added Expo Demo, small updated to Sample and Screenshots
- Loading branch information
Showing
8 changed files
with
144 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.