Rename cap variable to make it multi-purpose
This commit is contained in:
parent
25aadffa51
commit
fb90a4847e
@ -53,7 +53,7 @@ struct ContentView: View {
|
||||
var isEnteringNewCapName = false
|
||||
|
||||
@State
|
||||
private var capIdOfNextPhoto: Int?
|
||||
private var selectedCapId: Int?
|
||||
|
||||
var filteredCaps: [Cap] {
|
||||
let text = searchString
|
||||
@ -253,7 +253,7 @@ struct ContentView: View {
|
||||
.sheet(isPresented: $showCameraSheet) {
|
||||
CameraView(isPresented: $showCameraSheet,
|
||||
image: $database.image,
|
||||
capId: $capIdOfNextPhoto)
|
||||
capId: $selectedCapId)
|
||||
}
|
||||
.sheet(isPresented: $showSettingsSheet) {
|
||||
SettingsView(isPresented: $showSettingsSheet)
|
||||
@ -334,13 +334,13 @@ struct ContentView: View {
|
||||
|
||||
private func didTap(cap: Cap) {
|
||||
guard let image = database.image else {
|
||||
capIdOfNextPhoto = cap.id
|
||||
selectedCapId = cap.id
|
||||
openCamera()
|
||||
return
|
||||
}
|
||||
database.save(image, for: cap.id)
|
||||
database.image = nil
|
||||
capIdOfNextPhoto = nil
|
||||
selectedCapId = nil
|
||||
}
|
||||
|
||||
private func saveNewCap() {
|
||||
@ -356,16 +356,16 @@ struct ContentView: View {
|
||||
|
||||
private func showRenameWindow(for cap: Cap) {
|
||||
updatedCapName = cap.name
|
||||
capIdOfNextPhoto = cap.id
|
||||
selectedCapId = cap.id
|
||||
showUpdateCapNameAlert = true
|
||||
}
|
||||
|
||||
private func saveNewCapName() {
|
||||
defer {
|
||||
capIdOfNextPhoto = nil
|
||||
selectedCapId = nil
|
||||
updatedCapName = ""
|
||||
}
|
||||
guard let capId = capIdOfNextPhoto else {
|
||||
guard let capId = selectedCapId else {
|
||||
return
|
||||
}
|
||||
let name = updatedCapName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
@ -273,7 +273,7 @@ final class Database: ObservableObject {
|
||||
continue
|
||||
}
|
||||
if changedCaps.contains(oldCap.id) {
|
||||
#warning("Merge changed caps with server updates")
|
||||
#warning("Merge changed caps with server updates")
|
||||
} else {
|
||||
oldCap.update(with: cap)
|
||||
let save = oldCap
|
||||
|
Loading…
Reference in New Issue
Block a user