Skip to content

Commit

Permalink
Fix map dark and light mode style
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushik committed Jun 17, 2024
1 parent d59ff7e commit 7f18066
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/lib/ui/flow/home/map/map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class _MapScreenState extends ConsumerState<MapView> {
notifier = ref.watch(mapViewStateProvider.notifier);
final state = ref.watch(mapViewStateProvider);

_updateMapStyle(context.brightness == Brightness.dark);
return Stack(
children: [
Center(
Expand Down Expand Up @@ -101,6 +102,17 @@ class _MapScreenState extends ConsumerState<MapView> {
_controller.complete(controller);
}

void _updateMapStyle(bool isDarkMode) async {
final controller = await _controller.future;
if (isDarkMode) {
final style =
await rootBundle.loadString('assets/map/map_theme_night.json');
controller.setMapStyle(style);
} else {
controller.setMapStyle(null);
}
}

void _observeMapCameraPosition() {
ref.listen(mapViewStateProvider.select((state) => state.defaultPosition),
(previous, next) async {
Expand Down

0 comments on commit 7f18066

Please sign in to comment.