Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5 Edit Vehicle #269

Conversation

TratonGossink
Copy link
Contributor

What it Does

How I Tested

*Run the application.
*Tap "Add Vehicle"
*Create new mock-up vehicle
*Swip to view edit option

Notes

  • N/A

Screenshot

  • Add a screenshot of your new feature! OR show a screen recording of it in action. (On the simulator press Cmd + R to record, and the stop button when done). This video should be no longer than 30 seconds.

Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're almost there!! I have several comments that need resolved, which you know from our DMs. If you have any questions, you can comment directly on that thread, otherwise click the resolve button once you've addressed my comment. Once you fix everything, please click the re-review button

Re-review button

@@ -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",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a thing I recently learned, you can't have two comments for a single key
So for this you'd need to make a new key like EditVehicle and then you'd write the commend, and in the actual Localizable.xcstrings file you'd write just Edit

}
}

AnalyticsService.shared.logEvent(.maintenanceUpdate)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a maintenanceUpdate this is a vehicleUpdate

@@ -88,6 +90,30 @@ final class SettingsViewModel {
}
}

///Updates users vehicle that is being edited. Fetches selected vehicle from Firestore and saves to that selected vehicle.
func updateEvent(_ editVehicleEvent: EditVehicleEvent) async {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't be making a new model EditVehicleEvent, you should just be using Vehicle


AnalyticsService.shared.logEvent(.maintenanceUpdate)

await self.getVehicles()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the self it's implied

} label: {
Text("Update")
}
.disabled(name.isEmpty)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the same rules as isVehicleValid in the AddVehicleView

Comment on lines +26 to +29
@State private var selectedVehicleEvent: EditVehicleEvent?
@State private var isEditingVehicle = false
@State var editViewModel: EditVehicleView?
@State private var vehicleToEdit: Vehicle?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only need the vehicleToEdit, you shouldn't be using a separate model for editing, so EditVehicleEvent is not needed

Also don't call this editViewModel is not needed

@@ -124,9 +129,21 @@ struct SettingsView: View {
} label: {
Text("Delete", comment: "Label to delete a vehicle")
}
Button {
isEditingVehicle = true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where you would put vehicleToEdit = vehicle, because this is in the ForEach loop, and it's specifying which vehicle is going to show in the EditVehicleView

Comment on lines +141 to +143
.sheet(isPresented: $isEditingVehicle) {
EditVehicleView(
selectedEvent: $selectedVehicleEvent, viewModel: viewModel)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we'd pass the vehicleToEdit because we are using the Vehicle model, not the new one you created

@mikaelacaron mikaelacaron changed the base branch from dev to fix-vehicle-event-connection November 24, 2023 21:01
Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @TratonGossink I'm going to go ahead and merge this into fix-vehicle-event-connection which is something I'm already working on, because I'm redoing the current Firestore schema

Thanks for all your work!

@mikaelacaron mikaelacaron merged commit a6f96fa into mikaelacaron:fix-vehicle-event-connection Nov 24, 2023
2 checks passed
@mikaelacaron mikaelacaron changed the title 5 edit vehicle 5 Edit Vehicle Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FEATURE - Edit Vehicle Details
2 participants