mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +00:00
Multi window visionOS support
This commit is contained in:
parent
e7864f7089
commit
b7e8f63e86
12 changed files with 15 additions and 16 deletions
|
@ -59,7 +59,7 @@ struct SideBarView<Content: View>: View {
|
||||||
|
|
||||||
private var postButton: some View {
|
private var postButton: some View {
|
||||||
Button {
|
Button {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||||
#else
|
#else
|
||||||
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||||
|
|
|
@ -83,7 +83,7 @@ struct AccountDetailHeaderView: View {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let attachement = MediaAttachment.imageWith(url: account.header)
|
let attachement = MediaAttachment.imageWith(url: account.header)
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationMedia.mediaViewer(
|
openWindow(value: WindowDestinationMedia.mediaViewer(
|
||||||
attachments: [attachement],
|
attachments: [attachement],
|
||||||
selectedAttachment: attachement
|
selectedAttachment: attachement
|
||||||
|
@ -120,7 +120,7 @@ struct AccountDetailHeaderView: View {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let attachement = MediaAttachment.imageWith(url: account.avatar)
|
let attachement = MediaAttachment.imageWith(url: account.avatar)
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
||||||
selectedAttachment: attachement))
|
selectedAttachment: attachement))
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -279,7 +279,7 @@ public struct AccountDetailView: View {
|
||||||
if !viewModel.isCurrentUser {
|
if !viewModel.isCurrentUser {
|
||||||
Button {
|
Button {
|
||||||
if let account = viewModel.account {
|
if let account = viewModel.account {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.mentionStatusEditor(account: account, visibility: preferences.postVisibility))
|
openWindow(value: WindowDestinationEditor.mentionStatusEditor(account: account, visibility: preferences.postVisibility))
|
||||||
#else
|
#else
|
||||||
routerPath.presentedSheet = .mentionStatusEditor(account: account,
|
routerPath.presentedSheet = .mentionStatusEditor(account: account,
|
||||||
|
|
|
@ -205,7 +205,7 @@ struct ConversationMessageView: View {
|
||||||
.frame(height: 200)
|
.frame(height: 200)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
||||||
selectedAttachment: attachement))
|
selectedAttachment: attachement))
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -83,7 +83,7 @@ struct ConversationsListRow: View {
|
||||||
.accessibilityAction(.magicTap) {
|
.accessibilityAction(.magicTap) {
|
||||||
if let lastStatus = conversation.lastStatus {
|
if let lastStatus = conversation.lastStatus {
|
||||||
HapticManager.shared.fireHaptic(.notification(.success))
|
HapticManager.shared.fireHaptic(.notification(.success))
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: lastStatus))
|
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: lastStatus))
|
||||||
#else
|
#else
|
||||||
routerPath.presentedSheet = .replyToStatusEditor(status: lastStatus)
|
routerPath.presentedSheet = .replyToStatusEditor(status: lastStatus)
|
||||||
|
@ -100,7 +100,7 @@ struct ConversationsListRow: View {
|
||||||
Button {
|
Button {
|
||||||
if let lastStatus = conversation.lastStatus {
|
if let lastStatus = conversation.lastStatus {
|
||||||
HapticManager.shared.fireHaptic(.notification(.success))
|
HapticManager.shared.fireHaptic(.notification(.success))
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: lastStatus))
|
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: lastStatus))
|
||||||
#else
|
#else
|
||||||
routerPath.presentedSheet = .replyToStatusEditor(status: lastStatus)
|
routerPath.presentedSheet = .replyToStatusEditor(status: lastStatus)
|
||||||
|
|
|
@ -35,7 +35,7 @@ public struct StatusEditorToolbarItem: ToolbarContent {
|
||||||
ToolbarItem(placement: .navigationBarTrailing) {
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
Button {
|
Button {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: visibility))
|
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: visibility))
|
||||||
#else
|
#else
|
||||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||||
|
|
|
@ -110,7 +110,6 @@ public struct ExploreView: View {
|
||||||
}
|
}
|
||||||
.task(id: viewModel.searchQuery) {
|
.task(id: viewModel.searchQuery) {
|
||||||
do {
|
do {
|
||||||
try await Task.sleep(for: .milliseconds(150))
|
|
||||||
await viewModel.search()
|
await viewModel.search()
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
|
|
||||||
func search() async {
|
func search() async {
|
||||||
guard let client else { return }
|
guard let client, !searchQuery.isEmpty else { return }
|
||||||
do {
|
do {
|
||||||
try await Task.sleep(for: .milliseconds(250))
|
try await Task.sleep(for: .milliseconds(250))
|
||||||
var results: SearchResults = try await client.get(endpoint: Search.search(query: searchQuery,
|
var results: SearchResults = try await client.get(endpoint: Search.search(query: searchQuery,
|
||||||
|
|
|
@ -217,7 +217,7 @@ public struct StatusRowView: View {
|
||||||
Button("accessibility.status.media-viewer-action.label") {
|
Button("accessibility.status.media-viewer-action.label") {
|
||||||
HapticManager.shared.fireHaptic(.notification(.success))
|
HapticManager.shared.fireHaptic(.notification(.success))
|
||||||
let attachments = viewModel.finalStatus.mediaAttachments
|
let attachments = viewModel.finalStatus.mediaAttachments
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationMedia.mediaViewer(
|
openWindow(value: WindowDestinationMedia.mediaViewer(
|
||||||
attachments: attachments,
|
attachments: attachments,
|
||||||
selectedAttachment: attachments[0]
|
selectedAttachment: attachments[0]
|
||||||
|
|
|
@ -252,7 +252,7 @@ struct StatusRowActionsView: View {
|
||||||
switch action {
|
switch action {
|
||||||
case .respond:
|
case .respond:
|
||||||
SoundEffectManager.shared.playSound(.share)
|
SoundEffectManager.shared.playSound(.share)
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status))
|
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status))
|
||||||
#else
|
#else
|
||||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status)
|
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status)
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct StatusRowContextMenu: View {
|
||||||
systemImage: "bookmark")
|
systemImage: "bookmark")
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
|
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
|
||||||
#else
|
#else
|
||||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||||
|
@ -64,7 +64,7 @@ struct StatusRowContextMenu: View {
|
||||||
Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
|
Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
|
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
|
||||||
#else
|
#else
|
||||||
viewModel.routerPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
viewModel.routerPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
||||||
|
@ -172,7 +172,7 @@ struct StatusRowContextMenu: View {
|
||||||
}
|
}
|
||||||
if currentInstance.isEditSupported {
|
if currentInstance.isEditSupported {
|
||||||
Button {
|
Button {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(value: WindowDestinationEditor.editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status))
|
openWindow(value: WindowDestinationEditor.editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status))
|
||||||
#else
|
#else
|
||||||
viewModel.routerPath.presentedSheet = .editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status)
|
viewModel.routerPath.presentedSheet = .editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status)
|
||||||
|
|
|
@ -107,7 +107,7 @@ public struct StatusRowMediaPreviewView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func tabAction(for index: Int) {
|
private func tabAction(for index: Int) {
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||||
openWindow(
|
openWindow(
|
||||||
value: WindowDestinationMedia.mediaViewer(
|
value: WindowDestinationMedia.mediaViewer(
|
||||||
attachments: attachments,
|
attachments: attachments,
|
||||||
|
|
Loading…
Reference in a new issue