Skip to content

Commit

Permalink
side menu full gamepad navigation
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Mattiello <[email protected]>
  • Loading branch information
JoeMatt committed Nov 15, 2024
1 parent dd207cc commit 0a009b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion PVUI/Sources/PVSwiftUI/SideMenu/MenuItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ struct MenuItemView: SwiftUI.View {

var icon: SettingsIcon
var rowTitle: String
var isFocused: Bool

var action: () -> Void

@ObservedObject private var themeManager = ThemeManager.shared
@Environment(\.isFocused) private var isFocused: Bool

var body: some SwiftUI.View {
let _ = print("MenuItemView '\(rowTitle)' isFocused: \(isFocused)")
Button {
action()
} label: {
Expand Down
8 changes: 4 additions & 4 deletions PVUI/Sources/PVSwiftUI/SideMenu/SideMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ SideMenuView: SwiftUI.View {
Divider()
.foregroundStyle(themeManager.currentPalette.menuDivider.swiftUIColor)

MenuItemView(icon: .named("prov_home_icon"), rowTitle: "Home") {
MenuItemView(icon: .named("prov_home_icon"), rowTitle: "Home", isFocused: focusedItem == "home") {
delegate.didTapHome()
}
.focusableIfAvailable()
Expand All @@ -226,7 +226,7 @@ SideMenuView: SwiftUI.View {
Divider()
.foregroundStyle(themeManager.currentPalette.menuDivider.swiftUIColor)

MenuItemView(icon: .named("prov_settings_gear"), rowTitle: "Settings") {
MenuItemView(icon: .named("prov_settings_gear"), rowTitle: "Settings", isFocused: focusedItem == "settings") {
delegate.didTapSettings()
}
.focusableIfAvailable()
Expand All @@ -241,7 +241,7 @@ SideMenuView: SwiftUI.View {
Divider()
.foregroundStyle(themeManager.currentPalette.menuDivider.swiftUIColor)

MenuItemView(icon: .sfSymbol("checklist"), rowTitle: "Add Games") {
MenuItemView(icon: .sfSymbol("checklist"), rowTitle: "Add Games", isFocused: focusedItem == "imports") {
delegate.didTapImports()
}
.focusableIfAvailable()
Expand All @@ -261,7 +261,7 @@ SideMenuView: SwiftUI.View {
ForEach(sortedConsoles(), id: \.self) { console in
Divider()
.foregroundStyle(themeManager.currentPalette.menuDivider.swiftUIColor)
MenuItemView(icon: .named(console.iconName, PVUIBase.BundleLoader.myBundle), rowTitle: console.name) {
MenuItemView(icon: .named(console.iconName, PVUIBase.BundleLoader.myBundle), rowTitle: console.name, isFocused: focusedItem == console.identifier) {
delegate.didTapConsole(with: console.identifier)
}
.focusableIfAvailable()
Expand Down

0 comments on commit 0a009b6

Please sign in to comment.