70 lines
1.8 KiB
Dart
70 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:resume/services/breakpoints.dart';
|
|
|
|
class ContentListTile extends StatelessWidget {
|
|
const ContentListTile(
|
|
{super.key,
|
|
this.name,
|
|
this.location,
|
|
this.title,
|
|
this.description,
|
|
this.startDate,
|
|
this.endDate});
|
|
|
|
final String? name;
|
|
final String? location;
|
|
final String? title;
|
|
final String? description;
|
|
final String? startDate;
|
|
final String? endDate;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final width = MediaQuery.of(context).size.width;
|
|
|
|
return ListTile(
|
|
contentPadding: const EdgeInsets.all(0),
|
|
title: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
if (name != null) Text(name!),
|
|
if (location != null) Text(', $location'),
|
|
if (title != null && Breakpoints.xl < width) Text(' - $title'),
|
|
],
|
|
),
|
|
if (title != null && Breakpoints.xl >= width) Text('$title'),
|
|
],
|
|
),
|
|
titleAlignment: ListTileTitleAlignment.titleHeight,
|
|
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'
|
|
];
|
|
}
|