Skip to content

Commit

Permalink
Merge pull request #5 from Jeonhui/bug/useInlineMode(1.2.0)
Browse files Browse the repository at this point in the history
[1.2.1] useInline mode bug fix
  • Loading branch information
Jeonhui authored Nov 26, 2024
2 parents 61f18a1 + 4cb09a8 commit 65a6004
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
A567AB362BF5B09100819941 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A567AB352BF5B09100819941 /* Assets.xcassets */; };
A567AB392BF5B09100819941 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A567AB382BF5B09100819941 /* Preview Assets.xcassets */; };
A567AB4C2BF5B17F00819941 /* SheetSize+.swift in Sources */ = {isa = PBXBuildFile; fileRef = A567AB4B2BF5B17F00819941 /* SheetSize+.swift */; };
A567AB4E2BF5B2D100819941 /* FittedSheetsSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = A567AB4D2BF5B2D100819941 /* FittedSheetsSwiftUI */; };
A567AB502BF5B72100819941 /* SheetContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A567AB4F2BF5B72100819941 /* SheetContentView.swift */; };
A567AB522BF5B78F00819941 /* ExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A567AB512BF5B78F00819941 /* ExampleView.swift */; };
A590401F2CF58D5A00E55C1A /* FittedSheetsSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = A590401E2CF58D5A00E55C1A /* FittedSheetsSwiftUI */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -31,14 +31,15 @@
A567AB4B2BF5B17F00819941 /* SheetSize+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SheetSize+.swift"; sourceTree = "<group>"; };
A567AB4F2BF5B72100819941 /* SheetContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetContentView.swift; sourceTree = "<group>"; };
A567AB512BF5B78F00819941 /* ExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleView.swift; sourceTree = "<group>"; };
A5E91AD32CF58C970091B944 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Package.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
A567AB2B2BF5B09000819941 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A567AB4E2BF5B2D100819941 /* FittedSheetsSwiftUI in Frameworks */,
A590401F2CF58D5A00E55C1A /* FittedSheetsSwiftUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -105,6 +106,7 @@
A567AB3F2BF5B0A900819941 /* Frameworks */ = {
isa = PBXGroup;
children = (
A5E91AD32CF58C970091B944 /* Package.swift */,
A567AB402BF5B0A900819941 /* FitttedSheets-SwiftUI */,
);
name = Frameworks;
Expand Down Expand Up @@ -135,7 +137,7 @@
);
name = "FittedSheets-SwiftUI-Example";
packageProductDependencies = (
A567AB4D2BF5B2D100819941 /* FittedSheetsSwiftUI */,
A590401E2CF58D5A00E55C1A /* FittedSheetsSwiftUI */,
);
productName = "FittedSheets-SwiftUI-Example";
productReference = A567AB2E2BF5B09000819941 /* FittedSheets-SwiftUI-Example.app */;
Expand Down Expand Up @@ -405,7 +407,7 @@
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
A567AB4D2BF5B2D100819941 /* FittedSheetsSwiftUI */ = {
A590401E2CF58D5A00E55C1A /* FittedSheetsSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
productName = FittedSheetsSwiftUI;
};
Expand Down
42 changes: 25 additions & 17 deletions Sources/FittedSheetsSwiftUI/FittedSheetPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,33 @@ public struct FittedSheetPresenter<SheetView: View>: UIViewControllerRepresentab
private func presentSheetController(_ sheetController: SheetViewController,
parent viewController: UIViewController,
useInlineMode: Bool) {
if useInlineMode {
if isPresented {
DispatchQueue.main.async {
sheetController.animateIn(to: viewController.view,
in: viewController)
}
} else {
viewController.children.forEach { childViewController in
guard let svc = childViewController as? SheetViewController else { return }
DispatchQueue.main.async {
svc.animateOut()
}
}
guard !useInlineMode else {
useInlineModePresentSheetController(sheetController, parent: viewController)
return
}
if isPresented {
viewController.present(sheetController, animated: animated)
} else {
viewController.presentedViewController?.dismiss(animated: animated)
}
}

private func useInlineModePresentSheetController(_ sheetController: SheetViewController,
parent viewController: UIViewController) {
guard !viewController.children.contains(where: { $0 is SheetViewController }) else {
return
}
if isPresented {
DispatchQueue.main.async {
sheetController.animateIn(to: viewController.view,
in: viewController)
}
} else {
if isPresented {
viewController.present(sheetController, animated: animated)
} else {
viewController.presentedViewController?.dismiss(animated: animated)
viewController.children.forEach { childViewController in
guard let svc = childViewController as? SheetViewController else { return }
DispatchQueue.main.async {
svc.animateOut()
}
}
}
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 65a6004

Please sign in to comment.