From 4f9cb2e86aa324382cbe954859ef3851dc1daa29 Mon Sep 17 00:00:00 2001 From: Keita Watanabe Date: Mon, 29 Jul 2024 14:55:44 +0900 Subject: [PATCH 1/4] fix sendable (#2144) --- Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift b/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift index 1b6d8efa..37b34f96 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift @@ -9,7 +9,7 @@ public let availableColorsSets: [ColorSetCouple] = .init(light: ConstellationLight(), dark: ConstellationDark()), .init(light: ThreadsLight(), dark: ThreadsDark())] -public protocol ColorSet { +public protocol ColorSet: Sendable { var name: ColorSetName { get } var scheme: ColorScheme { get } var tintColor: Color { get set } @@ -18,11 +18,11 @@ public protocol ColorSet { var labelColor: Color { get set } } -public enum ColorScheme: String { +public enum ColorScheme: String, Sendable { case dark, light } -public enum ColorSetName: String { +public enum ColorSetName: String, Sendable { case iceCubeDark = "Ice Cube - Dark" case iceCubeLight = "Ice Cube - Light" case iceCubeNeonDark = "Ice Cube Neon - Dark" @@ -39,7 +39,7 @@ public enum ColorSetName: String { case threadsDark = "Threads - Dark" } -public struct ColorSetCouple: Identifiable { +public struct ColorSetCouple: Identifiable, Sendable { public var id: String { dark.name.rawValue + light.name.rawValue } From 9af98c39211b0647535b11738dcb50c87f626965 Mon Sep 17 00:00:00 2001 From: fwcd <30873659+fwcd@users.noreply.github.com> Date: Mon, 29 Jul 2024 07:56:22 +0200 Subject: [PATCH 2/4] Add context menu and draggability to attachment image views (#2142) * Factor out MediaUIShareLink * Add share link to attachment image view * Make attachment image views draggable * Add copy actions to attachment image view --- .../MediaUI/MediaUIAttachmentImageView.swift | 17 +++++++++++++++++ .../Sources/MediaUI/MediaUIShareLink.swift | 16 ++++++++++++++++ .../Sources/MediaUI/ShareToolbarItem.swift | 8 +------- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift diff --git a/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift b/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift index e29f1aaf..cc5f9921 100644 --- a/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift +++ b/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift @@ -22,6 +22,23 @@ struct MediaUIAttachmentImageView: View { .progressViewStyle(.circular) } } + .draggable(MediaUIImageTransferable(url: url)) + .contextMenu { + MediaUIShareLink(url: url, type: .image) + Button { + Task { + let transferable = MediaUIImageTransferable(url: url) + UIPasteboard.general.image = UIImage(data: await transferable.fetchData()) + } + } label: { + Label("status.media.contextmenu.copy", systemImage: "doc.on.doc") + } + Button { + UIPasteboard.general.url = url + } label: { + Label("status.action.copy-link", systemImage: "link") + } + } } } } diff --git a/Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift b/Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift new file mode 100644 index 00000000..54e0e1f6 --- /dev/null +++ b/Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift @@ -0,0 +1,16 @@ +import SwiftUI + +struct MediaUIShareLink: View, @unchecked Sendable { + let url: URL + let type: DisplayType + + var body: some View { + if type == .image { + let transferable = MediaUIImageTransferable(url: url) + ShareLink(item: transferable, preview: .init("status.media.contextmenu.share", + image: transferable)) + } else { + ShareLink(item: url) + } + } +} diff --git a/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift b/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift index eab146fd..dd29973f 100644 --- a/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift +++ b/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift @@ -6,13 +6,7 @@ struct ShareToolbarItem: ToolbarContent, @unchecked Sendable { var body: some ToolbarContent { ToolbarItem(placement: .topBarTrailing) { - if type == .image { - let transferable = MediaUIImageTransferable(url: url) - ShareLink(item: transferable, preview: .init("status.media.contextmenu.share", - image: transferable)) - } else { - ShareLink(item: url) - } + MediaUIShareLink(url: url, type: type) } } } From 33c2646ea192a7141a7eb4e64aa5e160015f426f Mon Sep 17 00:00:00 2001 From: fwcd <30873659+fwcd@users.noreply.github.com> Date: Mon, 29 Jul 2024 07:56:42 +0200 Subject: [PATCH 3/4] Make status rows draggable (#2141) --- .../StatusKit/Sources/StatusKit/Row/StatusRowView.swift | 1 + .../Sources/StatusKit/Row/StatusRowViewModel.swift | 6 +++++- .../StatusKit/Row/Subviews/StatusRowCardView.swift | 1 + .../StatusKit/Row/Subviews/StatusRowContextMenu.swift | 8 +++----- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift index 7b0c2c7b..3add988d 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift @@ -124,6 +124,7 @@ public struct StatusRowView: View { } } } + .if(viewModel.url != nil) { $0.draggable(viewModel.url!) } .contextMenu { contextMenu .onAppear { diff --git a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowViewModel.swift b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowViewModel.swift index 1e149dd2..eceb66cc 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowViewModel.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowViewModel.swift @@ -105,7 +105,11 @@ import SwiftUI status.reblog?.inReplyToId != nil || status.reblog?.inReplyToAccountId != nil || status.inReplyToId != nil || status.inReplyToAccountId != nil } - + + var url: URL? { + (status.reblog?.url ?? status.url).flatMap(URL.init(string:)) + } + @ViewBuilder func makeBackgroundColor(isHomeTimeline: Bool) -> some View { if isHomeTimeline, theme.showContentGradient { diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift index 332c89b8..0c69c0c8 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift @@ -81,6 +81,7 @@ public struct StatusRowCardView: View { .stroke(.gray.opacity(0.35), lineWidth: 1) } } + .draggable(url) .contextMenu { ShareLink(item: url) { Label("status.card.share", systemImage: "square.and.arrow.up") diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift index e44ae4b9..ad5cb675 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift @@ -88,9 +88,7 @@ struct StatusRowContextMenu: View { Divider() Menu("status.action.share-title") { - if let urlString = viewModel.status.reblog?.url ?? viewModel.status.url, - let url = URL(string: urlString) - { + if let url = viewModel.url { ShareLink(item: url, subject: Text(viewModel.status.reblog?.account.safeDisplayName ?? viewModel.status.account.safeDisplayName), message: Text(viewModel.status.reblog?.content.asRawText ?? viewModel.status.content.asRawText)) @@ -133,7 +131,7 @@ struct StatusRowContextMenu: View { } } - if let url = URL(string: viewModel.status.reblog?.url ?? viewModel.status.url ?? "") { + if let url = viewModel.url { Button { UIApplication.shared.open(url) } label: { Label("status.action.view-in-browser", systemImage: "safari") } @@ -152,7 +150,7 @@ struct StatusRowContextMenu: View { } Button { - UIPasteboard.general.string = viewModel.status.reblog?.url ?? viewModel.status.url + UIPasteboard.general.url = viewModel.url } label: { Label("status.action.copy-link", systemImage: "link") } From 6766ed496dbc70d1b7d4e583dd3e334fae15b1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adem=20=C3=96zsay=C4=B1n?= Date: Mon, 29 Jul 2024 08:57:33 +0300 Subject: [PATCH 4/4] Fix nav bar crash and empty settings screen after logout (#2124) --- IceCubesApp/App/Main/AppView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/IceCubesApp/App/Main/AppView.swift b/IceCubesApp/App/Main/AppView.swift index ff72955c..c1e4cb43 100644 --- a/IceCubesApp/App/Main/AppView.swift +++ b/IceCubesApp/App/Main/AppView.swift @@ -122,6 +122,7 @@ struct AppView: View { .tag(tab) } } + .id(availableTabs.count) /// Resets the TabView state when the number of tabs changes to avoid navigation bar issues and prevent crashes .introspect(.tabView, on: .iOS(.v17, .v18)) { (tabview: UITabBarController) in tabview.tabBar.isHidden = horizontalSizeClass == .regular tabview.customizableViewControllers = []