Skip to content

Commit

Permalink
fix menuitemview icon and text tint
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Mattiello <git@joemattiello.com>
  • Loading branch information
JoeMatt committed Dec 3, 2024
1 parent 8130b68 commit 3d31547
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions PVUI/Sources/PVSwiftUI/SideMenu/MenuItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@ struct MenuItemView: SwiftUI.View {
@ObservedObject private var gamepadManager = GamepadManager.shared

private var shouldShowFocus: Bool {
isFocused && controllerConnected
(isFocused && controllerConnected) || !controllerConnected
}

private var controllerConnected: Bool {
gamepadManager.isControllerConnected
}

private var tint: Color {
private var shouldStroke: Bool {
shouldShowFocus && controllerConnected
}

private var iconTint: Color {
shouldShowFocus ? themeManager.currentPalette.menuIconTint.swiftUIColor : themeManager.currentPalette.menuIconTint.swiftUIColor.opacity(controllerConnected ? 0.6 : 1.0)
}

private var textTint: Color {
shouldShowFocus ? themeManager.currentPalette.menuText.swiftUIColor : themeManager.currentPalette.menuText.swiftUIColor.opacity(controllerConnected ? 0.6 : 1.0)
}

var body: some SwiftUI.View {
let _ = print("MenuItemView '\(rowTitle)' isFocused: \(isFocused)")
Expand All @@ -50,10 +58,12 @@ struct MenuItemView: SwiftUI.View {
icon.image
.renderingMode(.template)
.resizable().scaledToFit().cornerRadius(4).padding(8)
.tint(tint)
.tint(iconTint)
.foregroundStyle(iconTint)
.foregroundColor(iconTint)
/// Text
Text(rowTitle)
.foregroundColor(tint)
.foregroundColor(textTint)
/// Space
Spacer()
}
Expand All @@ -67,7 +77,7 @@ struct MenuItemView: SwiftUI.View {
)
.overlay(
Rectangle()
.stroke(shouldShowFocus ? themeManager.currentPalette.menuIconTint.swiftUIColor : .clear, lineWidth: 2)
.stroke(shouldStroke ? themeManager.currentPalette.menuIconTint.swiftUIColor : .clear, lineWidth: 2)
)
}
.buttonStyle(.plain)
Expand Down

0 comments on commit 3d31547

Please sign in to comment.