Skip to content
Snippets Groups Projects
Commit e13629cc authored by alper-savas's avatar alper-savas
Browse files

Add date range info

parent 79ff9e29
Branches
No related tags found
1 merge request!6final project merge into main
...@@ -74,6 +74,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -74,6 +74,7 @@ class _MyHomePageState extends State<MyHomePage> {
// Set<Polyline> _polyline = {}; // Set<Polyline> _polyline = {};
String _totalDuration = ''; String _totalDuration = '';
String _totalDistance = ''; String _totalDistance = '';
String _totalDaysFormatted = '';
// Variables for calendar and weather filter // Variables for calendar and weather filter
DateTimeRange _dateRange = DateTimeRange( DateTimeRange _dateRange = DateTimeRange(
...@@ -230,12 +231,12 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -230,12 +231,12 @@ class _MyHomePageState extends State<MyHomePage> {
var coordinates = _data['route']; var coordinates = _data['route'];
int duration = _data['duration']; int duration = _data['duration'];
int distance = _data['distance']; int distance = _data['distance'];
//TODO include day
int daysAfterToday = _data['days_after_today']; int daysAfterToday = _data['days_after_today'];
// Format duration and distance // Format duration, distance and day
_totalDuration = getTotalDuration(duration); _totalDuration = getTotalDuration(duration);
_totalDistance = getTotalDistance(distance); _totalDistance = getTotalDistance(distance);
_totalDaysFormatted = getTotalDays(daysAfterToday);
// Draw polyline // Draw polyline
drawPolyline(coordinates); drawPolyline(coordinates);
...@@ -255,6 +256,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -255,6 +256,7 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() { setState(() {
_totalDuration; _totalDuration;
_totalDistance; _totalDistance;
_totalDaysFormatted;
_polyline; _polyline;
}); });
} catch (e) { } catch (e) {
...@@ -285,6 +287,13 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -285,6 +287,13 @@ class _MyHomePageState extends State<MyHomePage> {
return '$distanceInKm km'; return '$distanceInKm km';
} }
String getTotalDays(int daysAfterToday) {
String currentDate = convertDateFormat(DateTime.now());
String lastDate =
convertDateFormat(DateTime.now().add(Duration(days: daysAfterToday)));
return "$currentDate - $lastDate";
}
List<String> getForbidden() { List<String> getForbidden() {
List<String> forbidden = []; List<String> forbidden = [];
for (var option in _selectedOptions) { for (var option in _selectedOptions) {
...@@ -996,8 +1005,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -996,8 +1005,8 @@ class _MyHomePageState extends State<MyHomePage> {
color: Color.fromRGBO(53, 56, 63, 1), color: Color.fromRGBO(53, 56, 63, 1),
borderRadius: borderRadius:
BorderRadius.all(Radius.circular(25))), BorderRadius.all(Radius.circular(25))),
padding: padding: EdgeInsets.only(
EdgeInsets.only(bottom: 15, top: 15, left: 20), bottom: 15, top: 15, left: 20),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
...@@ -1047,7 +1056,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1047,7 +1056,8 @@ class _MyHomePageState extends State<MyHomePage> {
padding: EdgeInsets.only(right: 8), padding: EdgeInsets.only(right: 8),
child: Icon( child: Icon(
WeatherIcons.cloudy, WeatherIcons.cloudy,
color: Theme.of(context).accentColor, color:
Theme.of(context).accentColor,
size: 18, size: 18,
), ),
), ),
...@@ -1057,8 +1067,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1057,8 +1067,8 @@ class _MyHomePageState extends State<MyHomePage> {
letterSpacing: 0.6, letterSpacing: 0.6,
fontSize: 21, fontSize: 21,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: color: Theme.of(context)
Theme.of(context).accentColor), .accentColor),
), ),
], ],
), ),
...@@ -1101,7 +1111,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1101,7 +1111,8 @@ class _MyHomePageState extends State<MyHomePage> {
shape: MaterialStateProperty.all< shape: MaterialStateProperty.all<
RoundedRectangleBorder>( RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), borderRadius:
BorderRadius.circular(20),
), ),
), ),
), ),
...@@ -1129,7 +1140,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1129,7 +1140,8 @@ class _MyHomePageState extends State<MyHomePage> {
EdgeInsets.only(right: 5, top: 2), EdgeInsets.only(right: 5, top: 2),
child: Icon( child: Icon(
Icons.access_time_filled_outlined, Icons.access_time_filled_outlined,
color: Theme.of(context).accentColor, color:
Theme.of(context).accentColor,
size: 20, size: 20,
), ),
), ),
...@@ -1139,16 +1151,16 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1139,16 +1151,16 @@ class _MyHomePageState extends State<MyHomePage> {
letterSpacing: 0.6, letterSpacing: 0.6,
fontSize: 21, fontSize: 21,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: color: Theme.of(context)
Theme.of(context).accentColor), .accentColor),
), ),
Text( Text(
_totalDuration, _totalDuration,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: color: Theme.of(context)
Theme.of(context).accentColor), .accentColor),
), ),
], ],
), ),
...@@ -1164,7 +1176,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1164,7 +1176,8 @@ class _MyHomePageState extends State<MyHomePage> {
EdgeInsets.only(right: 5, top: 2), EdgeInsets.only(right: 5, top: 2),
child: Icon( child: Icon(
Icons.directions_car_rounded, Icons.directions_car_rounded,
color: Theme.of(context).accentColor, color:
Theme.of(context).accentColor,
size: 20, size: 20,
), ),
), ),
...@@ -1174,19 +1187,55 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1174,19 +1187,55 @@ class _MyHomePageState extends State<MyHomePage> {
letterSpacing: 0.6, letterSpacing: 0.6,
fontSize: 21, fontSize: 21,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: color: Theme.of(context)
Theme.of(context).accentColor), .accentColor),
), ),
Text( Text(
_totalDistance, _totalDistance,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: Theme.of(context)
.accentColor),
),
],
),
SizedBox(
height: 15,
),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
padding:
EdgeInsets.only(right: 5, top: 2),
child: Icon(
Icons.date_range,
color: color:
Theme.of(context).accentColor), Theme.of(context).accentColor,
size: 20,
),
),
Text(
'Date Range: ',
style: TextStyle(
letterSpacing: 0.6,
fontSize: 21,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.accentColor),
),
Text(
_totalDaysFormatted,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
color: Theme.of(context)
.accentColor),
), ),
], ],
) ),
], ],
), ),
), ),
...@@ -1222,8 +1271,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1222,8 +1271,8 @@ class _MyHomePageState extends State<MyHomePage> {
letterSpacing: 0.6, letterSpacing: 0.6,
fontSize: 21, fontSize: 21,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: color: Theme.of(context)
Theme.of(context).accentColor), .accentColor),
), ),
), ),
]), ]),
...@@ -1242,8 +1291,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -1242,8 +1291,8 @@ class _MyHomePageState extends State<MyHomePage> {
right: 6, left: 12), right: 6, left: 12),
child: Icon( child: Icon(
Icons.check_rounded, Icons.check_rounded,
color: color: Theme.of(context)
Theme.of(context).accentColor, .accentColor,
size: 20, size: 20,
), ),
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment