This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
public enum SheeKitTestsHostApp { | |
public static var app = _TestApp() | |
static func main() { | |
app.run() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SheetModifier<Item, SheetContent>: ViewModifier where Item : Identifiable, SheetContent : View { | |
@Binding var item: Item? | |
let presentationStyle: ModalPresentationStyle | |
let presentedViewControllerParameters: UIViewControllerProxy? | |
let onDismiss: (() -> Void)? | |
@ViewBuilder | |
let content: (Item) -> SheetContent | |
@State var proxy = UIViewControllerProxy() | |
func body(content: Content) -> some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SheetPresenterControllerRepresentable<Item>: UIViewControllerRepresentable where Item : Identifiable { | |
@Binding var item: Item? | |
@Environment(\.shee_isInteractiveDismissDisabled) private var isInteractiveDismissDisabled | |
let onDismiss: (() -> Void)? | |
let sheetHostProvider: (AdaptiveDelegate<Item>, UIViewController, Item, DismissAction) -> SheetHostingController<Item> | |
let sheetHostUpdater: (AdaptiveDelegate<Item>, UIViewController, Bool, DismissAction) -> Void | |
func makeCoordinator() -> AdaptiveDelegate<Item> { .init() } | |
func makeUIViewController(context: Context) -> SheetPresenterController { .init() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SheetHostingController<Item>: UIHostingController<AnyView> where Item : Identifiable { | |
var itemId: Item.ID? | |
var item: Item | |
var onDismiss: (() -> Void)? | |
init(rootView: AnyView, item: Item) { | |
self.itemId = item.id | |
self.item = item | |
super.init(rootView: rootView) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class AdaptiveDelegate<Item>: NSObject, UIPopoverPresentationControllerDelegate, UISheetPresentationControllerDelegate where Item : Identifiable { | |
weak var sheetHost: SheetHostingController<Item>? | |
var dismissedByUserCallback: DismissAction? | |
var isInteractiveDismissDisabled = false | |
var selectedDetentIdentifierBinding: Binding<UISheetPresentationController.Detent.Identifier?>? | |
override init() { | |
super.init() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct DismissAction { | |
public func callAsFunction() | |
} | |
extension EnvironmentValues { | |
public internal(set) var shee_dismiss: DismissAction | |
public internal(set) var shee_isPresented: Bool | |
} | |
extension View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct UIViewControllerProxy { | |
public var modalTransitionStyle: UIModalTransitionStyle = .coverVertical | |
public var modalPresentationCapturesStatusBarAppearance = false | |
public var disablesAutomaticKeyboardDismissal: Bool? | |
public var edgesForExtendedLayout: UIRectEdge = .all | |
public var extendedLayoutIncludesOpaqueBars: Bool = false | |
public var preferredContentSize: CGSize = .zero | |
public var preferredStatusBarStyle: UIStatusBarStyle? | |
public var prefersStatusBarHidden: Bool? | |
public var preferredStatusBarUpdateAnimation: UIStatusBarAnimation? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct SheetProperties { | |
/// Set to true to cause the sheet to layout with an edge-attached appearance in compact height instead of full screen. | |
/// Default: ``false`` | |
public var prefersEdgeAttachedInCompactHeight: Bool | |
/// Set to true to allow ``preferredContentSize`` to influence the width of the sheet when edge-attached. | |
/// When ``false``, the width of the sheet when edge-attached is always equal to the safe area width of the container. | |
/// The value of this property is not respected in compact width regular height. | |
/// Default: ``false`` | |
public var widthFollowsPreferredContentSizeWhenEdgeAttached: Bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum ModalPresentationStyle { | |
/// The default presentation style chosen by the system. | |
case automatic | |
/// A presentation style that partially covers the underlying content. | |
/// | |
/// - Parameters: | |
/// - properties: properties to assign to ``UISheetPresentationController`` | |
case pageSheet(properties: SheetProperties? = nil) | |
/// A presentation style that displays the content centered in the screen. | |
/// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
struct App { | |
static func main() { | |
_TestApp().runBenchmarks([Benchmark()]) | |
} | |
} | |
extension UIHostingController: _Test where Content == AnyView {} |