react-native-popup-dialog: PopupDialog show and dismiss methods typings (#27065)

* react-native-popupdialog: PopupDialog show and dismiss method typings

* react-native-popupdialog: PopupDialog show and dismiss methods typings

* react-native-popup-dialog show/dimiss methods tests

* tslint
This commit is contained in:
Michele Bombardi
2018-07-06 09:40:42 -07:00
committed by Mohamed Hegazy
parent a315fbc373
commit 697b7e6029
2 changed files with 37 additions and 7 deletions
+6 -2
View File
@@ -1,7 +1,8 @@
// Type definitions for react-native-popup-dialog 0.9
// Type definitions for react-native-popup-dialog 1.0
// Project: https://github.com/jacklam718/react-native-popup-dialog/blob/master/README.md
// Definitions by: Paito Anderson <https://github.com/PaitoAnderson>
// connectdotz <https://github.com/connectdotz>
// Michele Bombardi <https://github.com/bm-software>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
@@ -83,4 +84,7 @@ export class SlideAnimation {
export class DialogButton extends React.Component<DialogButtonProps, any> { }
export class DialogTitle extends React.Component<DialogTitleProps, any> { }
export class Overlay extends React.Component<OverlayProps, any> { }
export default class PopupDialog extends React.Component<PopupDialogProps, any> { }
export default class PopupDialog extends React.Component<PopupDialogProps, any> {
show(onShown?: () => void): void;
dismiss(onDismissed?: () => void): void;
}
@@ -1,5 +1,5 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import { StyleSheet, View, Button } from 'react-native';
import PopupDialog, {
DialogTitle,
DialogButton,
@@ -13,26 +13,52 @@ const scaleAnimation = new ScaleAnimation();
const fadeAnimation = new FadeAnimation({ animationDuration: 150 });
class Test extends React.Component<any> {
fadingPopupDialog: PopupDialog | null;
scalingPopupDialog: PopupDialog | null;
slidingPopupDialog: PopupDialog | null;
showPopupDialog(popupDialog: PopupDialog | null) {
if (popupDialog !== null) {
popupDialog.show(() => console.log('show callback'));
}
}
dismissPopupDialog(popupDialog: PopupDialog | null) {
if (popupDialog !== null) {
popupDialog.dismiss(() => console.log('dismiss callback'));
}
}
render() {
return (
<View>
<PopupDialog
<Button
onPress={() => this.showPopupDialog(this.fadingPopupDialog)}
title="Show Fading Dialog" />
<Button
onPress={() => this.showPopupDialog(this.scalingPopupDialog)}
title="Show Scaling Dialog" />
<Button
onPress={() => this.showPopupDialog(this.slidingPopupDialog)}
title="Show Sliding Dialog" />
<PopupDialog ref={(popupDialog) => this.fadingPopupDialog = popupDialog}
dialogTitle={<DialogTitle title="Popup Dialog - Fade Animation" />}
dialogAnimation={fadeAnimation}
/>
<PopupDialog
<PopupDialog ref={(popupDialog) => this.scalingPopupDialog = popupDialog}
dialogTitle={<DialogTitle title="Popup Dialog - Scale Animation" />}
dialogAnimation={scaleAnimation}
actions={[
<DialogButton
text="CLOSE"
onPress={(event) => { }}
onPress={(event) => this.dismissPopupDialog(this.scalingPopupDialog)}
textStyle={{ color: "red" }}
key="button-1"
/>,
]}
/>
<PopupDialog
<PopupDialog ref={(popupDialog) => this.slidingPopupDialog = popupDialog}
dialogTitle={<DialogTitle title="Popup Dialog - Slide Animation" />}
width={300}
height={300}