Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ class _SwipeableAnalyticsCardState extends State<SwipeableAnalyticsCard>
return getAppAqiCategoryColor(measurement.aqiCategory ?? '');
}

Widget _chevron(BuildContext context) {
return SvgPicture.asset(
'assets/icons/chevron-right.svg',
width: 20,
height: 20,
colorFilter: ColorFilter.mode(
AppTextColors.modalCloseIcon(context),
BlendMode.srcIn,
),
);
}

void _handleRemove() {
final String siteId = widget.measurement.siteId ?? '';

Expand All @@ -234,6 +246,8 @@ class _SwipeableAnalyticsCardState extends State<SwipeableAnalyticsCard>

@override
Widget build(BuildContext context) {
final locationColor = AppTextColors.muted(context);

return Stack(
clipBehavior: Clip.none,
children: [
Expand Down Expand Up @@ -327,7 +341,7 @@ class _SwipeableAnalyticsCardState extends State<SwipeableAnalyticsCard>
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
Expand Down Expand Up @@ -356,18 +370,18 @@ class _SwipeableAnalyticsCardState extends State<SwipeableAnalyticsCard>
'assets/images/shared/location_pin.svg',
width: 14,
height: 14,
colorFilter: ColorFilter.mode(
locationColor,
BlendMode.srcIn,
),
),
const SizedBox(width: 4),
Expanded(
child: Text(
_getLocationDescription(widget.measurement),
style: TextStyle(
fontSize: 14,
color: Theme.of(context)
.textTheme
.bodyMedium
?.color
?.withValues(alpha: 0.7),
color: locationColor,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand All @@ -378,6 +392,10 @@ class _SwipeableAnalyticsCardState extends State<SwipeableAnalyticsCard>
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8, top: 2),
child: _chevron(context),
),
],
),
],
Expand Down
22 changes: 21 additions & 1 deletion src/mobile/lib/src/app/dashboard/widgets/analytics_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ class AnalyticsCard extends StatelessWidget with UiLoggy {
return getAppAqiCategoryColor(measurement.aqiCategory ?? '');
}

Widget _chevron(BuildContext context) {
return SvgPicture.asset(
'assets/icons/chevron-right.svg',
width: 20,
height: 20,
colorFilter: ColorFilter.mode(
AppTextColors.modalCloseIcon(context),
BlendMode.srcIn,
),
);
}

@override
Widget build(BuildContext context) {
final locationColor = AppTextColors.muted(context);
Expand All @@ -75,7 +87,7 @@ class AnalyticsCard extends StatelessWidget with UiLoggy {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
Expand Down Expand Up @@ -104,6 +116,10 @@ class AnalyticsCard extends StatelessWidget with UiLoggy {
'assets/images/shared/location_pin.svg',
width: 14,
height: 14,
colorFilter: ColorFilter.mode(
locationColor,
BlendMode.srcIn,
),
),
SizedBox(width: 4),
Expanded(
Expand All @@ -122,6 +138,10 @@ class AnalyticsCard extends StatelessWidget with UiLoggy {
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8, top: 2),
child: _chevron(context),
),
],
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,22 @@ class NearbyMeasurementCard extends StatelessWidget with UiLoggy {
return getAppAqiCategoryColor(measurement.aqiCategory ?? '');
}

Widget _chevron(BuildContext context) {
return SvgPicture.asset(
'assets/icons/chevron-right.svg',
width: 20,
height: 20,
colorFilter: ColorFilter.mode(
AppTextColors.modalCloseIcon(context),
BlendMode.srcIn,
),
);
}

@override
Widget build(BuildContext context) {
final locationColor = AppTextColors.muted(context);

return InkWell(
onTap: () => _openForecast(context),
child: Container(
Expand All @@ -75,7 +89,7 @@ class NearbyMeasurementCard extends StatelessWidget with UiLoggy {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
Expand Down Expand Up @@ -104,18 +118,18 @@ class NearbyMeasurementCard extends StatelessWidget with UiLoggy {
'assets/images/shared/location_pin.svg',
width: 14,
height: 14,
colorFilter: ColorFilter.mode(
locationColor,
BlendMode.srcIn,
),
),
SizedBox(width: 4),
Expanded(
child: Text(
_getLocationDescription(measurement),
style: TextStyle(
fontSize: 14,
color: Theme.of(context)
.textTheme
.bodyMedium
?.color
?.withValues(alpha: 0.7),
color: locationColor,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand All @@ -126,6 +140,10 @@ class NearbyMeasurementCard extends StatelessWidget with UiLoggy {
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8, top: 2),
child: _chevron(context),
),
],
),
],
Expand Down
1 change: 0 additions & 1 deletion src/mobile/lib/src/app/dashboard/widgets/nearby_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ class _NearbyViewState extends State<NearbyView> with UiLoggy {
final entry = _nearbyMeasurementsWithDistance[index];
return NearbyMeasurementCard(
measurement: entry.key,
// distance: entry.value,
);
},
),
Expand Down
91 changes: 80 additions & 11 deletions src/mobile/lib/src/app/map/pages/map_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:airqo/src/app/map/controllers/map_camera_controller.dart';
import 'package:airqo/src/app/map/utils/map_marker_builder.dart';
import 'package:airqo/src/app/map/widgets/map_aq_card_layer.dart';
import 'package:airqo/src/app/map/widgets/map_controls.dart';
import 'package:airqo/src/app/map/widgets/map_controls_tour.dart';
import 'package:airqo/src/app/map/widgets/map_error_view.dart';
import 'package:airqo/src/app/map/widgets/map_loading_view.dart';
import 'package:airqo/src/app/map/widgets/map_overlay_controls.dart';
Expand All @@ -20,6 +21,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:geolocator/geolocator.dart';
import 'package:loggy/loggy.dart';
import 'package:shared_preferences/shared_preferences.dart';

class MapScreen extends StatefulWidget {
const MapScreen({super.key});
Expand Down Expand Up @@ -53,6 +55,13 @@ class _MapScreenState extends State<MapScreen>
String? _mapStyleJson;
int _markerBuildSeq = 0;

static const String _tourSeenKey = 'map_controls_tour_seen';
final GlobalKey _layersControlKey = GlobalKey();
final GlobalKey _locateControlKey = GlobalKey();
final GlobalKey _zoomControlKey = GlobalKey();
bool _showControlsTour = false;
bool _locationResolved = false;

static const LatLng _center = LatLng(0.347596, 32.582520);
static const double _sheetPeekSize = 0.13;
static const double _sheetMidSize = 0.44;
Expand Down Expand Up @@ -122,18 +131,19 @@ class _MapScreenState extends State<MapScreen>

void _showForecastModal(Measurement measurement) {
_hideTextInputOverlay();
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (!mounted) return;
_hideTextInputOverlay();

Future<void>.delayed(const Duration(milliseconds: 48), () {
if (!mounted) return;
_hideTextInputOverlay();
ForecastOverviewPage.showForMeasurement(
context,
measurement: measurement,
);
});
await Future<void>.delayed(const Duration(milliseconds: 48));
if (!mounted) return;
_hideTextInputOverlay();
await ForecastOverviewPage.showForMeasurement(
context,
measurement: measurement,
);
if (!mounted) return;
_hideTextInputOverlay();
});
}

Expand Down Expand Up @@ -202,7 +212,56 @@ class _MapScreenState extends State<MapScreen>
_cameraController.snapToPosition(userPosition!);
} catch (e) {
loggy.error('Failed to get user location: $e');
} finally {
if (mounted) {
setState(() => _locationResolved = true);
_maybeShowControlsTour();
}
}
}

Future<void> _dismissControlsTour() async {
setState(() => _showControlsTour = false);
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_tourSeenKey, true);
}

