Skip to content

Commit

Permalink
💫 Update: Ex - Test06
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Mar 30, 2023
1 parent ed4839d commit 5787d82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions example/src/examples/Test06/ModalGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ export const ModalGroup = React.forwardRef<ModalGroupHandle, ModalGroupProps>(
setCurrentModalIndex(nextModalIndex);
modalRef.setVisibility(true);
}}
onPressClosePrevModal={async (modalIndex) => {
onPressCloseModal={async (modalIndex) => {
const modalRef = modalRefs.current[`${modalIndex}`];

// guard
if (modalRef == null) {
return;
}

await modalRef.setVisibility(false);
setCurrentModalIndex(modalIndex - 1);
}}
onPressClosePrevModal={(modalIndex) => {
const prevModalIndex = modalIndex - 1;

const prevModalRef = modalRefs.current[`${prevModalIndex}`];
Expand All @@ -74,8 +85,7 @@ export const ModalGroup = React.forwardRef<ModalGroupHandle, ModalGroupProps>(
return;
}

await prevModalRef.setVisibility(false);
setCurrentModalIndex(prevModalIndex);
prevModalRef.setVisibility(false);
}}
/>
</ModalView>
Expand Down
3 changes: 2 additions & 1 deletion example/src/examples/Test06/ModalGroupItemContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function ModalGroupItemContent(props: {
modalIndex: number;
onPressOpenNextModal: (modalIndex: number) => void;
onPressClosePrevModal: (modalIndex: number) => void;
onPressCloseModal: (modalIndex: number) => void;
}) {
const logDisplayRef = React.useRef<CardLogDisplayHandle>(null);

Expand Down Expand Up @@ -82,7 +83,7 @@ export function ModalGroupItemContent(props: {
<CardButton
title={'🚫 Close Modal'}
onPress={() => {
modalContext.setVisibility(false);
props.onPressCloseModal(props.modalIndex);
}}
/>
{props.modalIndex > 0 && (
Expand Down

0 comments on commit 5787d82

Please sign in to comment.