The overall UI of Ferrite has been changed to make animations smoother and streamline the experiences. A new search filter interface has been added for all iOS versions, but iOS 15 and up have smooth UI applied due to bugs with searchbars in iOS 14 (which shouldn't even have a searchbar in the first place). Also fix the plugin fetching logic to not listen to a combine publisher and instead use a notification that is easier to control. Signed-off-by: kingbri <bdashore3@proton.me>
75 lines
2.5 KiB
Swift
75 lines
2.5 KiB
Swift
//
|
|
// BackupsView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 9/16/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct BackupsView: View {
|
|
@EnvironmentObject var backupManager: BackupManager
|
|
@EnvironmentObject var navModel: NavigationViewModel
|
|
|
|
@State private var selectedBackupUrl: URL?
|
|
@State private var showRestoreAlert = false
|
|
@State private var showRestoreCompletedAlert = false
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
if backupManager.backupUrls.isEmpty {
|
|
EmptyInstructionView(title: "No Backups", message: "Create one using the + button in the top-right")
|
|
} else {
|
|
List {
|
|
ForEach(backupManager.backupUrls, id: \.self) { url in
|
|
Button(url.lastPathComponent) {
|
|
backupManager.selectedBackupUrl = url
|
|
backupManager.showRestoreAlert.toggle()
|
|
}
|
|
.contextMenu {
|
|
Button {
|
|
navModel.activityItems = [url]
|
|
navModel.currentChoiceSheet = .activity
|
|
} label: {
|
|
Label("Export", systemImage: "square.and.arrow.up")
|
|
}
|
|
}
|
|
.backport.tint(.primary)
|
|
}
|
|
.onDelete { offsets in
|
|
for index in offsets {
|
|
if let url = backupManager.backupUrls[safe: index] {
|
|
backupManager.removeBackup(backupUrl: url, index: index)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.inlinedList(inset: -20)
|
|
.listStyle(.insetGrouped)
|
|
}
|
|
}
|
|
.backport.onAppear {
|
|
backupManager.backupUrls = FileManager.default.appDirectory
|
|
.appendingPathComponent("Backups", isDirectory: true).contentsByDateAdded
|
|
}
|
|
.navigationTitle("Backups")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
Button {
|
|
Task {
|
|
await backupManager.createBackup()
|
|
}
|
|
} label: {
|
|
Image(systemName: "plus")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct BackupsView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
BackupsView()
|
|
}
|
|
}
|