Refactoring
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:resume/constants.dart';
|
||||
|
||||
class ContentProvider {
|
||||
ContentProvider._();
|
||||
@@ -17,11 +18,25 @@ class ContentProvider {
|
||||
return true;
|
||||
}
|
||||
|
||||
static Map<String, dynamic> _content = {};
|
||||
static Map<String, dynamic> _content = {
|
||||
'experience': <List<dynamic>>[],
|
||||
'education': <List<dynamic>>[],
|
||||
'skills': <List<dynamic>>[],
|
||||
'text': <String>[],
|
||||
};
|
||||
|
||||
static List<dynamic> get experience => _content['experience'];
|
||||
|
||||
static List<dynamic> get education => _content['education'];
|
||||
|
||||
static List<dynamic> get skills => _content['skills'];
|
||||
static T getContent<T>(ContentType contentType) {
|
||||
switch (contentType) {
|
||||
case ContentType.experience:
|
||||
return _content['experience'] as T;
|
||||
case ContentType.education:
|
||||
return _content['education'] as T;
|
||||
case ContentType.skills:
|
||||
return _content['skills'] as T;
|
||||
case ContentType.text:
|
||||
return _content['text'] as T;
|
||||
default:
|
||||
return [] as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
lib/services/tools.dart
Normal file
12
lib/services/tools.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:resume/constants.dart' show months;
|
||||
|
||||
class Tools {
|
||||
/// builds timespan-String out of two date-Strings.
|
||||
/// Date has to be formatted as yyyy-MM
|
||||
static buildTimeString(String startDate, String endDate) {
|
||||
if (startDate.isEmpty || endDate.isEmpty) return '';
|
||||
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}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user