From 4e497cb2d67a80a351307ce7f814e252cafed253 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Sun, 29 Sep 2024 13:32:04 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20`ModalSheetState`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Temp/ModalSheetState.swift | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ios/Temp/ModalSheetState.swift b/ios/Temp/ModalSheetState.swift index 3504adfc..aa6407f1 100644 --- a/ios/Temp/ModalSheetState.swift +++ b/ios/Temp/ModalSheetState.swift @@ -61,6 +61,10 @@ public enum ModalSheetState: String { self.modalState.isDismissed; }; + public var isDraggingViaGesture: Bool { + self == .draggingViaGesture; + }; + public var isInPresentation: Bool { !self.isDraggingViaGesture && self.modalState.isInPresentation @@ -79,4 +83,28 @@ public enum ModalSheetState: String { public var simplified: Self { self.modalState.modalSheetState; }; + + public var isSpecific: Bool { + self.simplified != self; + }; + + // MARK: - Functions + // ----------------- + + public func isSameStep(comparedTo otherState: Self) -> Bool { + self.simplified == otherState.simplified; + }; + + public func isGeneric(comparedTo otherState: Self) -> Bool { + switch(self, otherState){ + case (.draggingViaGesture, let otherState) where otherState.isInPresentation: + return false; + + case (let currentState, .draggingViaGesture) where currentState.isInPresentation: + return false; + + default: + return self.isSpecific && !otherState.isSpecific + }; + }; };