Skip to content

Commit 968682b

Browse files
committed
fix: types and handlers
1 parent ff66244 commit 968682b

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/components/Button/Button.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as React from 'react';
2-
import { AccessibilityProps, TouchableHighlight, View } from 'react-native';
2+
import {
3+
AccessibilityProps,
4+
GestureResponderEvent,
5+
TouchableHighlight,
6+
View,
7+
} from 'react-native';
38
import { DeepPartial } from 'ts-essentials';
49

510
import { Theme, withTheme } from '../../theme';
@@ -65,7 +70,7 @@ export interface ButtonProps extends AccessibilityProps {
6570
* Button press handler
6671
* @default () => {}
6772
*/
68-
onPress?: () => void;
73+
onPress?: (event: GestureResponderEvent) => void;
6974

7075
/**
7176
* Sets an icon before the text.

src/components/ListItem/ListItem.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import {
33
AccessibilityProps,
4+
GestureResponderEvent,
45
ImageSourcePropType,
56
TouchableHighlight,
67
View,
@@ -27,6 +28,7 @@ export interface ListItemProps extends AccessibilityProps {
2728
imageSource?: ImageSourcePropType;
2829
avatarProps?: AvatarProps;
2930
rightIcon?: React.ReactNode;
31+
onPress?: (event: GestureResponderEvent) => void;
3032
getStyles?: ReplaceReturnType<GetListItemStyles, DeepPartial<ListItemStyles>>;
3133
testID?: string;
3234
}
@@ -39,6 +41,7 @@ const ListItemBase = (props: ListItemProps) => {
3941
description,
4042
imageSource,
4143
size = 'medium',
44+
onPress,
4245
rightIcon = null,
4346
theme,
4447
avatarProps,
@@ -62,6 +65,7 @@ const ListItemBase = (props: ListItemProps) => {
6265
underlayColor={focusBackgroundColor}
6366
style={containerStyle}
6467
testID={testID}
68+
onPress={onPress}
6569
{...accessibilityProps}
6670
>
6771
<View style={wrapperStyle}>

src/components/Switch/Switch.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as React from 'react';
2-
import { AccessibilityProps, Animated, TouchableOpacity } from 'react-native';
2+
import {
3+
AccessibilityProps,
4+
Animated,
5+
GestureResponderEvent,
6+
TouchableOpacity,
7+
} from 'react-native';
38
import { DeepPartial } from 'ts-essentials';
49

510
import { Icon } from '../../icons';
@@ -15,7 +20,7 @@ import {
1520
export interface SwitchProps extends AccessibilityProps {
1621
isSwitchedOn?: boolean;
1722
isDisabled?: boolean;
18-
onChange?: () => void;
23+
onChange?: (event: GestureResponderEvent) => void;
1924
onIcon?: React.ReactNode;
2025
offIcon?: React.ReactNode;
2126
duration?: number;
@@ -84,11 +89,11 @@ class SwitchBase extends React.Component<SwitchProps, SwitchState> {
8489
}
8590
}
8691

87-
public handleOnPress = () => {
92+
public handleOnPress = (e: GestureResponderEvent) => {
8893
const { onChange } = this.props;
8994
this.runAnimation();
9095

91-
if (onChange) onChange();
96+
if (onChange) onChange(e);
9297
};
9398

9499
public runAnimation = () => {

src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export * from './ListItem';
1313
export * from './Loading';
1414
export * from './Modal';
1515
export * from './Overlay';
16-
export * from './Picker';
16+
export * from './Pickers';
1717
export * from './Positioner';
1818
export * from './Popover';
1919
export * from './Progress';

0 commit comments

Comments
 (0)