From a4927fd30cf1a555613aeb069105c50ba86dc143 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 15 Jan 2024 21:15:40 +0100 Subject: [PATCH] VisionOS fixes --- IceCubesApp/App/Main/AppView.swift | 6 +++++- IceCubesApp/App/Tabs/Tabs.swift | 2 +- Packages/Explore/Sources/Explore/TagsListView.swift | 6 ++++++ .../Sources/StatusKit/Embed/StatusEmbeddedView.swift | 4 ++++ .../Row/Subviews/StatusRowActionsView.swift | 12 ++++++++++++ .../StatusKit/Row/Subviews/StatusRowCardView.swift | 8 +++++++- 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/IceCubesApp/App/Main/AppView.swift b/IceCubesApp/App/Main/AppView.swift index 32880c6f..3632e880 100644 --- a/IceCubesApp/App/Main/AppView.swift +++ b/IceCubesApp/App/Main/AppView.swift @@ -18,9 +18,9 @@ struct AppView: View { @Environment(Theme.self) private var theme @Environment(StreamWatcher.self) private var watcher + @Environment(\.openWindow) var openWindow @Environment(\.horizontalSizeClass) private var horizontalSizeClass - @Binding var selectedTab: Tab @Binding var appRouterPath: RouterPath @@ -57,7 +57,11 @@ struct AppView: View { selectedTab }, set: { newTab in if newTab == .post { + #if os(visionOS) + openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility)) + #else appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility) + #endif return } if newTab == selectedTab { diff --git a/IceCubesApp/App/Tabs/Tabs.swift b/IceCubesApp/App/Tabs/Tabs.swift index 9692f18e..49f1aa74 100644 --- a/IceCubesApp/App/Tabs/Tabs.swift +++ b/IceCubesApp/App/Tabs/Tabs.swift @@ -25,7 +25,7 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable { } static func visionOSTab() -> [Tab] { - [.profile, .timeline, .notifications, .mentions, .explore, .messages, .settings] + [.profile, .timeline, .notifications, .mentions, .explore, .messages, .post, .settings] } @ViewBuilder diff --git a/Packages/Explore/Sources/Explore/TagsListView.swift b/Packages/Explore/Sources/Explore/TagsListView.swift index bbf54d1d..de49a4ec 100644 --- a/Packages/Explore/Sources/Explore/TagsListView.swift +++ b/Packages/Explore/Sources/Explore/TagsListView.swift @@ -15,13 +15,19 @@ public struct TagsListView: View { List { ForEach(tags) { tag in TagRowView(tag: tag) + #if !os(visionOS) .listRowBackground(theme.primaryBackgroundColor) + #endif .padding(.vertical, 4) } } + #if !os(visionOS) .scrollContentBackground(.hidden) .background(theme.primaryBackgroundColor) .listStyle(.plain) + #else + .listStyle(.grouped) + #endif .navigationTitle("explore.section.trending.tags") .navigationBarTitleDisplayMode(.inline) } diff --git a/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift b/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift index 9331bfb4..b4dca5b3 100644 --- a/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift @@ -34,7 +34,11 @@ public struct StatusEmbeddedView: View { Spacer() } .padding(8) + #if os(visionOS) + .background(Material.thickMaterial) + #else .background(theme.secondaryBackgroundColor) + #endif .cornerRadius(4) .overlay( RoundedRectangle(cornerRadius: 4) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowActionsView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowActionsView.swift index d2e4449d..a3bae1fc 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowActionsView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowActionsView.swift @@ -145,7 +145,11 @@ struct StatusRowActionsView: View { } .padding(.vertical, 6) .padding(.trailing, 8) + #if os(visionOS) + .buttonStyle(.borderless) + #else .buttonStyle(.statusAction()) + #endif .accessibilityElement(children: .combine) .accessibilityLabel("status.action.share-link") case .linkAndText: @@ -158,7 +162,11 @@ struct StatusRowActionsView: View { } .padding(.vertical, 6) .padding(.trailing, 8) + #if os(visionOS) + .buttonStyle(.borderless) + #else .buttonStyle(.statusAction()) + #endif .accessibilityElement(children: .combine) .accessibilityLabel("status.action.share-link") } @@ -229,12 +237,16 @@ struct StatusRowActionsView: View { .padding(.trailing, 8) .contentShape(Rectangle()) } + #if os(visionOS) + .buttonStyle(.borderless) + #else .buttonStyle( .statusAction( isOn: action.isOn(dataController: statusDataController), tintColor: action.tintColor(theme: theme) ) ) + #endif .disabled(action == .boost && (viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != currentAccount.account?.id)) .accessibilityElement(children: .combine) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift index df52d836..b69da8c1 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift @@ -48,7 +48,9 @@ public struct StatusRowCardView: View { if let title = card.title, let url = URL(string: card.url) { VStack(alignment: .leading) { 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) { iconLinkPreview(title, url) } else { @@ -57,7 +59,11 @@ public struct StatusRowCardView: View { } .frame(maxWidth: maxWidth) .fixedSize(horizontal: false, vertical: true) + #if os(visionOS) + .background(Material.thick) + #else .background(theme.secondaryBackgroundColor) + #endif .cornerRadius(16) .overlay( RoundedRectangle(cornerRadius: 16)