Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Where/WhereUI/Sources/Settings/BackupArchiveFile.swift

This file was deleted.

13 changes: 8 additions & 5 deletions Where/WhereUI/Sources/Settings/BackupSettingsSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ struct BackupSettingsSection: View {
let backup: BackupModel

/// Backup export: the ready-to-share archive built up-front, revealed as a
/// `ShareLink` once the background export finishes.
/// second row once the background export finishes.
@State private var exportedArchiveURL: URL?
@State private var presentedShareItem: BackupShareSheet.Item?

// Backup import: the picked file and the merge/replace choice. The success
// confirmation lives on `backup` (the model), so it survives this screen
Expand All @@ -25,6 +26,9 @@ struct BackupSettingsSection: View {
var body: some View {
@Bindable var backup = backup
backupSection
.sheet(item: $presentedShareItem) { item in
BackupShareSheet(item: item)
}
.fileImporter(
isPresented: $showImporter,
allowedContentTypes: [.zip],
Expand Down Expand Up @@ -101,10 +105,9 @@ struct BackupSettingsSection: View {
.settingsRow(DataSettingsView.Item.exportBackup)

if backup.backupState == .idle, let url = exportedArchiveURL {
ShareLink(
item: BackupArchiveFile(url: url),
preview: SharePreview(String(localized: .settingsBackupShareTitle)),
) {
Button {
presentedShareItem = BackupShareSheet.Item(url: url)
} label: {
Label(
String(localized: .settingsBackupShare),
systemImage: "square.and.arrow.up.on.square",
Expand Down
35 changes: 35 additions & 0 deletions Where/WhereUI/Sources/Settings/BackupShareSheet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import SwiftUI
import UIKit

/// Presents the system activity sheet for a completed backup archive.
///
/// `ShareLink` does not present reliably for this file on a physical device,
/// so the SwiftUI sheet owns UIKit's direct activity-controller bridge.
struct BackupShareSheet: UIViewControllerRepresentable {
struct Item: Identifiable {
let url: URL

var id: URL {
url
}
}

let item: Item

func makeUIViewController(context _: Context) -> UIActivityViewController {
UIActivityViewController(activityItems: [item.url], applicationActivities: nil)
}

func updateUIViewController(
_: UIActivityViewController,
context _: Context,
) {}
}

#if DEBUG
#Preview {
BackupShareSheet(
item: .init(url: URL(fileURLWithPath: "/tmp/Where Backup.zip")),
)
}
#endif
Loading