Add Support for 'presentationSizing' in iOS 18 #9

Open
opened 2025-10-14 15:54:37 -06:00 by navan · 0 comments
Owner

Originally created by @bradleyandrew on 12/17/2024

With iOS 18 Apple introduced the 'presentationSizing' presentation modifier as per this documentation:
https://developer.apple.com/documentation/swiftui/view/presentationsizing(_:)

When presenting a .sheet in iOS 17, the default was to present it as full height of the iPad Display.
When presenting a .sheet in iOS 18, the default is to present it as half height of the iPad Display.

'WhatsNewView' is presented as a sheet and defaults to the smaller sized version on iOS 18.

If you include a number of 'WhatsNew.Feature' in a 'WhatsNew', a user will be forced to scroll through them on a smaller sheet in iOS 18 rather than having them presented at full height with zero scroll as they would display in iOS 17.

I apply this to my views that are used as a .sheet to solve for this issue on various iOS Versions:

extension View {
    
    func pageSheetSizing() -> some View {
        if #available(iOS 18.0, *) {
            AnyView(self.presentationSizing(.page))
        } else {
            // Fallback on earlier versions
            AnyView(self)
        }
    }
    
}

I initally tired to get it to work like this with the code below, but it did not work as 'pageSheetSizing' needs to be applied to the actual view:
.whatsNewSheet().pageSheetSizing()

I ended up settling on a custom implementation of '.whatsNewSheet()' and used it like this on the view I wanted to apply it to:

        .sheet(item: .init(
            get: { self.whatsNewIsDismissed == true ? nil : whatsNewEnvironment.whatsNew() },
            set: { self.whatsNewIsDismissed = $0 == nil }
        )) { whatsNew in
            WhatsNewView(whatsNew: whatsNew, versionStore: whatsNewEnvironment.whatsNewVersionStore, layout: whatsNewEnvironment.defaultLayout)
                .pageSheetSizing()
        }

This works to present a full height sheet in iOS 17 and iOS 18.

It would be good to have native support for this in WhatsNewKit, perhaps in 'WhatsNew.Layout' where you could specify the desired 'PresentationSizing'?

*Originally created by @bradleyandrew on 12/17/2024* With iOS 18 Apple introduced the 'presentationSizing' presentation modifier as per this documentation: https://developer.apple.com/documentation/swiftui/view/presentationsizing(_:) When presenting a .sheet in iOS 17, the default was to present it as full height of the iPad Display. When presenting a .sheet in iOS 18, the default is to present it as half height of the iPad Display. 'WhatsNewView' is presented as a sheet and defaults to the smaller sized version on iOS 18. If you include a number of 'WhatsNew.Feature' in a 'WhatsNew', a user will be forced to scroll through them on a smaller sheet in iOS 18 rather than having them presented at full height with zero scroll as they would display in iOS 17. I apply this to my views that are used as a .sheet to solve for this issue on various iOS Versions: ``` extension View { func pageSheetSizing() -> some View { if #available(iOS 18.0, *) { AnyView(self.presentationSizing(.page)) } else { // Fallback on earlier versions AnyView(self) } } } ``` I initally tired to get it to work like this with the code below, but it did not work as 'pageSheetSizing' needs to be applied to the actual view: `.whatsNewSheet().pageSheetSizing()` I ended up settling on a custom implementation of '.whatsNewSheet()' and used it like this on the view I wanted to apply it to: ``` .sheet(item: .init( get: { self.whatsNewIsDismissed == true ? nil : whatsNewEnvironment.whatsNew() }, set: { self.whatsNewIsDismissed = $0 == nil } )) { whatsNew in WhatsNewView(whatsNew: whatsNew, versionStore: whatsNewEnvironment.whatsNewVersionStore, layout: whatsNewEnvironment.defaultLayout) .pageSheetSizing() } ``` This works to present a full height sheet in iOS 17 and iOS 18. It would be good to have native support for this in WhatsNewKit, perhaps in 'WhatsNew.Layout' where you could specify the desired 'PresentationSizing'?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/WhatsNewKit#9
No description provided.