From d5068e35a9653089b93aa7c144a7bf8398c327f4 Mon Sep 17 00:00:00 2001 From: Dominic Go <18517029+dominicstop@users.noreply.github.com> Date: Fri, 7 Apr 2023 03:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20`RNIModal.synthesizedM?= =?UTF-8?q?odalIndex`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update RNIModal+Helpers.swift --- .../React Native/RNIModal/RNIModal+Helpers.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift b/ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift index 61c59afa..3cf3859b 100644 --- a/ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift +++ b/ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift @@ -37,18 +37,18 @@ extension RNIModalState where Self: RNIModalPresentation { }; /// Programmatically get the "modal index" - /// - /// Note:2023-03-31-15-41-04 - /// - /// * This is based on the view controller hierarchy - /// * So parent/child view controller that aren't modals are also counted - /// var synthesizedModalIndex: Int { let listPresentedVC = RNIModalManager.getPresentedViewControllers(for: self.window); - for (index, vc) in listPresentedVC.enumerated() { - guard vc != self.modalViewController else { continue }; + var index = -1; + + for vc in listPresentedVC { + if vc.presentingViewController != nil { + index += 1; + }; + + guard vc === self.modalViewController else { continue }; return index; };