summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-02-22 06:49:57 -0800
committerFuwn <[email protected]>2025-02-22 06:49:57 -0800
commitc73e15fdb2ae9e29a66bc75e92ac8e56c4adaedf (patch)
tree208645c0c78fe74e9098e5c0c47e5be779b26002
parentfeat: Development commit (diff)
downloadsora-testing-c73e15fdb2ae9e29a66bc75e92ac8e56c4adaedf.tar.xz
sora-testing-c73e15fdb2ae9e29a66bc75e92ac8e56c4adaedf.zip
feat: Development commit
-rw-r--r--Sora/Other/AsyncImageWithPreview.swift23
1 files changed, 17 insertions, 6 deletions
diff --git a/Sora/Other/AsyncImageWithPreview.swift b/Sora/Other/AsyncImageWithPreview.swift
index 6c47fb9..488e66e 100644
--- a/Sora/Other/AsyncImageWithPreview.swift
+++ b/Sora/Other/AsyncImageWithPreview.swift
@@ -12,6 +12,19 @@ struct AsyncImageWithPreview<Placeholder: View>: View {
@State private var currentOffset: CGSize = .zero
@State private var finalOffset: CGSize = .zero
+ var keyWindow: UIWindow? {
+ guard
+ let window = UIApplication.shared.connectedScenes
+ .compactMap({ $0 as? UIWindowScene })
+ .flatMap(\.windows)
+ .first(where: \.isKeyWindow)
+ else {
+ return nil
+ }
+
+ return window
+ }
+
var body: some View {
AsyncImage(url: url) { image in
ZoomableImageView(image: image)
@@ -37,12 +50,10 @@ struct AsyncImageWithPreview<Placeholder: View>: View {
#if os(iOS)
if settings.enableShareShortcut {
Button {
- let activityViewController = UIActivityViewController(
- activityItems: [url ?? URL(string: "")!], applicationActivities: nil
- )
-
- UIApplication.shared.windows.first?.rootViewController?.present(
- activityViewController, animated: true
+ keyWindow?.rootViewController?.present(
+ UIActivityViewController(
+ activityItems: [url ?? URL(string: "")!], applicationActivities: nil
+ ), animated: true
)
} label: {
Label("Share Image", systemImage: "square.and.arrow.up")