-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Refactor SavedTripsScreen with Trip object and enhance interactio…
…ns (#259) ### TL;DR Refactored saved trips functionality and improved UI interactions. ### What changed? - Updated `SavedTripUiEvent` to use `Trip` object instead of string identifiers - Added `tripId` property to `Trip` class for easier identification - Modified `SavedTripCard` to accept `Trip` object instead of separate origin and destination - Updated `SavedTripsScreen` to handle card clicks and deletions - Implemented event handling in `SavedTripsViewModel` for deleting and clicking saved trips - Updated `TimeTableViewModel` to use `tripId` when saving trips ### Why make this change? This refactoring improves the consistency and maintainability of the saved trips feature. By using the `Trip` object throughout the flow, we reduce the chance of errors and make the code more type-safe. The changes also enhance the user experience by providing more intuitive interactions with saved trips.
- Loading branch information
1 parent
416c970
commit 34adc73
Showing
7 changed files
with
89 additions
and
57 deletions.
There are no files selected for viewing
9 changes: 3 additions & 6 deletions
9
...ate/src/main/kotlin/xyz/ksharma/krail/trip/planner/ui/state/savedtrip/SavedTripUiEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
package xyz.ksharma.krail.trip.planner.ui.state.savedtrip | ||
|
||
import xyz.ksharma.krail.trip.planner.ui.state.searchstop.model.StopItem | ||
import xyz.ksharma.krail.trip.planner.ui.state.timetable.Trip | ||
|
||
sealed interface SavedTripUiEvent { | ||
data object LoadSavedTrips : SavedTripUiEvent | ||
data class SavedTripClicked(val savedTrip: String) : SavedTripUiEvent | ||
data class DeleteSavedTrip(val savedTrip: String) : SavedTripUiEvent | ||
data class OnSearchButtonClicked(val fromStopItem: StopItem, val toStopItem: StopItem) : | ||
SavedTripUiEvent | ||
data class SavedTripClicked(val trip: Trip) : SavedTripUiEvent | ||
data class DeleteSavedTrip(val trip: Trip) : SavedTripUiEvent | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters