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:
Andreas Fahrecker
2020-11-20 01:17:17 +01:00
committed by GitHub
parent 976fbec455
commit f013c0de65
27 changed files with 984 additions and 283 deletions

View File

@ -1,12 +1,14 @@
class TimeProgressEntity {
final String id;
final String name;
final DateTime startTime;
final DateTime endTime;
TimeProgressEntity(this.id, this.startTime, this.endTime);
TimeProgressEntity(this.id, this.name, this.startTime, this.endTime);
@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) =>
@ -14,23 +16,26 @@ class TimeProgressEntity {
other is TimeProgressEntity &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
startTime == other.startTime &&
endTime == other.endTime;
Map<String, Object> toJson() {
return {
"id": id,
"name": name,
"startTime": startTime.millisecondsSinceEpoch,
"endTime": startTime.millisecondsSinceEpoch
"endTime": endTime.millisecondsSinceEpoch
};
}
static TimeProgressEntity fromJson(Map<String, Object> json) {
final String id = json["id"] as String;
final String name = json["name"] as String;
final DateTime startTime =
DateTime.fromMillisecondsSinceEpoch(json["startTime"] as int);
final DateTime endTime =
DateTime.fromMillisecondsSinceEpoch(json["endTime"] as int);
return TimeProgressEntity(id, startTime, endTime);
return TimeProgressEntity(id, name, startTime, endTime);
}
}

View File

@ -1,7 +1,8 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:time_progress_calculator/persistence/time_progress_entity.dart';
import 'package:time_progress_tracker/persistence/time_progress_entity.dart';
import 'dart:developer' as developer;
class TimeProgressRepository {
static const String _key = "time_progress_repo";
@ -12,16 +13,19 @@ class TimeProgressRepository {
Future<List<TimeProgressEntity>> loadTimeProgressList() {
final String jsonString = this.prefs.getString(_key);
return codec
if (jsonString == null) {
return Future<List<TimeProgressEntity>>.value([]);
}
return Future<List<TimeProgressEntity>>.value(codec
.decode(jsonString)["timers"]
.cast<Map<String, Object>>()
.map<TimeProgressEntity>(TimeProgressEntity.fromJson)
.toList(growable: false);
.toList(growable: false));
}
Future<bool> saveTimeProgressList(List<TimeProgressEntity> timeProgressList) {
final String jsonString = codec
.encode({"timers": timeProgressList.map((timer) => timer.toJson()).toList()});
final String jsonString = codec.encode(
{"timers": timeProgressList.map((timer) => timer.toJson()).toList()});
return this.prefs.setString(_key, jsonString);
}
}