From 434247f3ea05d25f7c32f741bd314ca281ce5eb6 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Tue, 24 Oct 2023 18:34:45 +0200 Subject: [PATCH] Fixes for macOS --- IceCubesApp/App/IceCubesApp.swift | 17 +++-- IceCubesApp/App/SideBarView.swift | 1 - .../Localization/Localizable.xcstrings | 64 +++++++++++++------ .../Account/AccountDetailHeaderView.swift | 16 ++++- .../Detail/ConversationMessageView.swift | 8 ++- 5 files changed, 77 insertions(+), 29 deletions(-) diff --git a/IceCubesApp/App/IceCubesApp.swift b/IceCubesApp/App/IceCubesApp.swift index 31f1fe14..a88a12fc 100644 --- a/IceCubesApp/App/IceCubesApp.swift +++ b/IceCubesApp/App/IceCubesApp.swift @@ -16,6 +16,7 @@ struct IceCubesApp: App { @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate @Environment(\.scenePhase) private var scenePhase + @Environment(\.openWindow) private var openWindow @State private var appAccountsManager = AppAccountsManager.shared @State private var currentInstance = CurrentInstance.shared @@ -42,7 +43,7 @@ struct IceCubesApp: App { } private var appScene: some Scene { - WindowGroup { + WindowGroup(id: "MainWindow") { appView .applyTheme(theme) .onAppear { @@ -98,7 +99,6 @@ struct IceCubesApp: App { watcher.watch(streams: [.user, .direct]) } } - } @ViewBuilder @@ -273,9 +273,18 @@ struct IceCubesApp: App { @CommandsBuilder private var appMenu: some Commands { CommandGroup(replacing: .newItem) { - Button("menu.new-post") { - sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility) + Button("menu.new-window") { + openWindow(id: "MainWindow") } + .keyboardShortcut("n", modifiers: .shift) + Button("menu.new-post") { + if ProcessInfo.processInfo.isMacCatalystApp { + openWindow(value: WindowDestination.newStatusEditor(visibility: userPreferences.postVisibility)) + } else { + sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility) + } + } + .keyboardShortcut("n", modifiers: .command) } CommandGroup(replacing: .textFormatting) { Menu("menu.font") { diff --git a/IceCubesApp/App/SideBarView.swift b/IceCubesApp/App/SideBarView.swift index d966f6df..e7b79404 100644 --- a/IceCubesApp/App/SideBarView.swift +++ b/IceCubesApp/App/SideBarView.swift @@ -69,7 +69,6 @@ struct SideBarView: View { .frame(width: 20, height: 30) } .buttonStyle(.borderedProminent) - .keyboardShortcut("n", modifiers: .command) } private func makeAccountButton(account: AppAccount, showBadge: Bool) -> some View { diff --git a/IceCubesApp/Resources/Localization/Localizable.xcstrings b/IceCubesApp/Resources/Localization/Localizable.xcstrings index 1b148205..872af716 100644 --- a/IceCubesApp/Resources/Localization/Localizable.xcstrings +++ b/IceCubesApp/Resources/Localization/Localizable.xcstrings @@ -29932,120 +29932,142 @@ "localizations" : { "be" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Новы допіс" } }, "ca" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Publicació nova" } }, "de" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Neuer Beitrag" } }, "en" : { "stringUnit" : { "state" : "translated", - "value" : "New post" + "value" : "New Post" } }, "en-GB" : { "stringUnit" : { - "state" : "translated", - "value" : "New post" + "state" : "needs_review", + "value" : "New Post" } }, "es" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Publicación nueva" } }, "eu" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Bidalketa berria" } }, "fr" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Nouvelle publication" } }, "it" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Nuovo post" } }, "ja" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "新しい投稿" } }, "ko" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "새 글" } }, "nb" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Nytt innlegg" } }, "nl" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Nieuwe post" } }, "pl" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Nowy post" } }, "pt-BR" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Nova postagem" } }, "tr" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "New post" } }, "uk" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "Новий допис" } }, "zh-Hans" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "新嘟文" } }, "zh-Hant" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "新嘟文" } } } }, + "menu.new-window" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "New Window" + } + }, + "en-GB" : { + "stringUnit" : { + "state" : "translated", + "value" : "New Window" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nouvelle fenêtre" + } + } + } + }, "notifications-others-count %lld" : { "extractionState" : "manual", "localizations" : { @@ -68353,4 +68375,4 @@ } }, "version" : "1.0" -} +} \ No newline at end of file diff --git a/Packages/Account/Sources/Account/AccountDetailHeaderView.swift b/Packages/Account/Sources/Account/AccountDetailHeaderView.swift index f21960e6..3627c671 100644 --- a/Packages/Account/Sources/Account/AccountDetailHeaderView.swift +++ b/Packages/Account/Sources/Account/AccountDetailHeaderView.swift @@ -12,6 +12,7 @@ struct AccountDetailHeaderView: View { static let headerHeight: CGFloat = 200 } + @Environment(\.openWindow) private var openWindow @Environment(Theme.self) private var theme @Environment(QuickLook.self) private var quickLook @Environment(RouterPath.self) private var routerPath @@ -80,7 +81,13 @@ struct AccountDetailHeaderView: View { return } let attachement = MediaAttachment.imageWith(url: account.header) - quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement]) + + if ProcessInfo.processInfo.isMacCatalystApp { + openWindow(value: WindowDestination.mediaViewer(attachments: [attachement], + selectedAttachment: attachement)) + } else { + quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement]) + } } .accessibilityElement(children: .combine) .accessibilityAddTraits([.isImage, .isButton]) @@ -110,7 +117,12 @@ struct AccountDetailHeaderView: View { return } let attachement = MediaAttachment.imageWith(url: account.avatar) - quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement]) + if ProcessInfo.processInfo.isMacCatalystApp { + openWindow(value: WindowDestination.mediaViewer(attachments: [attachement], + selectedAttachment: attachement)) + } else { + quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement]) + } } .accessibilityElement(children: .combine) .accessibilityAddTraits([.isImage, .isButton]) diff --git a/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift b/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift index 8be8fd48..66cbaedd 100644 --- a/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift +++ b/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift @@ -7,6 +7,7 @@ import SwiftUI @MainActor struct ConversationMessageView: View { + @Environment(\.openWindow) private var openWindow @Environment(QuickLook.self) private var quickLook @Environment(RouterPath.self) private var routerPath @Environment(CurrentAccount.self) private var currentAccount @@ -200,7 +201,12 @@ struct ConversationMessageView: View { .frame(height: 200) .contentShape(Rectangle()) .onTapGesture { - quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement]) + if ProcessInfo.processInfo.isMacCatalystApp { + openWindow(value: WindowDestination.mediaViewer(attachments: [attachement], + selectedAttachment: attachement)) + } else { + quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement]) + } } }