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

Add date range info

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