VisionOS fixes

This commit is contained in:
Thomas Ricouard 2024-01-15 21:15:40 +01:00
parent b8be6b79af
commit a4927fd30c
6 changed files with 35 additions and 3 deletions

View file

@ -18,9 +18,9 @@ struct AppView: View {
@Environment(Theme.self) private var theme @Environment(Theme.self) private var theme
@Environment(StreamWatcher.self) private var watcher @Environment(StreamWatcher.self) private var watcher
@Environment(\.openWindow) var openWindow
@Environment(\.horizontalSizeClass) private var horizontalSizeClass @Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Binding var selectedTab: Tab @Binding var selectedTab: Tab
@Binding var appRouterPath: RouterPath @Binding var appRouterPath: RouterPath
@ -57,7 +57,11 @@ struct AppView: View {
selectedTab selectedTab
}, set: { newTab in }, set: { newTab in
if newTab == .post { if newTab == .post {
#if os(visionOS)
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
#else
appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility) appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
#endif
return return
} }
if newTab == selectedTab { if newTab == selectedTab {

View file

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

View file

@ -15,13 +15,19 @@ public struct TagsListView: View {
List { List {
ForEach(tags) { tag in ForEach(tags) { tag in
TagRowView(tag: tag) TagRowView(tag: tag)
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
#endif
.padding(.vertical, 4) .padding(.vertical, 4)
} }
} }
#if !os(visionOS)
.scrollContentBackground(.hidden) .scrollContentBackground(.hidden)
.background(theme.primaryBackgroundColor) .background(theme.primaryBackgroundColor)
.listStyle(.plain) .listStyle(.plain)
#else
.listStyle(.grouped)
#endif
.navigationTitle("explore.section.trending.tags") .navigationTitle("explore.section.trending.tags")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
} }

View file

@ -34,7 +34,11 @@ public struct StatusEmbeddedView: View {
Spacer() Spacer()
} }
.padding(8) .padding(8)
#if os(visionOS)
.background(Material.thickMaterial)
#else
.background(theme.secondaryBackgroundColor) .background(theme.secondaryBackgroundColor)
#endif
.cornerRadius(4) .cornerRadius(4)
.overlay( .overlay(
RoundedRectangle(cornerRadius: 4) RoundedRectangle(cornerRadius: 4)

View file

@ -145,7 +145,11 @@ struct StatusRowActionsView: View {
} }
.padding(.vertical, 6) .padding(.vertical, 6)
.padding(.trailing, 8) .padding(.trailing, 8)
#if os(visionOS)
.buttonStyle(.borderless)
#else
.buttonStyle(.statusAction()) .buttonStyle(.statusAction())
#endif
.accessibilityElement(children: .combine) .accessibilityElement(children: .combine)
.accessibilityLabel("status.action.share-link") .accessibilityLabel("status.action.share-link")
case .linkAndText: case .linkAndText:
@ -158,7 +162,11 @@ struct StatusRowActionsView: View {
} }
.padding(.vertical, 6) .padding(.vertical, 6)
.padding(.trailing, 8) .padding(.trailing, 8)
#if os(visionOS)
.buttonStyle(.borderless)
#else
.buttonStyle(.statusAction()) .buttonStyle(.statusAction())
#endif
.accessibilityElement(children: .combine) .accessibilityElement(children: .combine)
.accessibilityLabel("status.action.share-link") .accessibilityLabel("status.action.share-link")
} }
@ -229,12 +237,16 @@ struct StatusRowActionsView: View {
.padding(.trailing, 8) .padding(.trailing, 8)
.contentShape(Rectangle()) .contentShape(Rectangle())
} }
#if os(visionOS)
.buttonStyle(.borderless)
#else
.buttonStyle( .buttonStyle(
.statusAction( .statusAction(
isOn: action.isOn(dataController: statusDataController), isOn: action.isOn(dataController: statusDataController),
tintColor: action.tintColor(theme: theme) tintColor: action.tintColor(theme: theme)
) )
) )
#endif
.disabled(action == .boost && .disabled(action == .boost &&
(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != currentAccount.account?.id)) (viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != currentAccount.account?.id))
.accessibilityElement(children: .combine) .accessibilityElement(children: .combine)

View file

@ -48,7 +48,9 @@ public struct StatusRowCardView: View {
if let title = card.title, let url = URL(string: card.url) { if let title = card.title, let url = URL(string: card.url) {
VStack(alignment: .leading) { VStack(alignment: .leading) {
let sitesWithIcons = ["apps.apple.com", "music.apple.com", "open.spotify.com"] let sitesWithIcons = ["apps.apple.com", "music.apple.com", "open.spotify.com"]
if (UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac), if (UIDevice.current.userInterfaceIdiom == .pad ||
UIDevice.current.userInterfaceIdiom == .mac ||
UIDevice.current.userInterfaceIdiom == .vision),
let host = url.host(), sitesWithIcons.contains(host) { let host = url.host(), sitesWithIcons.contains(host) {
iconLinkPreview(title, url) iconLinkPreview(title, url)
} else { } else {
@ -57,7 +59,11 @@ public struct StatusRowCardView: View {
} }
.frame(maxWidth: maxWidth) .frame(maxWidth: maxWidth)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
#if os(visionOS)
.background(Material.thick)
#else
.background(theme.secondaryBackgroundColor) .background(theme.secondaryBackgroundColor)
#endif
.cornerRadius(16) .cornerRadius(16)
.overlay( .overlay(
RoundedRectangle(cornerRadius: 16) RoundedRectangle(cornerRadius: 16)