Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions lib/screens/map_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class _MaizeBusCoreState extends State<MaizeBusCore> {

void onBusClicked(Bus b) {
centerOnBus(b);
baseRoutesLayer.setFocusedRoute(b.routeId);
_showBusSheet(b.id);
}

Expand Down Expand Up @@ -1454,17 +1455,26 @@ class _MaizeBusCoreState extends State<MaizeBusCore> {
// 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,
// isScrollControlled: true,
// 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,
Expand All @@ -1482,7 +1492,7 @@ class _MaizeBusCoreState extends State<MaizeBusCore> {
showMaizebusOKDialog(
contextIn: context,
title: "Error",
content: "Couldn't load stop.",
content: "Couldn't load bus.",
);
}
},
Expand All @@ -1491,6 +1501,9 @@ class _MaizeBusCoreState extends State<MaizeBusCore> {
),
),
);
_bottomSheetController?.closed.then((_) {
baseRoutesLayer.setFocusedRoute(null);
});
}

void _showFavoritesSheet() {
Expand Down Expand Up @@ -1543,6 +1556,11 @@ class _MaizeBusCoreState extends State<MaizeBusCore> {
// 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);
},
Expand Down
6 changes: 5 additions & 1 deletion lib/screens/onboarding_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class _OnboardingDeciderState extends State<OnboardingDecider> {
}

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();
Expand Down
20 changes: 12 additions & 8 deletions lib/services/map_layers/base_routes_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class BaseRoutesLayer extends CompositeMapLayer {

Set<String> favoriteStops = {};
Set<String> selectedRoutes = {};
String? focusedRoute = null;

BitmapDescriptor _stopIcon = BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueAzure,
Expand Down Expand Up @@ -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

Expand All @@ -222,7 +224,6 @@ class BaseRoutesLayer extends CompositeMapLayer {
}

Future<void> reloadPreprocessedMarkersSegment(int markersToReload) async {

int stopIndex = stopsToReloadCursor + markersToReload;

for (; stopsToReloadCursor < math.min(stopsToReload.length, stopIndex); stopsToReloadCursor++) {
Expand All @@ -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(
Expand All @@ -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: () {
Expand Down Expand Up @@ -315,6 +312,12 @@ class BaseRoutesLayer extends CompositeMapLayer {

}

void setFocusedRoute(String? routeId) {
focusedRoute = routeId;
reloadPolylines();
reloadAllMarkers();
}

void reloadPolylines() {
polylinesCache.clear();

Expand All @@ -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
);
}
}
Expand Down
Loading