Skip to content

Commit 00ce79d

Browse files
committed
remove UIScreen from other platform
1 parent 5e18f72 commit 00ce79d

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Package.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ let package = Package(
1515
],
1616
dependencies: [
1717
.package(url: "https://github.com/lkzhao/BaseToolbox", from: "0.1.0"),
18-
.package(url: "https://github.com/kylebshr/ScreenCorners", from: "1.0.1"),
1918
],
2019
targets: [
2120
.target(
2221
name: "Hero2",
23-
dependencies: ["BaseToolbox", "ScreenCorners"]
22+
dependencies: ["BaseToolbox"]
2423
)
2524
]
2625
)

Sources/Hero2/BuiltinTransitions/MatchTransition.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ open class MatchTransition: Transition {
7777

7878
let isFullScreen = container.window?.convert(container.bounds, from: container) == container.window?.bounds
7979
let foregroundContainerView = self.foregroundContainerView
80-
let finalCornerRadius: CGFloat = isFullScreen ? UIScreen.main.displayCornerRadius : 0
80+
let finalCornerRadius: CGFloat = isFullScreen ? displayCornerRadius : 0
8181
foregroundContainerView.cornerRadius = finalCornerRadius
8282
foregroundContainerView.frame = container.bounds
8383
foregroundContainerView.backgroundColor = front.backgroundColor

Sources/Hero2/BuiltinTransitions/SheetTransition.swift

+21-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class SheetPresentationController: UIPresentationController, UIGestureRecognizer
166166
if hasParentSheet {
167167
back.cornerRadius = transition.cornerRadius
168168
} else {
169-
back.cornerRadius = UIScreen.main.displayCornerRadius
169+
back.cornerRadius = transition.displayCornerRadius
170170
}
171171
#endif
172172
overlayView.alpha = 0
@@ -190,7 +190,7 @@ class SheetPresentationController: UIPresentationController, UIGestureRecognizer
190190
overlayView.frameWithoutTransform = presentingViewController.view.bounds
191191

192192
presentedViewController.view.frameWithoutTransform = presentedViewController.sheetFrame(transition: transition, container: container)
193-
presentedViewController.view.cornerRadius = container.isCompactVertical ? UIScreen.main.displayCornerRadius : transition.cornerRadius
193+
presentedViewController.view.cornerRadius = container.isCompactVertical ? transition.displayCornerRadius : transition.cornerRadius
194194
presentedViewController.view.layer.maskedCorners =
195195
container.isIpadLayout ? [.layerMinXMinYCorner, .layerMaxXMinYCorner, .layerMinXMaxYCorner, .layerMaxXMaxYCorner] : [.layerMinXMinYCorner, .layerMaxXMinYCorner]
196196
presentedViewController.view.clipsToBounds = true
@@ -332,3 +332,22 @@ private extension UIViewController {
332332
}
333333
}
334334
}
335+
336+
extension Transition {
337+
private static let cornerRadiusKey: String = {
338+
let components = ["Radius", "Corner", "display", "_"]
339+
return components.reversed().joined()
340+
}()
341+
342+
public var displayCornerRadius: CGFloat {
343+
#if os(iOS)
344+
guard let cornerRadius = UIScreen.main.value(forKey: Self.cornerRadiusKey) as? CGFloat else {
345+
return 0
346+
}
347+
348+
return cornerRadius
349+
#else
350+
return 0
351+
#endif
352+
}
353+
}

0 commit comments

Comments
 (0)