Skip to content

Commit

Permalink
improve map and metric style (#54)
Browse files Browse the repository at this point in the history
* improve map and metric style

* edit screenshots
  • Loading branch information
BenjaminCanape authored Mar 13, 2024
1 parent 616f642 commit 701bb17
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 67 deletions.
Binary file modified banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class MyApp extends HookConsumerWidget {
selectionHandleColor: ColorUtils.main,
),
primaryColor: ColorUtils.main,
splashColor: ColorUtils.blueGreyDarker,
bottomSheetTheme:
BottomSheetThemeData(backgroundColor: ColorUtils.transparent),
),
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/common/core/utils/color_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ColorUtils {
static Color greyLight = Colors.grey.shade300;
static Color blueGrey = Colors.blueGrey;
static Color blueGreyDarker = Colors.blueGrey.shade900;
static Color backgroundLight = Colors.white;

/// List of colors used for generating color tuples.
static List<Color> colorList = [
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/common/core/utils/image_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ImageUtils {
try {
RenderRepaintBoundary boundary = boundaryKey.currentContext!
.findRenderObject() as RenderRepaintBoundary;

ui.Image image = await boundary.toImage();
ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
Expand Down
25 changes: 16 additions & 9 deletions lib/presentation/common/location/widgets/current_location_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class CurrentLocationMap extends HookConsumerWidget {
height: 80,
point: LatLng(currentLatitude, currentLongitude),
child: Icon(
Icons.run_circle_sharp,
size: 30,
color: ColorUtils.red,
Icons.circle,
size: 20,
color: ColorUtils.errorDarker,
),
),
];
Expand Down Expand Up @@ -75,12 +75,19 @@ class CurrentLocationMap extends HookConsumerWidget {

return futureProvider.when(data: (total) {
return Expanded(
child: LocationMap(
points: points,
markers: markers,
currentPosition: LatLng(currentLatitude, currentLongitude),
mapController: provider.mapController ?? MapController(),
));
child: SizedBox(
height: 500,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(150),
topRight: Radius.circular(150),
),
child: LocationMap(
points: points,
markers: markers,
currentPosition: LatLng(currentLatitude, currentLongitude),
mapController: provider.mapController ?? MapController(),
))));
}, loading: () {
return Expanded(child: Center(child: UIUtils.loader));
}, error: (error, stackTrace) {
Expand Down
47 changes: 22 additions & 25 deletions lib/presentation/common/location/widgets/location_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,29 @@ class LocationMap extends HookConsumerWidget {
final zoomLevel = MapUtils.getZoomLevel(points, center);

return points.isNotEmpty || currentPosition != null
? SizedBox(
height: 500,
child: FlutterMap(
key: ValueKey(MediaQuery.of(context).orientation),
mapController: mapController,
options: MapOptions(
initialCenter: points.isNotEmpty
? center
: currentPosition ?? const LatLng(0, 0),
initialZoom: zoomLevel,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
),
PolylineLayer(
polylines: [
Polyline(
points: points,
strokeWidth: 4,
color: ColorUtils.blueGrey),
],
),
MarkerLayer(markers: markers),
],
? FlutterMap(
key: ValueKey(MediaQuery.of(context).orientation),
mapController: mapController,
options: MapOptions(
initialCenter: points.isNotEmpty
? center
: currentPosition ?? const LatLng(0, 0),
initialZoom: zoomLevel,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
),
PolylineLayer(
polylines: [
Polyline(
points: points,
strokeWidth: 4,
color: ColorUtils.blueGrey),
],
),
MarkerLayer(markers: markers),
],
)
: Center(child: UIUtils.loader);
}
Expand Down
44 changes: 29 additions & 15 deletions lib/presentation/common/metrics/widgets/metrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Metrics extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final state = ref.watch(metricsViewModelProvider);
const textStyle = TextStyle(fontSize: 30.0);
const textStyle = TextStyle(fontSize: 26.0, fontWeight: FontWeight.bold);

double speedToDisplay = state.globalSpeed;
double distanceToDisplay = state.distance;
Expand All @@ -28,22 +28,36 @@ class Metrics extends HookConsumerWidget {

return Center(
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Icon(Icons.location_on),
const SizedBox(width: 8),
Text(
'${distanceToDisplay.toStringAsFixed(2)} km',
style: textStyle,
),
const SizedBox(width: 40),
const Icon(Icons.speed),
const SizedBox(width: 8),
Text(
'${speedToDisplay.toStringAsFixed(2)} km/h',
style: textStyle,
),
Row(children: [
const Icon(
Icons.location_on,
size: 45,
),
const SizedBox(width: 8),
Column(children: [
Text(
distanceToDisplay.toStringAsFixed(2),
style: textStyle,
),
const Text('km'),
])
]),
Row(children: [
Column(mainAxisAlignment: MainAxisAlignment.start, children: [
Text(
speedToDisplay.toStringAsFixed(2),
style: textStyle,
),
const Text('km/h'),
]),
const SizedBox(width: 8),
const Icon(
Icons.speed,
size: 45,
),
])
],
),
);
Expand Down
5 changes: 3 additions & 2 deletions lib/presentation/common/timer/widgets/timer_start.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class TimerStart extends HookConsumerWidget {

return FloatingActionButton(
heroTag: 'start_button',
backgroundColor:
timerViewModel.hasTimerStarted() ? ColorUtils.red : ColorUtils.main,
backgroundColor: timerViewModel.hasTimerStarted()
? ColorUtils.errorDarker
: ColorUtils.main,
elevation: 4.0,
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
Expand Down
1 change: 0 additions & 1 deletion lib/presentation/home/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class HomeScreen extends HookConsumerWidget {
padding: const EdgeInsets.all(16),
selectedIndex: currentIndex,
onTabChange: (value) {
//locationViewModel.cancelLocationStream();
homeViewModel.setCurrentIndex(value);
},
gap: 8,
Expand Down
24 changes: 16 additions & 8 deletions lib/presentation/my_activities/widgets/details_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,22 @@ class DetailsTab extends HookConsumerWidget {
speed: displayedActivity.speed,
),
Expanded(
child: RepaintBoundary(
key: state.boundaryKey,
child: LocationMap(
points: points,
markers: markers,
mapController: MapController(),
),
),
child: SizedBox(
height: 500,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(150),
topRight: Radius.circular(150),
),
child: RepaintBoundary(
key: state.boundaryKey,
child: LocationMap(
points: points,
markers: markers,
mapController: MapController(),
),
),
)),
)
],
),
Expand Down
23 changes: 16 additions & 7 deletions lib/presentation/new_activity/screens/sum_up_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,24 @@ class SumUpScreen extends HookConsumerWidget {
const Metrics(),
const SizedBox(height: 10),
Expanded(
child: RepaintBoundary(
key: state.boundaryKey,
child: LocationMap(
points: points,
markers: markers,
mapController: MapController(),
child: SizedBox(
height: 500,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(150),
topRight: Radius.circular(150),
),
child: RepaintBoundary(
key: state.boundaryKey,
child: LocationMap(
points: points,
markers: markers,
mapController: MapController(),
),
),
),
),
),
)
],
),
),
Expand Down
Binary file modified screenshots/activity_list/activity_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/new_activity/current_activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/new_activity/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 701bb17

Please sign in to comment.