Enhance visionOS support

This commit is contained in:
Thomas Ricouard 2024-02-06 15:17:20 +01:00
parent f14ca6e529
commit b9b3d0e727
6 changed files with 62 additions and 3 deletions

View file

@ -25,7 +25,7 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable {
}
static func visionOSTab() -> [Tab] {
[.profile, .timeline, .notifications, .mentions, .explore, .messages, .post, .settings]
[.profile, .timeline, .notifications, .mentions, .explore, .post, .settings]
}
@ViewBuilder

View file

@ -38,7 +38,9 @@ struct EditTagGroupView: View {
focusedField: $focusedField
)
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#endif
Section("add-tag-groups.edit.tags") {
TagsInputView(
@ -47,7 +49,9 @@ struct EditTagGroupView: View {
focusedField: $focusedField
)
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#endif
}
.formStyle(.grouped)
.navigationTitle(

View file

@ -169,6 +169,10 @@ public struct ExploreView: View {
AccountsListRow(viewModel: .init(account: account, relationShip: relationship))
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
}
}
@ -180,6 +184,10 @@ public struct ExploreView: View {
TagRowView(tag: tag)
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
.padding(.vertical, 4)
}
@ -191,6 +199,10 @@ public struct ExploreView: View {
StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath))
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
.padding(.vertical, 8)
}
@ -207,6 +219,10 @@ public struct ExploreView: View {
AccountsListRow(viewModel: .init(account: account, relationShip: relationship))
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
}
}
@ -216,6 +232,10 @@ public struct ExploreView: View {
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
}
}
@ -228,6 +248,10 @@ public struct ExploreView: View {
TagRowView(tag: tag)
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
.padding(.vertical, 4)
}
@ -237,6 +261,10 @@ public struct ExploreView: View {
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
}
}
@ -249,6 +277,10 @@ public struct ExploreView: View {
StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath))
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
.padding(.vertical, 8)
}
@ -259,6 +291,10 @@ public struct ExploreView: View {
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
}
}
@ -271,6 +307,10 @@ public struct ExploreView: View {
StatusRowCardView(card: card)
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
.padding(.vertical, 8)
}
@ -281,6 +321,10 @@ public struct ExploreView: View {
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#else
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#endif
}
}

View file

@ -34,7 +34,9 @@ public struct ListEditView: View {
}
Toggle("list.edit.isExclusive", isOn: $viewModel.isExclusive)
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#endif
.disabled(viewModel.isUpdating)
.onChange(of: viewModel.repliesPolicy) { _, _ in
Task { await viewModel.update() }
@ -62,14 +64,16 @@ public struct ListEditView: View {
listAccountsView
}
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#endif
.disabled(viewModel.isUpdating)
}
#if !os(visionOS)
.scrollDismissesKeyboard(.immediately)
#endif
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
#endif
.toolbar {
ToolbarItem {
Button {

View file

@ -172,7 +172,8 @@ public struct NotificationsListView: View {
trailing: .layoutPadding))
#if os(visionOS)
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(notification.type == .mention && lockedType != .mention ? Material.thick : Material.regular))
.foregroundStyle(notification.type == .mention && lockedType != .mention ? Material.thick : Material.regular).hoverEffect())
.listRowHoverEffectDisabled()
#else
.listRowBackground(notification.type == .mention && lockedType != .mention ?
theme.secondaryBackgroundColor : theme.primaryBackgroundColor)

View file

@ -12,7 +12,13 @@ struct TimelineHeaderView<Content: View>: View {
content()
Spacer()
}
#if os(visionOS)
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#else
.listRowBackground(theme.secondaryBackgroundColor)
#endif
.listRowSeparator(.hidden)
.listRowInsets(.init(top: 8,
leading: .layoutPadding,