feat(wip): implement trip persistence through a local repository. Include loaded trips in the start page UI
This commit is contained in:
99
frontend/lib/presentation/widgets/trip_marker_graphic.dart
Normal file
99
frontend/lib/presentation/widgets/trip_marker_graphic.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:anyway/core/constants.dart';
|
||||
import 'package:anyway/domain/entities/landmark.dart';
|
||||
import 'package:anyway/domain/entities/landmark_type.dart';
|
||||
|
||||
class TripMarkerGraphic extends StatelessWidget {
|
||||
const TripMarkerGraphic({
|
||||
super.key,
|
||||
required this.landmark,
|
||||
required this.position,
|
||||
this.compact = false,
|
||||
});
|
||||
|
||||
final Landmark landmark;
|
||||
final int position;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final gradient = landmark.isVisited
|
||||
? const LinearGradient(colors: [Colors.grey, Colors.white])
|
||||
: APP_GRADIENT;
|
||||
final showPosition = landmark.type.type != LandmarkTypeEnum.start &&
|
||||
landmark.type.type != LandmarkTypeEnum.finish;
|
||||
final markerDiameter = compact ? 68.0 : 84.0;
|
||||
final borderWidth = compact ? 3.0 : 4.5;
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: SizedBox(
|
||||
width: markerDiameter,
|
||||
height: markerDiameter,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: gradient,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.black87, width: borderWidth),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
blurRadius: 6,
|
||||
color: Colors.black26,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.all(compact ? 8 : 10),
|
||||
child: Icon(
|
||||
_iconForType(landmark.type.type),
|
||||
color: Colors.black87,
|
||||
size: compact ? 30 : 38,
|
||||
),
|
||||
),
|
||||
if (showPosition)
|
||||
Positioned(
|
||||
top: -2,
|
||||
right: -2,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(compact ? 4 : 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.black26),
|
||||
),
|
||||
child: Text(
|
||||
position.toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: compact ? 12 : 14,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// TODO - should this be a landmark property?
|
||||
IconData _iconForType(LandmarkTypeEnum type) {
|
||||
switch (type) {
|
||||
case LandmarkTypeEnum.start:
|
||||
return Icons.flag;
|
||||
case LandmarkTypeEnum.finish:
|
||||
return Icons.flag_circle;
|
||||
case LandmarkTypeEnum.shopping:
|
||||
return Icons.shopping_bag;
|
||||
case LandmarkTypeEnum.nature:
|
||||
return Icons.park;
|
||||
case LandmarkTypeEnum.sightseeing:
|
||||
return Icons.place;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user