divadretlaw / CustomAlert

🔔 Custom Alert for SwiftUI
MIT License
190 stars 18 forks source link

backward overlay #6

Closed fabricetiennette closed 1 year ago

fabricetiennette commented 1 year ago

Are you thinking of a backward overlay removal option feature in the future ?

divadretlaw commented 1 year ago

Not quite sure what you mean by "backward overlay"?

Do you mean the dimmed background when displaying the alert?

In general the custom alert is designed to look and behave exactly like the native alert, but if needed I could add the ability to customize the background, which would also allow it to be removed entirely.

mickey4u commented 2 months ago

@divadretlaw Is there a way I can override the background color around the alert content view?

divadretlaw commented 2 months ago

@mickey4u you mean like this?

example

Then yes

.customAlert("Title", isPresented: $showAlert) {
    Text("Content")
} actions: {
    Button(role: .cancel) {
    } label: {
        Text("OK")
    }
}
.configureCustomAlert { configuration in
    configuration.background = .color(Color.purple.opacity(0.5))
}

You can customize the styling via configureCustomAlert. If you are missing some customization options you can create an issue or a pull request.

See https://github.com/divadretlaw/CustomAlert/blob/main/Demo/Demo/Alerts/CustomAlerts.swift#L98 for a heavily customized alert example.

mickey4u commented 2 months ago

@divadretlaw no I tried that, so when you embed a custom view into the customAlert it has the default background around the custom view.

Screenshot 2024-09-02 at 23 50 10
divadretlaw commented 2 months ago

@mickey4u I don't quite follow, please create a separate issue with some example code if you still have some questions

Here are three configurations with the alert having custom colors. Depending on the configuration you see something of the alert background or not

The alert is configured as follows

Default No title, just custom view No title, alert padding = 0
1 2 3