From 7a1bbfe365dc1ae2132fc80f3f4b8f93a5988ed9 Mon Sep 17 00:00:00 2001 From: marco Date: Mon, 2 Dec 2024 17:50:31 +0100 Subject: [PATCH] created content boxes --- lib/widgets/content_list_tile.dart | 30 ++++++++++++++++ lib/widgets/content_widget.dart | 56 ++++++++++++++++++++++++++++++ lib/widgets/skill_list_tile.dart | 30 ++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 lib/widgets/content_list_tile.dart create mode 100644 lib/widgets/content_widget.dart create mode 100644 lib/widgets/skill_list_tile.dart diff --git a/lib/widgets/content_list_tile.dart b/lib/widgets/content_list_tile.dart new file mode 100644 index 0000000..6eece2e --- /dev/null +++ b/lib/widgets/content_list_tile.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class ContentListTile extends StatelessWidget { + const ContentListTile({ + super.key, + this.name, + this.location, + this.title, + this.description, + }); + + final String? name; + final String? location; + final String? title; + final String? description; + + @override + Widget build(BuildContext context) { + return ListTile( + title: Row( + children: [ + if (name != null) Text(name!), + if (location != null) Text(', $location'), + if (title != null) Text(' - $title'), + ], + ), + subtitle: description != null ? Text(description!) : null, + ); + } +} diff --git a/lib/widgets/content_widget.dart b/lib/widgets/content_widget.dart new file mode 100644 index 0000000..396d594 --- /dev/null +++ b/lib/widgets/content_widget.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:resume/widgets/content_list_tile.dart'; +import 'package:resume/widgets/skill_list_tile.dart'; + +class ContentBox extends StatelessWidget { + const ContentBox({ + super.key, + required this.title, + required this.content, + required this.contentType, + }); + + final ContentType contentType; + final List content; + final String title; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.max, + children: [ + Text(title), + ListView.builder( + shrinkWrap: true, + itemCount: content.length, + itemBuilder: (context, index) => _buildListTile(content[index]), + ), + ], + ); + } + + Widget _buildListTile(Map data) { + switch (contentType) { + case ContentType.experience: + return ContentListTile( + name: data['name'], + location: data['location'], + title: data['title'], + description: data['description'], + ); + case ContentType.education: + return ContentListTile( + name: data['name'], + location: data['location'], + title: data['title'], + ); + case ContentType.skills: + return SkillListTile( + name: data['name'], + percentage: data['percentage'], + ); + } + } +} + +enum ContentType { experience, education, skills } diff --git a/lib/widgets/skill_list_tile.dart b/lib/widgets/skill_list_tile.dart new file mode 100644 index 0000000..ffb69cf --- /dev/null +++ b/lib/widgets/skill_list_tile.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class SkillListTile extends StatelessWidget { + const SkillListTile({ + super.key, + required this.name, + this.percentage, + }); + + final String name; + final String? percentage; + + @override + Widget build(BuildContext context) { + return ListTile( + title: Row( + children: [ + Expanded(flex: 2, child: Text(name)), + if (percentage != null) + Expanded( + flex: 5, + child: LinearProgressIndicator( + value: double.parse(percentage!) / 100, + ), + ), + ], + ), + ); + } +}