Skip to content

Conversation

@ananyadua27
Copy link
Collaborator

@ananyadua27 ananyadua27 commented Nov 3, 2025

Changes Made

  • Added a property sortedItems to BMHomeSectionListView
  • Replaced items → sortedItems in both ForEach loops to reflect new ordering
  • Reused existing distanceToUser for distance calculation instead of adding duplicate logic

Testing steps

  • Verified on simulator: distances display correctly under each list item, items appear closest → farthest from the user
  • No unintended impact on tapping, navigation, or visual styling

Resolves #436

@ananyadua27 ananyadua27 changed the title feature (home): sort section list items by distance to user Feature (Home): Sort Section List Items by Distance to User Nov 3, 2025
Comment on lines +19 to +21
// Sort items by proximity to user (ascending)
// utilizes the CLLocation.distanceFromUser() helper
// items without lat/lon sent to the bottom
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment

Comment on lines +61 to +62
// items -> sortedItems in both forEach calls
// displays all items as tappable rows
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment

Comment on lines -58 to +72
}) {
} label: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

for buttons, we typically do something like this:

Button (action: {
}) {

}

What you have is valid, but since label is the last parameter and it is a closure, we can use the trailing closure syntax: https://www.hackingwithswift.com/sixty/6/5/trailing-closure-syntax


BMHomeSectionListView(sectionType: .dining, items: diningHalls, mapViewController: MapViewController())
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

remove newline

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.

Sort BMHomeSectionListView Items By User Location

3 participants