edudnyk / SheeKit

Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of `UISheetPresentationController` and other UIKit features.
MIT License
91 stars 7 forks source link

Optionally override interface style of presented view controller. #12

Open lightandshadow68 opened 2 years ago

lightandshadow68 commented 2 years ago

This PR allows overriding the interface style of the presented view controller. Specifically, it adds the ability to set the overrideUserInterfaceStyle property on the view controller before it is presented. This allows omitting the .preferredColorScheme(.dark) modifier, which didn't seem to survive the presentation and retroactively caused interface style changes in the view calling .shee(....

edudnyk commented 1 year ago

Hi @lightandshadow68,

Thanks for this PR. Given your problem statement, I think you can do better here.

In SheetModifier.swift, you can declare @Environment(\.colorScheme) private var colorScheme. This will collect the color scheme assigned outside of the sheet with .preferredColorScheme(..).

Then, you can automatically pass that to sheetHost.overrideUserInterfaceStyle in the same file, without the necessity of exposing this property in UIViewControllerProxy.