sparrowcode / AlertKit

Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.
https://sparrowcode.io/frameworks
MIT License
2.3k stars 130 forks source link

Color for icon in SwiftUI #38

Closed derech1e closed 2 years ago

derech1e commented 2 years ago

Is your feature request related to a problem? Please describe. Please add custom color support to icons in SwiftUI.

Describe the solution you'd like Something, where you can define the color of the .error icon animation. It would be pretty nice!

ivanvorobei commented 2 years ago

You can use method with SPAlertView parameter, before set tint color to view.

derech1e commented 2 years ago

How can I set the tint color?

SPAlertView(title: "Test", message: "Test1", preset: .done).present(haptic: .success) { print("a") }

derech1e commented 2 years ago

This also not work:

let alert = SPAlertView(title: "a", message: "b", preset: .error)
alert.tintColor = .red
alert.present()
derech1e commented 2 years ago

@ivanvorobei I don't get it. Even when I set the tint to the whole Stack it won't change the icon color.

ivanvorobei commented 2 years ago

Try set tint for icon color and template rendering mode. Also you can set image with original rendering mode and specific color.

derech1e commented 2 years ago

I can't set the renderingMode. It throws an error.

                        let alert = SPAlertView(title: "", message: addLoogbookEntryVM.brokenValues[0].message, preset: .error)
                        alert.duration = 3.5
                        alert.dismissByTap = true
                        alert.iconView?.tintColor = .red
                        alert.tintColor = .red
                        alert.iconView?.largeContentImage?.renderingMode = .alwaysOriginal
                        alert.present()

@ivanvorobei

ivanvorobei commented 2 years ago

You should set image with rendering mode.

derech1e commented 2 years ago

You should set image with rendering mode.

But when I set the image I lose the animation. Right?

Can you give me a little code snippet?

ivanvorobei commented 2 years ago

Sorry, I founded bug. Now you can change color simple with tint. Also I added Colors section in Readme.

ivanvorobei commented 2 years ago

Please, update to 4.0.1 version

derech1e commented 2 years ago

Ok, but still not working for me :/

derech1e commented 2 years ago
let alert = SPAlertView(title: "", message: "Test", preset: .custom(UIImage(systemName: "pencil.and.outline")!.withRenderingMode(.alwaysTemplate)))
                        alert.iconView?.tintColor = .red
                        alert.duration = 3.5
                        alert.dismissByTap = true
                        alert.present()

This is my code, that don't work.

ivanvorobei commented 2 years ago

Are you sure about upgrade to new version? I tested your code, and it work

Simulator Screen Shot - iPhone 13 Pro - 2021-12-24 at 10 20 43

derech1e commented 2 years ago

Are you sure about upgrade to new version? I tested your code, and it work

Simulator Screen Shot - iPhone 13 Pro - 2021-12-24 at 10 20 43

Ok, I am sorry. I thought I updated to the last version but for some reason it wasn't the case. Now it works :) Thank you!