void _maybeShowControlsTour() {
if (_showControlsTour || !_locationResolved) return;
SharedPreferences.getInstance().then((prefs) {
final seen = prefs.getBool(_tourSeenKey) ?? false;
if (!seen && mounted) setState(() => _showControlsTour = true);
});
}

List<MapControlTourStep> _controlsTourSteps() {
final steps = <MapControlTourStep>[
MapControlTourStep(
targetKey: _layersControlKey,
icon: Icons.layers_outlined,
title: 'Map style',
subtitle: 'Switch between standard, satellite, and other map views.',
),
];
if (userPosition != null) {
steps.add(
MapControlTourStep(
targetKey: _locateControlKey,
icon: Icons.my_location,
title: 'Your location',
subtitle: 'Center the map on where you are right now.',
),
);
}
steps.add(
MapControlTourStep(
targetKey: _zoomControlKey,
icon: Icons.add,
title: 'Zoom in and out',
subtitle: 'Use + and − to zoom the map closer or further away.',
),
);
return steps;
}

void _updateNearbyMeasurements() {
Expand Down Expand Up @@ -413,6 +472,9 @@ class _MapScreenState extends State<MapScreen>
Positioned.fill(
child: MapOverlayControls(
isDark: isDark,
layersKey: _layersControlKey,
locateKey: _locateControlKey,
zoomKey: _zoomControlKey,
onLayersTap: _openMapStylePicker,
onLocateTap: userPosition != null
? () => _cameraController.snapToPosition(userPosition!)
Expand All @@ -423,8 +485,10 @@ class _MapScreenState extends State<MapScreen>
),
Positioned(
top: 50,
left: 10,
child: MapAqLegend(isDark: isDark),
left: mapControlSideInset,
child: MapControlSideSlot(
child: MapAqLegend(isDark: isDark),
),
),
DraggableScrollableSheet(
controller: _sheetController,
Expand Down Expand Up @@ -455,6 +519,11 @@ class _MapScreenState extends State<MapScreen>
onViewForecast: () =>
_showForecastModal(_selectedCardMeasurement!),
),
if (_showControlsTour)
MapControlsTour(
steps: _controlsTourSteps(),
onDismiss: _dismissControlsTour,
),
],
);
}
Expand Down
Loading
Loading