Skip to content

Commit

Permalink
⭐️ Impl: ModalView.setStateIsModalVisible
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Jan 9, 2023
1 parent fed37df commit 5e64ced
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/ModalView/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ export class ModalView extends
return this.emitter;
};

setStateIsModalVisible = (nextModalVisibility: boolean) => {
const { isModalVisible: prevModalVisibility } = this.state;

const didModalVisibilityChange =
prevModalVisibility !== nextModalVisibility;

if(!didModalVisibilityChange) return;

this.setState({
isModalVisible: nextModalVisibility,
});
};

setVisibility = async (
nextVisible: boolean,
childProps: object | null = null
Expand Down Expand Up @@ -305,6 +318,8 @@ export class ModalView extends
ModalViewEmitterEvents.onModalShow,
event.nativeEvent
);

this.setStateIsModalVisible(true);
};

_handleOnModalDismiss: OnModalDismissEvent = (event) => {
Expand Down Expand Up @@ -335,6 +350,8 @@ export class ModalView extends
ModalViewEmitterEvents.onModalDidDismiss,
event.nativeEvent
);

this.setStateIsModalVisible(false);
};

_handleOnModalWillDismiss: OnModalDidDismissEvent = (event) => {
Expand Down

0 comments on commit 5e64ced

Please sign in to comment.