157 lines
4.8 KiB
Dart
157 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:resume/services/breakpoints.dart';
|
|
import 'package:resume/constants.dart' show ContentType;
|
|
|
|
import '../services/tools.dart';
|
|
|
|
class ContentListTile extends StatelessWidget {
|
|
const ContentListTile.education(
|
|
{super.key,
|
|
required this.name,
|
|
required this.location,
|
|
required this.title,
|
|
required this.startDate,
|
|
required this.endDate})
|
|
: description = '',
|
|
percentage = '',
|
|
_contentType = ContentType.education;
|
|
|
|
const ContentListTile.experience(
|
|
{super.key,
|
|
required this.name,
|
|
required this.location,
|
|
required this.title,
|
|
required this.description,
|
|
required this.startDate,
|
|
required this.endDate})
|
|
: percentage = '',
|
|
_contentType = ContentType.experience;
|
|
|
|
const ContentListTile.skills(
|
|
{super.key, required this.name, required this.percentage})
|
|
: description = '',
|
|
title = ',',
|
|
location = '',
|
|
startDate = '',
|
|
endDate = '',
|
|
_contentType = ContentType.skills;
|
|
|
|
final String description;
|
|
final String endDate;
|
|
final String location;
|
|
final String name;
|
|
final String percentage;
|
|
final String startDate;
|
|
final String title;
|
|
|
|
final ContentType _contentType;
|
|
|
|
Widget get _skillsListTile => ListTile(
|
|
contentPadding: const EdgeInsets.all(0),
|
|
title: Row(
|
|
children: [
|
|
Expanded(flex: 2, child: Text(name)),
|
|
const Padding(padding: EdgeInsets.only(bottom: 8)),
|
|
Expanded(
|
|
flex: 4,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
child: LinearProgressIndicator(
|
|
value: (double.tryParse(percentage) ?? 1) / 100,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
Widget _getEducationListTile(BuildContext context, double screenWidth) =>
|
|
ListTile(
|
|
contentPadding: const EdgeInsets.all(0),
|
|
title: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
name,
|
|
),
|
|
Text(', $location'),
|
|
if (Breakpoints.xl < screenWidth) Text(' - $title'),
|
|
],
|
|
),
|
|
if (Breakpoints.xl >= screenWidth) Text(title),
|
|
],
|
|
),
|
|
titleAlignment: ListTileTitleAlignment.titleHeight,
|
|
subtitle: Breakpoints.sm >= screenWidth
|
|
? Padding(
|
|
padding: const EdgeInsets.only(bottom: 8),
|
|
child: Text(
|
|
Tools.buildTimeString(startDate, endDate),
|
|
style: Theme.of(context).textTheme.labelSmall,
|
|
),
|
|
)
|
|
: null,
|
|
trailing: Breakpoints.sm < screenWidth
|
|
? Text(Tools.buildTimeString(startDate, endDate))
|
|
: null,
|
|
);
|
|
|
|
Widget _getExperienceListTile(BuildContext context, double screenWidth) =>
|
|
ListTile(
|
|
contentPadding: const EdgeInsets.all(0),
|
|
title: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
name,
|
|
),
|
|
Text(', $location'),
|
|
if (Breakpoints.xl < screenWidth) Text(' - $title'),
|
|
],
|
|
),
|
|
if (Breakpoints.xl >= screenWidth) Text(title),
|
|
],
|
|
),
|
|
titleAlignment: ListTileTitleAlignment.titleHeight,
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Padding(padding: EdgeInsets.only(top: 8)),
|
|
if (Breakpoints.sm >= screenWidth)
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 8),
|
|
child: Text(
|
|
Tools.buildTimeString(startDate, endDate),
|
|
style: Theme.of(context).textTheme.labelSmall,
|
|
),
|
|
),
|
|
Text(description),
|
|
],
|
|
),
|
|
trailing: Breakpoints.sm < screenWidth
|
|
? Text(Tools.buildTimeString(startDate, endDate))
|
|
: null,
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final width = MediaQuery.of(context).size.width;
|
|
|
|
if (_contentType == ContentType.skills) {
|
|
return _skillsListTile;
|
|
} else if (_contentType == ContentType.education) {
|
|
return _getEducationListTile(context, width);
|
|
} else if (_contentType == ContentType.experience) {
|
|
return _getExperienceListTile(context, width);
|
|
} else {
|
|
return const Placeholder();
|
|
}
|
|
}
|
|
}
|