Skip to content

Commit 1bef83d

Browse files
committed
Fix not passing close to controls prop
1 parent c329cb6 commit 1bef83d

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ Prop name | Description | Type | Default value | Platform |
5858
--------------------|---------------|-----------|---------------|----------|
5959
`animationType` | Type of animation modal presented with | "none", "fade", "slide" | "none" |
6060
`backgroundColor` | Background color of the modal in HEX (#0099CC) | string | null |
61+
`controls` | Config of available controls (see below) | Object | {close: true} |
6162
`glideAlways` | Emulates ScrollView glide animation if built-in was not triggered | boolean | false | Android
6263
`glideAlwaysDelay` | Defines delay in milliseconds for glideAlways | number | 75 | Android
6364
`images` | Array of images to display, see below image item description | array | [] |
6465
`imageIndex` | Current index of image to display | number | 0 |
6566
`isVisible` | Is modal shown or not | boolean | false |
6667
`onClose` | Function called on modal closed | function | none |
6768
`renderFooter` | Function returns a footer element | function | none |
68-
`controls` | Config of available controls (see below) | Object | {close: true} |
6969

7070
#### Image item:
7171

src/ImageView.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type PropsType = {
6868
onClose: () => {},
6969
renderFooter: ImageType => {},
7070
controls: {
71-
close?: ComponentType<ControlType>,
71+
close?: ComponentType<ControlType> | boolean,
7272
next?: ComponentType<ControlType> | boolean,
7373
prev?: ComponentType<ControlType> | boolean,
7474
},
@@ -93,7 +93,7 @@ export default class ImageView extends Component<PropsType, StateType> {
9393
imageIndex: 0,
9494
glideAlways: false,
9595
glideAlwaysDelay: 75,
96-
controls: {close: Close, prev: null, next: null},
96+
controls: {prev: null, next: null},
9797
};
9898

9999
constructor(props: PropsType) {
@@ -550,7 +550,11 @@ export default class ImageView extends Component<PropsType, StateType> {
550550

551551
getControls = (): ControlsType => {
552552
const {close, prev, next} = this.props.controls;
553-
const controls = {close, prev: undefined, next: undefined};
553+
const controls = {close: Close, prev: undefined, next: undefined};
554+
555+
if (close === null) {
556+
controls.close = null;
557+
}
554558

555559
if (prev) {
556560
controls.prev = prev === true ? Prev : prev;
@@ -778,9 +782,7 @@ export default class ImageView extends Component<PropsType, StateType> {
778782
]}
779783
>
780784
{!!close &&
781-
React.createElement(close, {
782-
onPress: this.close,
783-
})}
785+
React.createElement(close, {onPress: this.close})}
784786
</Animated.View>
785787
<FlatList
786788
horizontal

src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type ControlType = {
66
};
77

88
export type ControlsType = {
9-
close?: ComponentType<ControlType>,
9+
close?: ?ComponentType<ControlType>,
1010
next?: ComponentType<ControlType>,
1111
prev?: ComponentType<ControlType>,
1212
};

0 commit comments

Comments
 (0)