Added an auto copy setting
This commit is contained in:
parent
44e25bf25e
commit
950b8c124c
@ -9,4 +9,5 @@ import Foundation
|
||||
|
||||
public struct Prefs {
|
||||
static let autoLaunchCamera = "autolaunchcamera"
|
||||
static let autoCopy = "autocopy"
|
||||
}
|
||||
|
@ -39,4 +39,7 @@ final class Scan {
|
||||
self.images = images.map{ $0.pngData() ?? Data() }
|
||||
}
|
||||
|
||||
public func copyImages() {
|
||||
UIPasteboard.general.images = self.uiImages
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ struct MainView: View {
|
||||
@Query var scans: [Scan]
|
||||
|
||||
@AppStorage(Prefs.autoLaunchCamera) var autolaunch = false
|
||||
@AppStorage(Prefs.autoCopy) var autoCopy = false
|
||||
|
||||
var isAuthorized: Bool {
|
||||
get async {
|
||||
@ -89,6 +90,8 @@ struct MainView: View {
|
||||
try? ctx.save()
|
||||
}
|
||||
|
||||
if autoCopy { newScan.copyImages() }
|
||||
|
||||
scannedImages = []
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ struct ScanItemView: View {
|
||||
Spacer()
|
||||
|
||||
if scan.images.count == 1 {
|
||||
Button { copy() } label: {
|
||||
Button { scan.copyImages() } label: {
|
||||
Image(systemName: "doc.on.doc.fill").tint(.white)
|
||||
.padding(8)
|
||||
.background(Color(red: 1, green: 1, blue: 1, opacity: 0.4))
|
||||
@ -72,10 +72,6 @@ struct ScanItemView: View {
|
||||
.padding(.horizontal, 12)
|
||||
}
|
||||
|
||||
func copy() {
|
||||
UIPasteboard.general.images = scan.uiImages
|
||||
}
|
||||
|
||||
func delete() {
|
||||
withAnimation(.easeOut) {
|
||||
ctx.delete(scan)
|
||||
|
@ -11,6 +11,7 @@ struct SettingsView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
@AppStorage(Prefs.autoLaunchCamera) var autoLaunchCamera = false
|
||||
@AppStorage(Prefs.autoCopy) var autoCopy = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
@ -29,6 +30,7 @@ struct SettingsView: View {
|
||||
var generalSettings: some View {
|
||||
Section {
|
||||
Toggle("Launch Camera on Startup", isOn: $autoLaunchCamera)
|
||||
Toggle("Auto-Copy on Save", isOn: $autoCopy)
|
||||
} header: { Text("General") }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user