Feature/basic app (#1)
Feature/Basic App (#1) Basic App Structure Consists of Time Progress Dashboard, Time Progress Detail View and Time Progress Creator. All of these have an AppDrawer with a Link To the Dashboard and all your Track Time Progresses, also an About Button. Commits: * Undetailed Commit more work * Changed isEditing ? in Detail Screen and Extracted FAB row to widget * Extracted Progress Detail Fab Row and Progress Detail select Date Btn to widgets * Create Progress Detail Widgets Folder * Extracted Edit Dates Row Widget * Extracted Functions from ui * Made some fields private * LoadTimerProgressList if unloaded function * Created App Yes No Dialog Widget * Using Yes No Dialog in Detail Screen * Created TimeProgress Initial Default factory * Renamed to Time Progress Tracker * Added About Button in App Drawer * Code cleanup * Code clean up and fixed Bug with null as string in Repository Signed-off-by Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
committed by
GitHub
parent
976fbec455
commit
f013c0de65
@ -1,26 +1,51 @@
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:time_progress_calculator/persistence/time_progress_entity.dart';
|
||||
import 'package:time_progress_calculator/uuid.dart';
|
||||
import 'package:time_progress_tracker/persistence/time_progress_entity.dart';
|
||||
import 'package:time_progress_tracker/uuid.dart';
|
||||
|
||||
@immutable
|
||||
class TimeProgress {
|
||||
final String id;
|
||||
final String name;
|
||||
final DateTime startTime;
|
||||
final DateTime endTime;
|
||||
|
||||
TimeProgress(this.startTime, this.endTime, {String id})
|
||||
TimeProgress(this.name, this.startTime, this.endTime, {String id})
|
||||
: id = id ?? Uuid().generateV4();
|
||||
|
||||
TimeProgress copyWith({String id, DateTime startTime, DateTime endTime}) {
|
||||
factory TimeProgress.initialDefault() {
|
||||
int thisYear = DateTime.now().year;
|
||||
return TimeProgress("", DateTime(thisYear - 1), DateTime(thisYear + 1));
|
||||
}
|
||||
|
||||
TimeProgress copyWith(
|
||||
{String id, String name, DateTime startTime, DateTime endTime}) {
|
||||
return TimeProgress(
|
||||
name ?? this.name,
|
||||
startTime ?? this.startTime,
|
||||
endTime ?? this.endTime,
|
||||
id: id ?? this.id,
|
||||
);
|
||||
}
|
||||
|
||||
int daysBehind() {
|
||||
return DateTime.now().difference(startTime).inDays;
|
||||
}
|
||||
|
||||
int daysLeft() {
|
||||
return endTime.difference(DateTime.now()).inDays;
|
||||
}
|
||||
|
||||
int allDays() {
|
||||
return endTime.difference(startTime).inDays;
|
||||
}
|
||||
|
||||
double percentDone() {
|
||||
return this.daysBehind() / (this.allDays() / 100) / 100;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode ^ startTime.hashCode ^ endTime.hashCode;
|
||||
int get hashCode =>
|
||||
id.hashCode ^ name.hashCode ^ startTime.hashCode ^ endTime.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@ -28,20 +53,22 @@ class TimeProgress {
|
||||
other is TimeProgress &&
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
name == other.name &&
|
||||
startTime == other.startTime &&
|
||||
endTime == other.endTime;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Timer{id: $id, startTimer: $startTime, endTimer: $endTime}";
|
||||
return "TimeProgress{id: $id, name: $name, startTime: $startTime, endTime: $endTime}";
|
||||
}
|
||||
|
||||
TimeProgressEntity toEntity() {
|
||||
return TimeProgressEntity(id, startTime, endTime);
|
||||
return TimeProgressEntity(id, name, startTime, endTime);
|
||||
}
|
||||
|
||||
static TimeProgress fromEntity(TimeProgressEntity entity) {
|
||||
return TimeProgress(
|
||||
entity.name,
|
||||
entity.startTime,
|
||||
entity.endTime,
|
||||
id: entity.id ?? Uuid().generateV4(),
|
||||
|
Reference in New Issue
Block a user