Skip to content

Commit 3f99ea6

Browse files
committed
- Remove deprecated prop-types
- Update index.d.ts - Convert TouchableEffect to a function
1 parent 215f3bc commit 3f99ea6

File tree

7 files changed

+34
-120
lines changed

7 files changed

+34
-120
lines changed

index.d.ts

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
1-
declare module 'react-native-simple-dialogs' {
2-
import * as React from 'react';
3-
import {
4-
StyleProp,
5-
ViewStyle,
6-
TextStyle,
7-
} from 'react-native';
8-
9-
type animationType = 'none' | 'slide' | 'fade';
10-
11-
type supportedOrientationsType =
12-
| 'portrait'
13-
| 'portrait-upside-down'
14-
| 'landscape'
15-
| 'landscape-left'
16-
| 'landscape-right';
17-
18-
type keyboardDismissModeType = 'none' | 'on-drag' | 'interactive';
1+
import * as React from 'react';
2+
import {
3+
StyleProp,
4+
ViewStyle,
5+
TextStyle,
6+
ScrollViewProps,
7+
ActivityIndicatorProps,
8+
ModalProps,
9+
TouchableNativeFeedbackProps,
10+
TouchableOpacityProps,
11+
} from 'react-native';
1912

20-
type keyboardShouldPersistTapsType =
21-
| 'always'
22-
| 'never'
23-
| 'handled'
24-
| false
25-
| true;
13+
declare module 'react-native-simple-dialogs' {
2614

2715
type activityIndicatorSizeType = 'small' | 'large' | number;
2816

2917
export interface BaseProps {
3018
visible?: boolean;
3119
onRequestClose?: () => void;
32-
animationType?: animationType;
20+
animationType?: ModalProps['animationType'];
3321
onShow?: () => void;
3422
onOrientationChange?: () => void;
35-
supportedOrientations?: supportedOrientationsType[];
23+
supportedOrientations?: ModalProps['supportedOrientations'];
3624
onTouchOutside?: () => void;
3725
title?: string;
3826
titleStyle?: StyleProp<TextStyle>;
@@ -41,9 +29,9 @@ declare module 'react-native-simple-dialogs' {
4129
buttonsStyle?: StyleProp<ViewStyle>;
4230
overlayStyle?: StyleProp<ViewStyle>;
4331
buttons?: React.ReactNode | React.ReactNode[] | JSX.Element
44-
keyboardDismissMode?: keyboardDismissModeType;
45-
keyboardShouldPersistTaps?: keyboardShouldPersistTapsType;
46-
contentInsetAdjustmentBehavior?: 'automatic' | 'scrollableAxes' | 'never' | 'always';
32+
keyboardDismissMode?: ScrollViewProps['keyboardDismissMode'];
33+
keyboardShouldPersistTaps?: ScrollViewProps['keyboardShouldPersistTaps'];
34+
contentInsetAdjustmentBehavior?: ScrollViewProps['contentInsetAdjustmentBehavior'];
4735
}
4836

4937
export interface DialogProps extends BaseProps {
@@ -53,9 +41,9 @@ declare module 'react-native-simple-dialogs' {
5341
export interface ProgressDialogProps extends BaseProps {
5442
message: string;
5543
messageStyle?: StyleProp<TextStyle>;
56-
activityIndicatorColor?: string;
57-
activityIndicatorSize?: activityIndicatorSizeType;
58-
activityIndicatorStyle?: StyleProp<ViewStyle>;
44+
activityIndicatorColor?: ActivityIndicatorProps['color'];
45+
activityIndicatorSize?: ActivityIndicatorProps['size'];
46+
activityIndicatorStyle?: ActivityIndicatorProps['style'];
5947
}
6048

6149
export interface ButtonProps {
@@ -75,7 +63,10 @@ declare module 'react-native-simple-dialogs' {
7563
}
7664

7765
export class Dialog extends React.Component<DialogProps> { }
66+
7867
export class ProgressDialog extends React.Component<ProgressDialogProps> { }
68+
7969
export class ConfirmDialog extends React.Component<ConfirmDialogProps> { }
80-
export class TouchableEffect extends React.Component<Props> { }
70+
71+
export declare const TouchableEffect: React.FC<TouchableNativeFeedbackProps & TouchableOpacityProps>;
8172
}

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ export {
3131
Dialog,
3232
ProgressDialog,
3333
ConfirmDialog,
34-
TouchableEffect
35-
}
34+
TouchableEffect,
35+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-simple-dialogs",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Cross-platform simple dialogs for React Native based on the Modal component. ⚛",
55
"private": false,
66
"repository": {

src/ConfirmDialog.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@
2525
import React, { Component } from 'react'
2626
import {
2727
View,
28-
ViewPropTypes,
2928
Text,
3029
Platform
3130
} from 'react-native'
3231
const { OS } = Platform;
3332

34-
import PropTypes from 'prop-types';
35-
3633
import Dialog from './Dialog'
3734
import TouchableEffect from './TouchableEffect';
3835

@@ -162,26 +159,4 @@ class ConfirmDialog extends Component {
162159
}
163160
}
164161

165-
const buttonPropType = PropTypes.shape({
166-
title: PropTypes.string.isRequired,
167-
onPress: PropTypes.func.isRequired,
168-
disabled: PropTypes.bool,
169-
titleStyle: PropTypes.shape({
170-
...Text.propTypes.style,
171-
colorDisabled: PropTypes.string,
172-
}),
173-
style: PropTypes.shape({
174-
...ViewPropTypes.style,
175-
backgroundColorDisabled: PropTypes.string,
176-
})
177-
});
178-
179-
ConfirmDialog.propTypes = {
180-
...Dialog.propTypes,
181-
message: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
182-
messageStyle: Text.propTypes.style,
183-
negativeButton: buttonPropType,
184-
positiveButton: buttonPropType.isRequired
185-
}
186-
187162
export default ConfirmDialog

src/Dialog.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ import React, { Component } from 'react'
2626
import {
2727
Modal,
2828
View,
29-
ViewPropTypes,
3029
TouchableWithoutFeedback,
3130
Text,
3231
Platform,
3332
SafeAreaView,
3433
ScrollView
3534
} from 'react-native'
36-
const { OS } = Platform;
3735

38-
import PropTypes from 'prop-types';
36+
const { OS } = Platform;
3937

4038
class Dialog extends Component {
4139

@@ -143,7 +141,7 @@ class Dialog extends Component {
143141
backgroundColor: "#000000AA",
144142
padding: 24
145143
}, overlayStyle]}>
146-
<SafeAreaView style={{flex: 1}}>
144+
<SafeAreaView style={{ flex: 1 }}>
147145
{this._renderOutsideTouchable(onTouchOutside)}
148146

149147
<View style={[{
@@ -176,23 +174,6 @@ class Dialog extends Component {
176174
}
177175
}
178176

179-
Dialog.propTypes = {
180-
dialogStyle: ViewPropTypes.style,
181-
contentStyle: ViewPropTypes.style,
182-
buttonsStyle: ViewPropTypes.style,
183-
overlayStyle: ViewPropTypes.style,
184-
buttons: PropTypes.element,
185-
visible: PropTypes.bool,
186-
onRequestClose: PropTypes.func,
187-
onShow: PropTypes.func,
188-
onTouchOutside: PropTypes.func,
189-
title: PropTypes.string,
190-
titleStyle: Text.propTypes.style,
191-
keyboardDismissMode: PropTypes.string,
192-
keyboardShouldPersistTaps: PropTypes.string,
193-
contentInsetAdjustmentBehavior: PropTypes.string,
194-
}
195-
196177
Dialog.defaultProps = {
197178
visible: false,
198179
onRequestClose: () => null,

src/ProgressDialog.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
*/
2424

2525
import React, { Component } from 'react'
26-
import PropTypes from 'prop-types';
2726
import {
2827
View,
2928
ActivityIndicator,
3029
Text,
31-
ViewPropTypes
3230
} from 'react-native';
3331

3432
import Dialog from './Dialog'
@@ -50,18 +48,4 @@ class ProgressDialog extends Component {
5048
}
5149
}
5250

53-
ProgressDialog.propTypes = {
54-
...Dialog.propTypes,
55-
message: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
56-
messageStyle: Text.propTypes.style,
57-
activityIndicatorColor: PropTypes.string,
58-
activityIndicatorSize: PropTypes.oneOfType([
59-
PropTypes.string,
60-
PropTypes.number
61-
]),
62-
activityIndicatorStyle: ViewPropTypes.style
63-
}
64-
65-
delete ProgressDialog.propTypes.children;
66-
6751
export default ProgressDialog

src/TouchableEffect.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,12 @@ import {
3131

3232
const { OS } = Platform;
3333

34-
class TouchableEffect extends Component {
35-
36-
render() {
37-
let touchable;
38-
39-
if (OS === 'android') {
40-
touchable = <TouchableNativeFeedback {...this.props} />
41-
} else {
42-
touchable = <TouchableOpacity {...this.props} />
43-
}
44-
45-
return touchable;
34+
const TouchableEffect = (props) => {
35+
if (OS === 'android') {
36+
return <TouchableNativeFeedback {...props} />;
4637
}
47-
}
4838

49-
if (OS === 'android') {
50-
TouchableEffect.propTypes = { ...TouchableNativeFeedback.propTypes };
51-
} else {
52-
TouchableEffect.propTypes = { ...TouchableOpacity.propTypes };
39+
return <TouchableOpacity {...props} />;
5340
}
5441

55-
TouchableEffect.defaultProps = {
56-
background: OS === 'android' ? TouchableNativeFeedback.SelectableBackground() : undefined
57-
};
58-
59-
export default TouchableEffect
42+
export default TouchableEffect;

0 commit comments

Comments
 (0)