71 lines
1.8 KiB
Dart
71 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:anyway/structs/landmark.dart';
|
|
import 'package:anyway/modules/map_chooser.dart';
|
|
|
|
|
|
class StepBetweenLandmarks extends StatefulWidget {
|
|
final Landmark current;
|
|
final Landmark next;
|
|
|
|
const StepBetweenLandmarks({
|
|
super.key,
|
|
required this.current,
|
|
required this.next
|
|
});
|
|
|
|
@override
|
|
State<StepBetweenLandmarks> createState() => _StepBetweenLandmarksState();
|
|
}
|
|
|
|
class _StepBetweenLandmarksState extends State<StepBetweenLandmarks> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
int? time = widget.current.tripTime?.inMinutes;
|
|
|
|
// since landmarks might have been marked as visited, the next landmark might not be the immediate next in the list
|
|
// => the precomputed trip time is not valid anymore
|
|
if (widget.current.next != widget.next) {
|
|
time = null;
|
|
}
|
|
|
|
// round 0 travel time to 1 minute
|
|
if (time != null && time < 1) {
|
|
time = 1;
|
|
}
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.all(10),
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
left: BorderSide(width: 3.0, color: Colors.black),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
const Icon(Icons.directions_walk),
|
|
Text(
|
|
time == null ? "" : "About $time min",
|
|
style: const TextStyle(fontSize: 10)
|
|
),
|
|
],
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
ElevatedButton.icon(
|
|
onPressed: () async {
|
|
showMapChooser(context, widget.current, widget.next);
|
|
},
|
|
icon: const Icon(Icons.directions),
|
|
label: const Text("Directions"),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|