nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
378 stars 13 forks source link

Status bar color is out of sync when window overlay is used together with presentation sheet #7

Closed PhilipDukhov closed 11 months ago

PhilipDukhov commented 12 months ago

WindowLinkModifier is being used to show overlay toast view. When it's presented over a sheet, presented with PresentationLinkModifier, the sheet changes status bar color to black which makes it invisible

.window modifier is used to display an overlay toast view. When it is presented over a sheet presented using .presentation, the sheet changes the color of the status bar to black, making it invisible

@State var isSheetPresented = false
@State var isToastPresented = false

var body: some View {
    VStack {
        Button {
            isSheetPresented = true
        } label: {
            Text("Show sheet")
        }
        Button {
            isToastPresented = true
        } label: {
            Text("Show toast")
        }
    }
    .presentation(
        transition: .sheet(
            options: .init(
                detents: [.large],
                isInteractive: true,
                preferredCornerRadius: 20,
                options: .init(
                    shouldAutomaticallyDismissDestination: false,
                    preferredPresentationBackgroundColor: .white
                )
            )
        ),
        isPresented: $isSheetPresented
    ) {
        Button {
            isToastPresented = true
        } label: {
            Text("Show toast")
        }
    }
    .window(
        level: .overlay,
        transition: .move(edge: .top).combined(with: .opacity),
        isPresented: $isToastPresented
    ) {
        Button {
            isToastPresented = false
        } label: {
            Text("Hide toast")
                .background(Color.green)
        }
    }
    .animation(.default, value: isSheetPresented)
    .animation(.default, value: isToastPresented)
}
nathantannar4 commented 11 months ago

Fixed in 0.1.26. Please use the .default WindowLinkLevel for the level param in the window modifier. This will change the presentation behaviour such that the presenting window still determines the status bar appearance, and the new window doesn't take first responder (which can effect text editing if you present a toast while editing)