You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
4.1 KiB
167 lines
4.1 KiB
import 'package:flutter/material.dart';
|
|
import 'package:timemanage/db/data_provider.dart';
|
|
import 'package:timemanage/model/project.dart';
|
|
import 'package:timemanage/model/timer_entry.dart';
|
|
import 'dart:math';
|
|
|
|
class MockDataProvider extends DataProvider {
|
|
String localeKey;
|
|
static final Map<String, Map<String, String>> l10n = {
|
|
"en": {
|
|
"administration": "Administration",
|
|
"mockups": "Mockups",
|
|
"ui-layout": "UI Layout",
|
|
"coffee": "Coffee",
|
|
"app-development": "App development"
|
|
},
|
|
"zh-CN": {
|
|
"ui-layout": "UI布局",
|
|
"administration": "管理",
|
|
"coffee": "咖啡",
|
|
"mockups": "样机",
|
|
"app-development": "应用程式开发",
|
|
},
|
|
};
|
|
|
|
MockDataProvider(Locale locale) : localeKey = locale.languageCode {
|
|
if (locale.languageCode == "zh") {
|
|
localeKey += "-${locale.countryCode!}";
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<List<Project>> listProjects() async {
|
|
return <Project>[
|
|
Project(
|
|
id: 1,
|
|
name: "Time Manager",
|
|
colour: Colors.cyan[600]!,
|
|
archived: false),
|
|
Project(
|
|
id: 2,
|
|
name: l10n[localeKey]!["administration"]!,
|
|
colour: Colors.pink[600]!,
|
|
archived: false,
|
|
),
|
|
];
|
|
}
|
|
|
|
@override
|
|
Future<List<TimerEntry>> listTimers() async {
|
|
int tid = 1;
|
|
Random rand = Random(42);
|
|
|
|
// start with running timers
|
|
List<TimerEntry> entries = [
|
|
TimerEntry(
|
|
id: tid++,
|
|
description: l10n[localeKey]!["ui-layout"],
|
|
projectID: 1,
|
|
startTime: DateTime.now()
|
|
.subtract(const Duration(hours: 2, minutes: 10, seconds: 1)),
|
|
endTime: null,
|
|
),
|
|
TimerEntry(
|
|
id: tid++,
|
|
description: l10n[localeKey]!["coffee"],
|
|
projectID: 2,
|
|
startTime:
|
|
DateTime.now().subtract(const Duration(minutes: 3, seconds: 14)),
|
|
endTime: null,
|
|
),
|
|
];
|
|
|
|
// add some fake March stuff
|
|
for (int w = 0; w < 4; w++) {
|
|
for (int d = 0; d < 5; d++) {
|
|
String descriptionKey;
|
|
double r = rand.nextDouble();
|
|
if (r <= 0.2) {
|
|
descriptionKey = 'mockups';
|
|
} else if (r <= 0.5) {
|
|
descriptionKey = 'ui-layout';
|
|
} else {
|
|
descriptionKey = 'app-development';
|
|
}
|
|
|
|
entries.add(TimerEntry(
|
|
id: tid++,
|
|
description: l10n[localeKey]![descriptionKey],
|
|
projectID: 1,
|
|
startTime: DateTime(
|
|
2020,
|
|
3,
|
|
(w * 7) + d + 2,
|
|
rand.nextInt(3) + 8,
|
|
rand.nextInt(60),
|
|
rand.nextInt(60),
|
|
),
|
|
endTime: DateTime(
|
|
2020,
|
|
3,
|
|
(w * 7) + d + 2,
|
|
rand.nextInt(3) + 13,
|
|
rand.nextInt(60),
|
|
rand.nextInt(60),
|
|
),
|
|
));
|
|
|
|
entries.add(TimerEntry(
|
|
id: tid++,
|
|
description: l10n[localeKey]!['administration'],
|
|
projectID: 2,
|
|
startTime: DateTime(
|
|
2020,
|
|
3,
|
|
(w * 7) + d + 2,
|
|
14,
|
|
rand.nextInt(30),
|
|
rand.nextInt(60),
|
|
),
|
|
endTime: DateTime(
|
|
2020,
|
|
3,
|
|
(w * 7) + d + 2,
|
|
15,
|
|
rand.nextInt(30),
|
|
rand.nextInt(60),
|
|
),
|
|
));
|
|
}
|
|
}
|
|
return entries;
|
|
}
|
|
|
|
@override
|
|
Future<Project> createProject(
|
|
{required String name, Color? colour, bool? archived}) async {
|
|
return Project(
|
|
id: -1, name: name, colour: colour!, archived: archived ?? false);
|
|
}
|
|
|
|
@override
|
|
Future<void> editProject(Project project) async {}
|
|
@override
|
|
Future<void> deleteProject(Project project) async {}
|
|
@override
|
|
Future<TimerEntry> createTimer(
|
|
{String? description,
|
|
int? projectID,
|
|
DateTime? startTime,
|
|
DateTime? endTime}) async {
|
|
DateTime st = startTime ?? DateTime.now();
|
|
return TimerEntry(
|
|
id: -1,
|
|
description: description,
|
|
projectID: projectID,
|
|
startTime: st,
|
|
endTime: endTime,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<void> editTimer(TimerEntry timer) async {}
|
|
@override
|
|
Future<void> deleteTimer(TimerEntry timer) async {}
|
|
}
|