Add Hide option to home shortcut context menu

This commit is contained in:
Arkadiusz Fal
2026-06-09 08:46:51 +02:00
parent 8e48097a5a
commit d7ec654f84
2 changed files with 31 additions and 2 deletions

View File

@@ -3742,6 +3742,17 @@
} }
} }
}, },
"home.hideShortcut" : {
"comment" : "Context menu action on Home shortcuts to hide the shortcut",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Hide"
}
}
}
},
"home.history.clear" : { "home.history.clear" : {
"comment" : "Clear history button", "comment" : "Clear history button",
"localizations" : { "localizations" : {

View File

@@ -386,7 +386,10 @@ struct HomeView: View {
shortcutCardView(for: shortcut) shortcutCardView(for: shortcut)
.environment(\.homeShortcutColorfulColor, colorfulColor(atPosition: index)) .environment(\.homeShortcutColorfulColor, colorfulColor(atPosition: index))
#if !os(tvOS) #if !os(tvOS)
.contextMenu { editShortcutsButton } .contextMenu {
hideShortcutButton(for: shortcut)
editShortcutsButton
}
#endif #endif
} }
} }
@@ -419,12 +422,27 @@ struct HomeView: View {
shortcutRowView(for: shortcut) shortcutRowView(for: shortcut)
} }
#if !os(tvOS) #if !os(tvOS)
.contextMenu { editShortcutsButton } .contextMenu {
hideShortcutButton(for: shortcut)
editShortcutsButton
}
#endif #endif
} }
} }
#if !os(tvOS) #if !os(tvOS)
/// Context menu action that hides the given shortcut from Home.
private func hideShortcutButton(for shortcut: HomeShortcutItem) -> some View {
Button {
guard let settingsManager else { return }
var visibility = settingsManager.homeShortcutVisibility
visibility[shortcut] = false
settingsManager.homeShortcutVisibility = visibility
} label: {
Label(String(localized: "home.hideShortcut"), systemImage: "eye.slash")
}
}
/// Context menu action that opens the Home settings sheet to reorder/toggle shortcuts. /// Context menu action that opens the Home settings sheet to reorder/toggle shortcuts.
private var editShortcutsButton: some View { private var editShortcutsButton: some View {
Button { Button {