SwiftKickMobile/SwiftMessages

Message view is not interactive on iOS18.

Closed this issue · 3 comments

Please consider the following code:

import SwiftUI
import SwiftMessages

struct MessageView: View {
    let message: String

    @State
    private var isToggleOn = false

    var body: some View {
        VStack {
            Text(message)
            Toggle("Switch: ", isOn: $isToggleOn)

            Button("Close") {
                print("Close button clicked")
            }
        }
        .padding(20)
        .background(.yellow)
    }
}

struct ContentView: View {
    var body: some View {
        Button("Show Message") {
            var config = SwiftMessages.Config()
            config.duration = .forever

            let message = "Hello, World!"
            let hostingView = MessageHostingView(id: message, content: MessageView(message: message))

            SwiftMessages.show(config: config, view: hostingView)
        }
    }
}

#Preview {
    ContentView()
}

It creates a message based on a custom view, containing 2 interactive UI elements: switch and button. On iOS18, interaction with the message view is not possible - both switch and button don't respond to user actions. This is especially painful when a button is supposed to close a message. On iOS17, everything worked as expected.
A sample project is attached.
SwiftMessagesIssue.zip

This is already fixed on the head of master. I'm cutting a new release today.

Cool. Thank you so much.

10.0.1