Merge profile to dashboard

This commit is contained in:
世界
2025-11-26 22:25:52 +08:00
parent 4f0d1098e6
commit 264c37218c
27 changed files with 1590 additions and 306 deletions
@@ -58,6 +58,7 @@ public struct ShareButtonCompat<Label>: View where Label: View {
public var body: some View {
Button(action: shareItem, label: label)
.buttonStyle(.plain)
#if os(macOS)
.background(SharingServicePicker($sharePresented, $alert, itemURL))
#endif
@@ -66,7 +67,7 @@ public struct ShareButtonCompat<Label>: View where Label: View {
private func shareItem() {
#if os(iOS)
Task {
await shareItem0()
await shareItemAsync()
}
#elseif os(macOS)
sharePresented = true
@@ -74,11 +75,11 @@ public struct ShareButtonCompat<Label>: View where Label: View {
}
#if os(iOS)
private nonisolated func shareItem0() async {
private nonisolated func shareItemAsync() async {
do {
let shareItem = try await itemURL()
await MainActor.run {
shareItem1(shareItem)
presentShareController(shareItem)
}
} catch {
await MainActor.run {
@@ -87,10 +88,20 @@ public struct ShareButtonCompat<Label>: View where Label: View {
}
}
private func shareItem1(_ item: URL) {
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
windowScene.keyWindow?.rootViewController?.present(UIActivityViewController(activityItems: [item], applicationActivities: nil), animated: true, completion: nil)
private func presentShareController(_ item: URL) {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootViewController = windowScene.keyWindow?.rootViewController
else {
return
}
var topViewController = rootViewController
while let presented = topViewController.presentedViewController {
topViewController = presented
}
topViewController.present(
UIActivityViewController(activityItems: [item], applicationActivities: nil),
animated: true
)
}
#endif
}