mirror of
https://github.com/yattee/yattee.git
synced 2026-05-13 02:45:03 +00:00
Keep focus on pressed tvOS channel tab button
This commit is contained in:
@@ -87,6 +87,12 @@ struct ChannelView: View {
|
|||||||
@State private var tvOSShowSearchTab = false
|
@State private var tvOSShowSearchTab = false
|
||||||
@FocusState private var isSubscribeFocused: Bool
|
@FocusState private var isSubscribeFocused: Bool
|
||||||
@FocusState private var isTVSearchFieldFocused: Bool
|
@FocusState private var isTVSearchFieldFocused: Bool
|
||||||
|
@FocusState private var tvOSFocusedTab: TvOSChannelFocusTarget?
|
||||||
|
|
||||||
|
private enum TvOSChannelFocusTarget: Hashable {
|
||||||
|
case tab(ChannelTab)
|
||||||
|
case searchTab
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Header configuration
|
// Header configuration
|
||||||
@@ -642,6 +648,7 @@ struct ChannelView: View {
|
|||||||
private var tvOSSearchTabButton: some View {
|
private var tvOSSearchTabButton: some View {
|
||||||
let isSelected = tvOSShowSearchTab
|
let isSelected = tvOSShowSearchTab
|
||||||
let action = {
|
let action = {
|
||||||
|
tvOSFocusedTab = .searchTab
|
||||||
if !tvOSShowSearchTab {
|
if !tvOSShowSearchTab {
|
||||||
tvOSShowSearchTab = true
|
tvOSShowSearchTab = true
|
||||||
isSearchActive = true
|
isSearchActive = true
|
||||||
@@ -651,20 +658,17 @@ struct ChannelView: View {
|
|||||||
.fontWeight(isSelected ? .bold : .regular)
|
.fontWeight(isSelected ? .bold : .regular)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
|
||||||
if isSelected {
|
|
||||||
Button(action: action) { label }
|
Button(action: action) { label }
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
.tint(accentColor)
|
.tint(isSelected ? accentColor : Color.gray.opacity(0.3))
|
||||||
} else {
|
.focused($tvOSFocusedTab, equals: .searchTab)
|
||||||
Button(action: action) { label }
|
|
||||||
.buttonStyle(.bordered)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func tvOSTabButton(for tab: ChannelTab) -> some View {
|
private func tvOSTabButton(for tab: ChannelTab) -> some View {
|
||||||
let isSelected = !tvOSShowSearchTab && selectedTab == tab
|
let isSelected = !tvOSShowSearchTab && selectedTab == tab
|
||||||
let action = {
|
let action = {
|
||||||
|
tvOSFocusedTab = .tab(tab)
|
||||||
if tvOSShowSearchTab {
|
if tvOSShowSearchTab {
|
||||||
tvOSShowSearchTab = false
|
tvOSShowSearchTab = false
|
||||||
isSearchActive = false
|
isSearchActive = false
|
||||||
@@ -680,14 +684,10 @@ struct ChannelView: View {
|
|||||||
.fontWeight(isSelected ? .bold : .regular)
|
.fontWeight(isSelected ? .bold : .regular)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
|
||||||
if isSelected {
|
|
||||||
Button(action: action) { label }
|
Button(action: action) { label }
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
.tint(accentColor)
|
.tint(isSelected ? accentColor : Color.gray.opacity(0.3))
|
||||||
} else {
|
.focused($tvOSFocusedTab, equals: .tab(tab))
|
||||||
Button(action: action) { label }
|
|
||||||
.buttonStyle(.bordered)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var tvOSRightColumn: some View {
|
private var tvOSRightColumn: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user