85 lines
2.2 KiB
Dart
85 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:resume/widgets/content_list_tile.dart';
|
|
import 'package:resume/widgets/language_widget.dart';
|
|
import 'package:resume/constants.dart' show ContentType;
|
|
|
|
class ContentBlock extends StatelessWidget {
|
|
const ContentBlock({
|
|
super.key,
|
|
required this.blockTitle,
|
|
required this.contentType,
|
|
required this.content,
|
|
});
|
|
|
|
final String blockTitle;
|
|
final ContentType contentType;
|
|
final dynamic content;
|
|
|
|
Widget get _getContentWidget {
|
|
if (contentType == ContentType.language) {
|
|
return const LanguageWidget();
|
|
} else if (contentType == ContentType.text ||
|
|
contentType == ContentType.generalSkills) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
child: Text(content),
|
|
);
|
|
}
|
|
// List-based content-blocks
|
|
List<Widget> widgets = [];
|
|
for (var item in content) {
|
|
widgets.add(_buildListTile(item));
|
|
}
|
|
return Column(
|
|
children: widgets,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
blockTitle,
|
|
style: Theme.of(context).textTheme.headlineMedium,
|
|
),
|
|
const Padding(padding: EdgeInsets.only(bottom: 8)),
|
|
_getContentWidget,
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildListTile(Map data) {
|
|
if (contentType == ContentType.experience) {
|
|
return ContentListTile.experience(
|
|
name: data['name'],
|
|
location: data['location'],
|
|
title: data['title'],
|
|
description: data['description'],
|
|
startDate: data['startDate'],
|
|
endDate: data['endDate'],
|
|
);
|
|
} else if (contentType == ContentType.education) {
|
|
return ContentListTile.education(
|
|
name: data['name'],
|
|
location: data['location'],
|
|
title: data['title'],
|
|
startDate: data['startDate'],
|
|
endDate: data['endDate'],
|
|
);
|
|
} else {
|
|
return ContentListTile.skills(
|
|
name: data['name'],
|
|
percentage: data['percentage'],
|
|
);
|
|
}
|
|
}
|
|
}
|