Skip to content

Commit

Permalink
- change button to allow isEditingVehicle to equal true.
Browse files Browse the repository at this point in the history
  • Loading branch information
TratonGossink committed Nov 21, 2023
1 parent 5594ab5 commit 97dfae3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Basic-Car-Maintenance/Shared/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@
}
},
"Edit" : {
"comment" : "Button label to edit this maintenance",
"comment" : "Button label to edit this vehicle\nButton label to edit this maintenance",
"localizations" : {
"be" : {
"stringUnit" : {
Expand Down
2 changes: 1 addition & 1 deletion Basic-Car-Maintenance/Shared/Models/EditVehicleEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ struct EditVehicleEvent: Codable, Identifiable, Hashable {
let color: String
let VIN: String
let licenseplatenumber: String
var vehicle: Vehicle
var vehicle: Vehicle?
}
31 changes: 22 additions & 9 deletions Basic-Car-Maintenance/Shared/Settings/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SettingsView: View {
@State private var copiedAppVersion: Bool = false

@State private var selectedVehicleEvent: EditVehicleEvent?
@Binding private var isEditingVehicle: Bool
@State private var isEditingVehicle: Bool = false
@State var editViewModel: EditVehicleView?
@State private var vehicleToEdit: Vehicle?

Expand Down Expand Up @@ -129,24 +129,38 @@ struct SettingsView: View {
} label: {
Text("Delete", comment: "Label to delete a vehicle")
}
// Button {
// Task {
// selectedVehicleEvent = vehicle
// isEditingVehicle = true
// }
// }
// } label: {
// VStack {
// Text("Edit", comment: "Button label to edit this vehicle")
// Image(systemName: SFSymbol.pencil)
// }
// .sheet(isPresented: $isEditingVehicle) {
// EditVehicleView(
// selectedEvent: $selectedVehicleEvent, viewModel: viewModel)
// }

Button {
Task {
selectedVehicleEvent = vehicle
// selectedVehicleEvent = vehicle
isEditingVehicle = true
EditVehicleView(selectedEvent: $selectedVehicleEvent, viewModel: viewModel)

Check warning on line 152 in Basic-Car-Maintenance/Shared/Settings/Views/SettingsView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Line should be 110 characters or less; currently it has 111 characters (line_length)
}
}
} label: {
VStack {
} label: {
Text("Edit", comment: "Button label to edit this vehicle")
Image(systemName: SFSymbol.pencil)
}
.sheet(isPresented: $isEditingVehicle) {
EditVehicleView(
selectedEvent: $selectedVehicleEvent, viewModel: viewModel)
EditVehicleView(
selectedEvent: $selectedVehicleEvent, viewModel: viewModel)
}
}
}

Button {
isShowingAddVehicle = true

Check warning on line 165 in Basic-Car-Maintenance/Shared/Settings/Views/SettingsView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

TODOs should be resolved (Show Paywall) (todo)
} label: {
Expand Down Expand Up @@ -227,7 +241,6 @@ struct SettingsView: View {
}
}
}

// swiftlint:disable:next line_length
.alert(Text("Failed To Delete Vehicle", comment: "Label to dsplay title of the delete vehicle alert"),
isPresented: $showDeleteVehicleError) {
Expand Down

0 comments on commit 97dfae3

Please sign in to comment.