Skip to content

Commit

Permalink
Update icon color for favorite icon button
Browse files Browse the repository at this point in the history
  • Loading branch information
Breiby committed Aug 7, 2024
1 parent 95db31f commit 7c0da40
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import SwiftUI

public struct SwiftUIIconButton: View {
public struct Style {
let color: Color
let colorToggled: Color
let icon: UIImage
let iconToggled: UIImage
}
Expand All @@ -17,14 +19,16 @@ public struct SwiftUIIconButton: View {
public var body: some View {
Image.init(uiImage: isToggled ? style.iconToggled : style.icon)
.renderingMode(.template)
.foregroundColor(isToggled ? .backgroundPrimary : .icon)
.foregroundColor(isToggled ? style.colorToggled : style.color)
.accessibilityRemoveTraits(.isImage)
.accessibilityAddTraits(isToggled ? [.isButton, .isSelected] : [.isButton])
}
}

public extension SwiftUIIconButton.Style {
static let favorite = SwiftUIIconButton.Style(
color: .iconSubtle,
colorToggled: .backgroundPrimary,
icon: UIImage(named: .favoriteDefault),
iconToggled: UIImage(named: .favoriteActive)
)
Expand Down

0 comments on commit 7c0da40

Please sign in to comment.