added start and end date
This commit is contained in:
@@ -1,31 +1,60 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ContentListTile extends StatelessWidget {
|
class ContentListTile extends StatelessWidget {
|
||||||
const ContentListTile({
|
const ContentListTile(
|
||||||
super.key,
|
{super.key,
|
||||||
this.name,
|
this.name,
|
||||||
this.location,
|
this.location,
|
||||||
this.title,
|
this.title,
|
||||||
this.description,
|
this.description,
|
||||||
});
|
this.startDate,
|
||||||
|
this.endDate});
|
||||||
|
|
||||||
final String? name;
|
final String? name;
|
||||||
final String? location;
|
final String? location;
|
||||||
final String? title;
|
final String? title;
|
||||||
final String? description;
|
final String? description;
|
||||||
|
final String? startDate;
|
||||||
|
final String? endDate;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
contentPadding: const EdgeInsets.all(0),
|
contentPadding: const EdgeInsets.all(0),
|
||||||
title: Row(
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (name != null) Text(name!),
|
if (name != null) Text(name!),
|
||||||
if (location != null) Text(', $location'),
|
if (location != null) Text(', $location'),
|
||||||
if (title != null) Text(' - $title'),
|
if (title != null) Text(' - $title'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
titleAlignment: ListTileTitleAlignment.titleHeight,
|
||||||
subtitle: description != null ? Text(description!) : null,
|
subtitle: description != null ? Text(description!) : null,
|
||||||
|
trailing: startDate != null && endDate != null
|
||||||
|
? Text(_getTimeString(startDate!, endDate!))
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getTimeString(String startDate, String endDate) {
|
||||||
|
final firstDate = DateTime.parse('$startDate-01');
|
||||||
|
final secondDate = DateTime.parse('$endDate-01');
|
||||||
|
return '${months[firstDate.month - 1]} ${firstDate.year} - ${months[secondDate.month - 1]} ${secondDate.year}';
|
||||||
|
}
|
||||||
|
|
||||||
|
static const months = [
|
||||||
|
'January',
|
||||||
|
'February',
|
||||||
|
'March',
|
||||||
|
'April',
|
||||||
|
'May',
|
||||||
|
'June',
|
||||||
|
'July',
|
||||||
|
'August',
|
||||||
|
'September',
|
||||||
|
'October',
|
||||||
|
'November',
|
||||||
|
'December'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,12 +38,16 @@ class ContentBox extends StatelessWidget {
|
|||||||
location: data['location'],
|
location: data['location'],
|
||||||
title: data['title'],
|
title: data['title'],
|
||||||
description: data['description'],
|
description: data['description'],
|
||||||
|
startDate: data['startDate'],
|
||||||
|
endDate: data['endDate'],
|
||||||
);
|
);
|
||||||
case ContentType.education:
|
case ContentType.education:
|
||||||
return ContentListTile(
|
return ContentListTile(
|
||||||
name: data['name'],
|
name: data['name'],
|
||||||
location: data['location'],
|
location: data['location'],
|
||||||
title: data['title'],
|
title: data['title'],
|
||||||
|
startDate: data['startDate'],
|
||||||
|
endDate: data['endDate'],
|
||||||
);
|
);
|
||||||
case ContentType.skills:
|
case ContentType.skills:
|
||||||
return SkillListTile(
|
return SkillListTile(
|
||||||
|
|||||||
Reference in New Issue
Block a user