Skip to content

Commit

Permalink
1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nathantannar4 committed Nov 22, 2024
1 parent 806844a commit 551fc4a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/nathantannar4/Engine", from: "1.8.8"),
.package(url: "https://github.com/nathantannar4/Engine", from: "1.9.0"),
.package(url: "https://github.com/nathantannar4/Turbocharger", from: "1.3.1"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ open class PresentationHostingController<
return
}

// This seems to match the `maximumDetentValue` computed by UIKit
let maximumDetentValue = containerView.frame.inset(by: containerView.safeAreaInsets).height - 10
let resolvedDetentHeight = detent.resolvedValue(
containerTraitCollection: sheetPresentationController.traitCollection,
maximumDetentValue: containerView.frame.height
maximumDetentValue: maximumDetentValue
)
guard let resolvedDetentHeight,
resolvedDetentHeight != view.frame.height - (view.safeAreaInsets.top + view.safeAreaInsets.bottom)
else {
let height = view.frame.height - (view.safeAreaInsets.top + view.safeAreaInsets.bottom)
guard let resolvedDetentHeight, resolvedDetentHeight != height else {
return
}

Expand Down
27 changes: 22 additions & 5 deletions Sources/Transmission/Sources/PresentationLinkTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ extension PresentationLinkTransition {
return Detent(identifier: identifier, height: height)
}

/// Creates a detent with a height relative to the maximum detent height.
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static func percentage(
_ identifier: Identifier,
multiplier: CGFloat
) -> Detent {
precondition(identifier.isCustom, "A custom detent identifier must be provided.")
return Detent(identifier: identifier) { ctx in
return ctx.maximumDetentValue * multiplier
}
}

/// Creates a detent that's height is lazily resolved.
@available(iOS 15.0, *)
@available(macOS, unavailable)
Expand Down Expand Up @@ -363,20 +378,22 @@ extension PresentationLinkTransition {
}
)
let max = context.maximumDetentValue
return min(resolution(ctx) ?? max, max)
return min(ceil(resolution(ctx) ?? max), max)
}
}
let sel = NSSelectorFromString(String(":tnatsnoc:reifitnedIhtiWtneted_".reversed()))
var constant: CGFloat?
if let resolution {
if let resolution, let containerView = presentationController.containerView {
// This seems to match the `maximumDetentValue` computed by UIKit
let maximumDetentValue = containerView.frame.inset(by: containerView.safeAreaInsets).height - 10
let ctx = ResolutionContext(
containerTraitCollection: presentationController.traitCollection,
maximumDetentValue: presentationController.containerView?.frame.height ?? UIView.layoutFittingExpandedSize.height,
maximumDetentValue: maximumDetentValue,
idealDetentValue: {
idealResolution(presentationController)
}
)
constant = resolution(ctx)
constant = resolution(ctx).map { ceil($0) }
} else {
constant = height
}
Expand All @@ -401,7 +418,7 @@ extension PresentationLinkTransition {
}
)
let max = maximumDetentValue
return min(resolution(ctx) ?? max, max)
return min(ceil(resolution(ctx) ?? max), max)
}
}
return detent
Expand Down

0 comments on commit 551fc4a

Please sign in to comment.