Fixed Simple Problem, that occured after migrating to new version.

Still WIP need to fix more Problems
This commit is contained in:
2024-03-15 07:05:10 +01:00
parent c12ba48e15
commit 3085a295e5
36 changed files with 268 additions and 232 deletions

View File

@ -7,13 +7,13 @@ class AppSettings {
final Color leftColor;
final Duration duration;
AppSettings({
const AppSettings({
this.doneColor,
this.leftColor,
this.duration,
});
factory AppSettings.defaults() => AppSettings(
factory AppSettings.defaults() => const AppSettings(
doneColor: Colors.green,
leftColor: Colors.red,
duration: Duration(days: 365),

View File

@ -8,7 +8,7 @@ class AppState {
final List<TimeProgress> timeProgressList;
final AppSettings appSettings;
AppState(
const AppState(
{this.hasProgressesLoaded = false,
this.hasSettingsLoaded = false,
this.timeProgressList = const [],
@ -22,7 +22,7 @@ class AppState {
List<TimeProgress> timeProgressList,
}) {
return AppState(
hasProgressesLoaded: hasLoaded ?? this.hasProgressesLoaded,
hasProgressesLoaded: hasLoaded ?? hasProgressesLoaded,
timeProgressList: timeProgressList ?? this.timeProgressList,
);
}

View File

@ -38,7 +38,7 @@ class TimeProgress {
int allDays() => endTime.difference(startTime).inDays;
double percentDone() {
double percent = this.daysBehind() / (this.allDays() / 100) / 100;
double percent = daysBehind() / (allDays() / 100) / 100;
if (percent < 0) percent = 0;
if (percent > 1) percent = 1;
return percent;
@ -48,7 +48,7 @@ class TimeProgress {
DateTime.now().millisecondsSinceEpoch > startTime.millisecondsSinceEpoch;
int daysTillStart() {
if (hasStarted()) throw new TimeProgressHasStartedException();
if (hasStarted()) throw TimeProgressHasStartedException();
return startTime.difference(DateTime.now()).inDays;
}
@ -56,7 +56,7 @@ class TimeProgress {
DateTime.now().millisecondsSinceEpoch > endTime.millisecondsSinceEpoch;
int daysSinceEnd() {
if (!hasEnded()) throw new TimeProgressHasNotEndedException();
if (!hasEnded()) throw TimeProgressHasNotEndedException();
return DateTime.now().difference(endTime).inDays;
}
@ -79,11 +79,12 @@ class TimeProgress {
"TimeProgress{id: $id, name: $name, startTime: $startTime, endTime: $endTime}";
TimeProgressEntity toEntity() {
if (!TimeProgress.isNameValid(name))
throw new TimeProgressInvalidNameException(name);
if (!TimeProgress.areTimesValid(startTime, endTime))
throw new TimeProgressStartTimeIsNotBeforeEndTimeException(
startTime, endTime);
if (!TimeProgress.isNameValid(name)) {
throw TimeProgressInvalidNameException(name);
}
if (!TimeProgress.areTimesValid(startTime, endTime)) {
throw TimeProgressStartTimeIsNotBeforeEndTimeException(startTime, endTime);
}
return TimeProgressEntity(id, name, startTime, endTime);
}