From a993f206f334110c05eefdc34cd116483775779a Mon Sep 17 00:00:00 2001 From: iswheeler <22535264+iswheeler@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:14:35 -0400 Subject: [PATCH] Finished route focusing --- lib/screens/map_screen.dart | 24 ++++++++++++++++--- lib/screens/onboarding_screen.dart | 6 ++++- .../map_layers/base_routes_layer.dart | 20 +++++++++------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/screens/map_screen.dart b/lib/screens/map_screen.dart index b7a8b1e..e4f9e1f 100644 --- a/lib/screens/map_screen.dart +++ b/lib/screens/map_screen.dart @@ -276,6 +276,7 @@ class _MaizeBusCoreState extends State { void onBusClicked(Bus b) { centerOnBus(b); + baseRoutesLayer.setFocusedRoute(b.routeId); _showBusSheet(b.id); } @@ -1454,6 +1455,8 @@ class _MaizeBusCoreState extends State { // TODO: Fix the back button (maybe bring back the sheet stack? That might be messy now that our bus sheet is different)--it should take the user back to the previous camera position/zoom on the map // + + // showModalBottomSheet( _bottomSheetController = showBottomSheet( context: context, @@ -1461,10 +1464,17 @@ class _MaizeBusCoreState extends State { // isDismissible: true, backgroundColor: Colors.transparent, builder: (context) => Container( + height: MediaQuery.sizeOf(context).height / 2, + + // decoration: BoxDecoration( + // color: Colors.red + // ), child: DraggableScrollableSheet( snap: true, - snapSizes: [0.5, 0.9], - initialChildSize: 0.5, + snapSizes: [1.0], + initialChildSize: 1.0, + maxChildSize: 1.0, + // initialChildSize: 0.85, // maxChildSize: 0.85, // snap: true, @@ -1482,7 +1492,7 @@ class _MaizeBusCoreState extends State { showMaizebusOKDialog( contextIn: context, title: "Error", - content: "Couldn't load stop.", + content: "Couldn't load bus.", ); } }, @@ -1491,6 +1501,9 @@ class _MaizeBusCoreState extends State { ), ), ); + _bottomSheetController?.closed.then((_) { + baseRoutesLayer.setFocusedRoute(null); + }); } void _showFavoritesSheet() { @@ -1543,6 +1556,11 @@ class _MaizeBusCoreState extends State { // When someone clicks "See all stops for this bus" this callback runs Navigator.pop(context); // Close the current modal centerOnBusID(busProvider, busId); + Bus? bus = null; + try { + bus = busProvider.buses.where((b) => b.id == busId).toList()[0]; + } catch (e) {} + baseRoutesLayer.setFocusedRoute(bus?.routeId); _showBusSheet(busId); }, diff --git a/lib/screens/onboarding_screen.dart b/lib/screens/onboarding_screen.dart index b5862f5..4f1992e 100644 --- a/lib/screens/onboarding_screen.dart +++ b/lib/screens/onboarding_screen.dart @@ -44,7 +44,11 @@ class _OnboardingDeciderState extends State { } if (_accepted) { - return const Scaffold(body: MaizeBusCore(), resizeToAvoidBottomInset: false); + return Scaffold( + body: const MaizeBusCore(), + resizeToAvoidBottomInset: false, + bottomSheetScrimBuilder: (context, animation) => const SizedBox.shrink(), + ); } return const OnboardingScreen(); diff --git a/lib/services/map_layers/base_routes_layer.dart b/lib/services/map_layers/base_routes_layer.dart index a9432f7..fc84ba8 100644 --- a/lib/services/map_layers/base_routes_layer.dart +++ b/lib/services/map_layers/base_routes_layer.dart @@ -47,6 +47,7 @@ class BaseRoutesLayer extends CompositeMapLayer { Set favoriteStops = {}; Set selectedRoutes = {}; + String? focusedRoute = null; BitmapDescriptor _stopIcon = BitmapDescriptor.defaultMarkerWithHue( BitmapDescriptor.hueAzure, @@ -195,7 +196,8 @@ class BaseRoutesLayer extends CompositeMapLayer { for (final r in routes) { // used to be routesCache if (!selectedRoutes.contains(r.routeId)) continue; // Skip deselected routes - + // If a route is focused, don't show stops for other routes + if (focusedRoute != null && r.routeId != focusedRoute) continue; // TODO: VVV Save these two variables in some data structure somewhere, or maybe alongside the Stop in the stopsToReload @@ -222,7 +224,6 @@ class BaseRoutesLayer extends CompositeMapLayer { } Future reloadPreprocessedMarkersSegment(int markersToReload) async { - int stopIndex = stopsToReloadCursor + markersToReload; for (; stopsToReloadCursor < math.min(stopsToReload.length, stopIndex); stopsToReloadCursor++) { @@ -241,7 +242,6 @@ class BaseRoutesLayer extends CompositeMapLayer { position: entry.stop.location, flat: true, icon: - // TODO: Reimplement this isRide/isNotRide/isFavorite/etc logic (displayFancyIcons) ? ( await MapImageService.getFancyStopIcon( @@ -259,9 +259,6 @@ class BaseRoutesLayer extends CompositeMapLayer { entry.stop.isRide, entry.stop.rotation ) - // favoriteStops.contains(entry.stop.id) // Used to be isFavorite - // ? (entry.stop.isRide ? _favRideStopIcon : _favStopIcon) - // : (entry.stop.isRide ? _rideStopIcon : _stopIcon) ), consumeTapEvents: true, onTap: () { @@ -315,6 +312,12 @@ class BaseRoutesLayer extends CompositeMapLayer { } + void setFocusedRoute(String? routeId) { + focusedRoute = routeId; + reloadPolylines(); + reloadAllMarkers(); + } + void reloadPolylines() { polylinesCache.clear(); @@ -334,8 +337,9 @@ class BaseRoutesLayer extends CompositeMapLayer { jointType: JointType.round, polylineId: PolylineId(routeKey), points: r.points, - color: routeColor, - width: 4, + color: (focusedRoute == null || focusedRoute == r.routeId) ? routeColor : Colors.grey, + width: (focusedRoute == r.routeId) ? 6 : 4, + zIndex: (focusedRoute == r.routeId) ? 999999 : 0 // Make sure focused routes are always on top ); } }