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