Compare commits
6 Commits
c12ba48e15
...
main
Author | SHA1 | Date | |
---|---|---|---|
3940184975 | |||
eee1d12851 | |||
e11a73d37e | |||
ead31e12c0 | |||
421d19f91f | |||
3085a295e5 |
@ -22,6 +22,12 @@ if (flutterVersionName == null) {
|
|||||||
flutterVersionName = '1.0'
|
flutterVersionName = '1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def keystoreProperties = new Properties()
|
||||||
|
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.fahrecker.time_progress_calculator"
|
namespace "com.fahrecker.time_progress_calculator"
|
||||||
compileSdk flutter.compileSdkVersion
|
compileSdk flutter.compileSdkVersion
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.fahrecker.time_progress_calculator">
|
package="com.fahrecker.time_progress_calculator">
|
||||||
<application
|
<application
|
||||||
android:label="time_progress_tracker"
|
android:label="Time Progress Tracker"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
|
@ -49,8 +49,9 @@ class DeleteTimeProgressAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loadTimeProgressListIfUnloaded(Store<AppState> store) {
|
void loadTimeProgressListIfUnloaded(Store<AppState> store) {
|
||||||
if (!store.state.hasProgressesLoaded)
|
if (!store.state.hasProgressesLoaded) {
|
||||||
store.dispatch(LoadTimeProgressListAction());
|
store.dispatch(LoadTimeProgressListAction());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSettingsIfUnloaded(Store<AppState> store) {
|
void loadSettingsIfUnloaded(Store<AppState> store) {
|
||||||
|
19
lib/app.dart
19
lib/app.dart
@ -11,10 +11,10 @@ class TimeProgressTrackerApp extends StatelessWidget {
|
|||||||
|
|
||||||
final Store<AppState> store;
|
final Store<AppState> store;
|
||||||
|
|
||||||
TimeProgressTrackerApp({
|
const TimeProgressTrackerApp({
|
||||||
Key key,
|
super.key,
|
||||||
this.store,
|
required this.store,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -23,19 +23,22 @@ class TimeProgressTrackerApp extends StatelessWidget {
|
|||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
title: name,
|
title: name,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
|
primarySwatch: Colors.indigo,
|
||||||
|
colorScheme: ColorScheme.fromSwatch(
|
||||||
primarySwatch: Colors.indigo,
|
primarySwatch: Colors.indigo,
|
||||||
accentColor: Colors.indigoAccent,
|
accentColor: Colors.indigoAccent,
|
||||||
|
backgroundColor: Colors.white
|
||||||
|
),
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
),
|
),
|
||||||
initialRoute: HomeScreen.routeName,
|
initialRoute: HomeScreen.routeName,
|
||||||
routes: {
|
routes: {
|
||||||
HomeScreen.routeName: (BuildContext context) =>
|
HomeScreen.routeName: (BuildContext context) => const HomeScreen(),
|
||||||
HomeScreen(),
|
|
||||||
ProgressDetailScreen.routeName: (BuildContext context) =>
|
ProgressDetailScreen.routeName: (BuildContext context) =>
|
||||||
ProgressDetailScreen(),
|
const ProgressDetailScreen(),
|
||||||
ProgressCreationScreen.routeName: (BuildContext context) =>
|
ProgressCreationScreen.routeName: (BuildContext context) =>
|
||||||
ProgressCreationScreen(),
|
const ProgressCreationScreen(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,7 @@ import 'dart:ui';
|
|||||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||||
|
|
||||||
TimeProgress selectProgressById(List<TimeProgress> tpList, String id) =>
|
TimeProgress selectProgressById(List<TimeProgress> tpList, String id) =>
|
||||||
tpList.firstWhere((tp) => tp.id == id, orElse: null);
|
tpList.firstWhere((tp) => tp.id == id, orElse: () => TimeProgress.initialDefault());
|
||||||
|
|
||||||
List<TimeProgress> selectActiveProgresses(List<TimeProgress> tpList) =>
|
List<TimeProgress> selectActiveProgresses(List<TimeProgress> tpList) =>
|
||||||
tpList.where((tp) => tp.hasStarted() && !tp.hasEnded()).toList();
|
tpList.where((tp) => tp.hasStarted() && !tp.hasEnded()).toList();
|
||||||
|
@ -17,12 +17,12 @@ List<Middleware<AppState>> createStoreMiddleware(
|
|||||||
final loadSettings = _createLoadAppSettings(settingsRepo);
|
final loadSettings = _createLoadAppSettings(settingsRepo);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
TypedMiddleware<AppState, LoadTimeProgressListAction>(loadTimeProgressList),
|
TypedMiddleware<AppState, LoadTimeProgressListAction>(loadTimeProgressList).call,
|
||||||
TypedMiddleware<AppState, AddTimeProgressAction>(saveTimeProgressList),
|
TypedMiddleware<AppState, AddTimeProgressAction>(saveTimeProgressList).call,
|
||||||
TypedMiddleware<AppState, UpdateTimeProgressAction>(saveTimeProgressList),
|
TypedMiddleware<AppState, UpdateTimeProgressAction>(saveTimeProgressList).call,
|
||||||
TypedMiddleware<AppState, DeleteTimeProgressAction>(saveTimeProgressList),
|
TypedMiddleware<AppState, DeleteTimeProgressAction>(saveTimeProgressList).call,
|
||||||
TypedMiddleware<AppState, LoadSettingsAction>(loadSettings),
|
TypedMiddleware<AppState, LoadSettingsAction>(loadSettings).call,
|
||||||
TypedMiddleware<AppState, UpdateAppSettingsActions>(saveSettings)
|
TypedMiddleware<AppState, UpdateAppSettingsActions>(saveSettings).call
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,9 +45,6 @@ Middleware<AppState> _createLoadTimeProgressList(
|
|||||||
repository.loadTimeProgressList().then((timeProgresses) {
|
repository.loadTimeProgressList().then((timeProgresses) {
|
||||||
List<TimeProgress> timeProgressList =
|
List<TimeProgress> timeProgressList =
|
||||||
timeProgresses.map<TimeProgress>(TimeProgress.fromEntity).toList();
|
timeProgresses.map<TimeProgress>(TimeProgress.fromEntity).toList();
|
||||||
if (timeProgressList == null) {
|
|
||||||
timeProgressList = [];
|
|
||||||
}
|
|
||||||
store.dispatch(TimeProgressListLoadedAction(
|
store.dispatch(TimeProgressListLoadedAction(
|
||||||
timeProgressList,
|
timeProgressList,
|
||||||
));
|
));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class TimeProgressInvalidNameException implements Exception {
|
class TimeProgressInvalidNameException implements Exception {
|
||||||
final invalidName;
|
final String invalidName;
|
||||||
|
|
||||||
TimeProgressInvalidNameException(this.invalidName);
|
TimeProgressInvalidNameException(this.invalidName);
|
||||||
|
|
||||||
@ -7,8 +7,8 @@ class TimeProgressInvalidNameException implements Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TimeProgressStartTimeIsNotBeforeEndTimeException implements Exception {
|
class TimeProgressStartTimeIsNotBeforeEndTimeException implements Exception {
|
||||||
final startTime;
|
final DateTime startTime;
|
||||||
final endTime;
|
final DateTime endTime;
|
||||||
|
|
||||||
TimeProgressStartTimeIsNotBeforeEndTimeException(
|
TimeProgressStartTimeIsNotBeforeEndTimeException(
|
||||||
this.startTime, this.endTime);
|
this.startTime, this.endTime);
|
||||||
|
@ -7,22 +7,22 @@ class AppSettings {
|
|||||||
final Color leftColor;
|
final Color leftColor;
|
||||||
final Duration duration;
|
final Duration duration;
|
||||||
|
|
||||||
AppSettings({
|
const AppSettings({
|
||||||
this.doneColor,
|
required this.doneColor,
|
||||||
this.leftColor,
|
required this.leftColor,
|
||||||
this.duration,
|
required this.duration,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory AppSettings.defaults() => AppSettings(
|
factory AppSettings.defaults() => const AppSettings(
|
||||||
doneColor: Colors.green,
|
doneColor: Colors.green,
|
||||||
leftColor: Colors.red,
|
leftColor: Colors.red,
|
||||||
duration: Duration(days: 365),
|
duration: Duration(days: 365),
|
||||||
);
|
);
|
||||||
|
|
||||||
AppSettings copyWith({
|
AppSettings copyWith({
|
||||||
Color doneColor,
|
Color? doneColor,
|
||||||
Color leftColor,
|
Color? leftColor,
|
||||||
Duration duration,
|
Duration? duration,
|
||||||
}) =>
|
}) =>
|
||||||
AppSettings(
|
AppSettings(
|
||||||
doneColor: doneColor ?? this.doneColor,
|
doneColor: doneColor ?? this.doneColor,
|
||||||
|
@ -8,22 +8,24 @@ class AppState {
|
|||||||
final List<TimeProgress> timeProgressList;
|
final List<TimeProgress> timeProgressList;
|
||||||
final AppSettings appSettings;
|
final AppSettings appSettings;
|
||||||
|
|
||||||
AppState(
|
const AppState(
|
||||||
{this.hasProgressesLoaded = false,
|
{this.hasProgressesLoaded = false,
|
||||||
this.hasSettingsLoaded = false,
|
this.hasSettingsLoaded = false,
|
||||||
this.timeProgressList = const [],
|
this.timeProgressList = const [],
|
||||||
this.appSettings});
|
required this.appSettings});
|
||||||
|
|
||||||
factory AppState.initial() =>
|
factory AppState.initial() =>
|
||||||
AppState(hasProgressesLoaded: false, appSettings: AppSettings.defaults());
|
AppState(hasProgressesLoaded: false, appSettings: AppSettings.defaults());
|
||||||
|
|
||||||
AppState copyWith({
|
AppState copyWith({
|
||||||
bool hasLoaded,
|
bool? hasLoaded,
|
||||||
List<TimeProgress> timeProgressList,
|
List<TimeProgress>? timeProgressList,
|
||||||
|
AppSettings? appSettings,
|
||||||
}) {
|
}) {
|
||||||
return AppState(
|
return AppState(
|
||||||
hasProgressesLoaded: hasLoaded ?? this.hasProgressesLoaded,
|
hasProgressesLoaded: hasLoaded ?? hasProgressesLoaded,
|
||||||
timeProgressList: timeProgressList ?? this.timeProgressList,
|
timeProgressList: timeProgressList ?? this.timeProgressList,
|
||||||
|
appSettings: appSettings ?? this.appSettings,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class TimeProgress {
|
|||||||
final DateTime startTime;
|
final DateTime startTime;
|
||||||
final DateTime endTime;
|
final DateTime endTime;
|
||||||
|
|
||||||
TimeProgress(this.name, this.startTime, this.endTime, {String id})
|
TimeProgress(this.name, this.startTime, this.endTime, {String? id})
|
||||||
: id = id ?? Uuid().generateV4();
|
: id = id ?? Uuid().generateV4();
|
||||||
|
|
||||||
factory TimeProgress.initialDefault() {
|
factory TimeProgress.initialDefault() {
|
||||||
@ -23,7 +23,7 @@ class TimeProgress {
|
|||||||
TimeProgress("", DateTime.now(), DateTime.now().add(duration));
|
TimeProgress("", DateTime.now(), DateTime.now().add(duration));
|
||||||
|
|
||||||
TimeProgress copyWith(
|
TimeProgress copyWith(
|
||||||
{String id, String name, DateTime startTime, DateTime endTime}) =>
|
{String? id, String? name, DateTime? startTime, DateTime? endTime}) =>
|
||||||
TimeProgress(
|
TimeProgress(
|
||||||
name ?? this.name,
|
name ?? this.name,
|
||||||
startTime ?? this.startTime,
|
startTime ?? this.startTime,
|
||||||
@ -38,7 +38,7 @@ class TimeProgress {
|
|||||||
int allDays() => endTime.difference(startTime).inDays;
|
int allDays() => endTime.difference(startTime).inDays;
|
||||||
|
|
||||||
double percentDone() {
|
double percentDone() {
|
||||||
double percent = this.daysBehind() / (this.allDays() / 100) / 100;
|
double percent = daysBehind() / (allDays() / 100) / 100;
|
||||||
if (percent < 0) percent = 0;
|
if (percent < 0) percent = 0;
|
||||||
if (percent > 1) percent = 1;
|
if (percent > 1) percent = 1;
|
||||||
return percent;
|
return percent;
|
||||||
@ -48,7 +48,7 @@ class TimeProgress {
|
|||||||
DateTime.now().millisecondsSinceEpoch > startTime.millisecondsSinceEpoch;
|
DateTime.now().millisecondsSinceEpoch > startTime.millisecondsSinceEpoch;
|
||||||
|
|
||||||
int daysTillStart() {
|
int daysTillStart() {
|
||||||
if (hasStarted()) throw new TimeProgressHasStartedException();
|
if (hasStarted()) throw TimeProgressHasStartedException();
|
||||||
return startTime.difference(DateTime.now()).inDays;
|
return startTime.difference(DateTime.now()).inDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TimeProgress {
|
|||||||
DateTime.now().millisecondsSinceEpoch > endTime.millisecondsSinceEpoch;
|
DateTime.now().millisecondsSinceEpoch > endTime.millisecondsSinceEpoch;
|
||||||
|
|
||||||
int daysSinceEnd() {
|
int daysSinceEnd() {
|
||||||
if (!hasEnded()) throw new TimeProgressHasNotEndedException();
|
if (!hasEnded()) throw TimeProgressHasNotEndedException();
|
||||||
return DateTime.now().difference(endTime).inDays;
|
return DateTime.now().difference(endTime).inDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,24 +79,26 @@ class TimeProgress {
|
|||||||
"TimeProgress{id: $id, name: $name, startTime: $startTime, endTime: $endTime}";
|
"TimeProgress{id: $id, name: $name, startTime: $startTime, endTime: $endTime}";
|
||||||
|
|
||||||
TimeProgressEntity toEntity() {
|
TimeProgressEntity toEntity() {
|
||||||
if (!TimeProgress.isNameValid(name))
|
if (!TimeProgress.isNameValid(name)) {
|
||||||
throw new TimeProgressInvalidNameException(name);
|
throw TimeProgressInvalidNameException(name);
|
||||||
if (!TimeProgress.areTimesValid(startTime, endTime))
|
}
|
||||||
throw new TimeProgressStartTimeIsNotBeforeEndTimeException(
|
if (!TimeProgress.areTimesValid(startTime, endTime)) {
|
||||||
|
throw TimeProgressStartTimeIsNotBeforeEndTimeException(
|
||||||
startTime, endTime);
|
startTime, endTime);
|
||||||
|
}
|
||||||
return TimeProgressEntity(id, name, startTime, endTime);
|
return TimeProgressEntity(id, name, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TimeProgress fromEntity(TimeProgressEntity entity) =>
|
static TimeProgress fromEntity(TimeProgressEntity entity) =>
|
||||||
TimeProgress(entity.name, entity.startTime, entity.endTime,
|
TimeProgress(entity.name, entity.startTime, entity.endTime,
|
||||||
id: entity.id ?? Uuid().generateV4());
|
id: entity.id);
|
||||||
|
|
||||||
static bool isValid(TimeProgress tp) =>
|
static bool isValid(TimeProgress tp) =>
|
||||||
TimeProgress.isNameValid(tp.name) &&
|
TimeProgress.isNameValid(tp.name) &&
|
||||||
TimeProgress.areTimesValid(tp.startTime, tp.endTime);
|
TimeProgress.areTimesValid(tp.startTime, tp.endTime);
|
||||||
|
|
||||||
static bool isNameValid(String name) =>
|
static bool isNameValid(String name) =>
|
||||||
name != null && name != "" && name.length > 2 && name.length < 21;
|
name != "" && name.length > 2 && name.length < 21;
|
||||||
|
|
||||||
static bool areTimesValid(DateTime startTime, DateTime endTime) =>
|
static bool areTimesValid(DateTime startTime, DateTime endTime) =>
|
||||||
startTime.isBefore(endTime);
|
startTime.isBefore(endTime);
|
||||||
|
@ -11,15 +11,16 @@ class AppSettingsRepository {
|
|||||||
AppSettingsRepository(this.prefs, {this.codec = json});
|
AppSettingsRepository(this.prefs, {this.codec = json});
|
||||||
|
|
||||||
Future<AppSettingsEntity> loadAppSettings() {
|
Future<AppSettingsEntity> loadAppSettings() {
|
||||||
final String jsonString = this.prefs.getString(_key);
|
final String? jsonString = prefs.getString(_key);
|
||||||
if (jsonString == null)
|
if (jsonString == null) {
|
||||||
return Future<AppSettingsEntity>.value(AppSettingsEntity.defaults());
|
return Future<AppSettingsEntity>.value(AppSettingsEntity.defaults());
|
||||||
|
}
|
||||||
return Future<AppSettingsEntity>.value(
|
return Future<AppSettingsEntity>.value(
|
||||||
AppSettingsEntity.fromJson(codec.decode(jsonString)));
|
AppSettingsEntity.fromJson(codec.decode(jsonString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> saveAppSettings(AppSettingsEntity appSettings) =>
|
Future<bool> saveAppSettings(AppSettingsEntity appSettings) =>
|
||||||
this.prefs.setString(_key, codec.encode(appSettings));
|
prefs.setString(_key, codec.encode(appSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppSettingsEntity {
|
class AppSettingsEntity {
|
||||||
@ -52,8 +53,8 @@ class AppSettingsEntity {
|
|||||||
|
|
||||||
static AppSettingsEntity fromJson(Map<String, Object> json) =>
|
static AppSettingsEntity fromJson(Map<String, Object> json) =>
|
||||||
AppSettingsEntity(
|
AppSettingsEntity(
|
||||||
json[_doneKey],
|
json[_doneKey] as int,
|
||||||
json[_leftKey],
|
json[_leftKey] as int,
|
||||||
json[_durationDaysKey],
|
json[_durationDaysKey] as int,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class TimeProgressEntity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static TimeProgressEntity fromJson(Map<String, Object> json) {
|
static TimeProgressEntity fromJson(dynamic json) {
|
||||||
final String id = json["id"] as String;
|
final String id = json["id"] as String;
|
||||||
final String name = json["name"] as String;
|
final String name = json["name"] as String;
|
||||||
final DateTime startTime =
|
final DateTime startTime =
|
||||||
|
@ -10,13 +10,12 @@ class TimeProgressRepository {
|
|||||||
TimeProgressRepository(this.prefs, {this.codec = json});
|
TimeProgressRepository(this.prefs, {this.codec = json});
|
||||||
|
|
||||||
Future<List<TimeProgressEntity>> loadTimeProgressList() {
|
Future<List<TimeProgressEntity>> loadTimeProgressList() {
|
||||||
final String jsonString = this.prefs.getString(_key);
|
final String? jsonString = prefs.getString(_key);
|
||||||
if (jsonString == null) {
|
if (jsonString == null) {
|
||||||
return Future<List<TimeProgressEntity>>.value([]);
|
return Future<List<TimeProgressEntity>>.value([]);
|
||||||
}
|
}
|
||||||
return Future<List<TimeProgressEntity>>.value(codec
|
return Future<List<TimeProgressEntity>>.value(codec
|
||||||
.decode(jsonString)["timers"]
|
.decode(jsonString)["timers"]
|
||||||
.cast<Map<String, Object>>()
|
|
||||||
.map<TimeProgressEntity>(TimeProgressEntity.fromJson)
|
.map<TimeProgressEntity>(TimeProgressEntity.fromJson)
|
||||||
.toList(growable: false));
|
.toList(growable: false));
|
||||||
}
|
}
|
||||||
@ -24,6 +23,6 @@ class TimeProgressRepository {
|
|||||||
Future<bool> saveTimeProgressList(List<TimeProgressEntity> timeProgressList) {
|
Future<bool> saveTimeProgressList(List<TimeProgressEntity> timeProgressList) {
|
||||||
final String jsonString = codec.encode(
|
final String jsonString = codec.encode(
|
||||||
{"timers": timeProgressList.map((timer) => timer.toJson()).toList()});
|
{"timers": timeProgressList.map((timer) => timer.toJson()).toList()});
|
||||||
return this.prefs.setString(_key, jsonString);
|
return prefs.setString(_key, jsonString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ AppState appStateReducer(AppState state, dynamic action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final appSettingsReducers = combineReducers<AppSettings>([
|
final appSettingsReducers = combineReducers<AppSettings>([
|
||||||
TypedReducer<AppSettings, AppSettingsLoadedActions>(_loadAppSettings),
|
TypedReducer<AppSettings, AppSettingsLoadedActions>(_loadAppSettings).call,
|
||||||
TypedReducer<AppSettings, UpdateAppSettingsActions>(_updateAppSettings),
|
TypedReducer<AppSettings, UpdateAppSettingsActions>(_updateAppSettings).call,
|
||||||
TypedReducer<AppSettings, AppSettingsNotLoadedAction>(_setDefaultSettings)
|
TypedReducer<AppSettings, AppSettingsNotLoadedAction>(_setDefaultSettings).call
|
||||||
]);
|
]);
|
||||||
|
|
||||||
AppSettings _loadAppSettings(
|
AppSettings _loadAppSettings(
|
||||||
|
@ -2,8 +2,8 @@ import 'package:redux/redux.dart';
|
|||||||
import 'package:time_progress_tracker/actions/actions.dart';
|
import 'package:time_progress_tracker/actions/actions.dart';
|
||||||
|
|
||||||
final hasProgressesLoadedReducer = combineReducers<bool>([
|
final hasProgressesLoadedReducer = combineReducers<bool>([
|
||||||
TypedReducer<bool, TimeProgressListLoadedAction>(_setProgressesLoaded),
|
TypedReducer<bool, TimeProgressListLoadedAction>(_setProgressesLoaded).call,
|
||||||
TypedReducer<bool, TimeProgressListNotLoadedAction>(_setProgressesUnloaded)
|
TypedReducer<bool, TimeProgressListNotLoadedAction>(_setProgressesUnloaded).call
|
||||||
]);
|
]);
|
||||||
|
|
||||||
bool _setProgressesLoaded(bool hasLoaded, TimeProgressListLoadedAction action) {
|
bool _setProgressesLoaded(bool hasLoaded, TimeProgressListLoadedAction action) {
|
||||||
@ -15,8 +15,8 @@ bool _setProgressesUnloaded(bool hasLoaded, TimeProgressListNotLoadedAction acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
final hasSettingsLoadedReducer = combineReducers<bool>([
|
final hasSettingsLoadedReducer = combineReducers<bool>([
|
||||||
TypedReducer<bool, AppSettingsLoadedActions>(_setSettingsLoaded),
|
TypedReducer<bool, AppSettingsLoadedActions>(_setSettingsLoaded).call,
|
||||||
TypedReducer<bool, AppSettingsNotLoadedAction>(_setSettingsUnloaded)
|
TypedReducer<bool, AppSettingsNotLoadedAction>(_setSettingsUnloaded).call
|
||||||
]);
|
]);
|
||||||
|
|
||||||
bool _setSettingsLoaded(bool hasLoaded, AppSettingsLoadedActions action) {
|
bool _setSettingsLoaded(bool hasLoaded, AppSettingsLoadedActions action) {
|
||||||
|
@ -4,13 +4,13 @@ import 'package:time_progress_tracker/models/time_progress.dart';
|
|||||||
|
|
||||||
final timeProgressListReducer = combineReducers<List<TimeProgress>>([
|
final timeProgressListReducer = combineReducers<List<TimeProgress>>([
|
||||||
TypedReducer<List<TimeProgress>, TimeProgressListLoadedAction>(
|
TypedReducer<List<TimeProgress>, TimeProgressListLoadedAction>(
|
||||||
_setLoadedTimeProgressList),
|
_setLoadedTimeProgressList).call,
|
||||||
TypedReducer<List<TimeProgress>, TimeProgressListNotLoadedAction>(
|
TypedReducer<List<TimeProgress>, TimeProgressListNotLoadedAction>(
|
||||||
_setEmptyTimeProgressList),
|
_setEmptyTimeProgressList).call,
|
||||||
TypedReducer<List<TimeProgress>, AddTimeProgressAction>(_addTimeProgress),
|
TypedReducer<List<TimeProgress>, AddTimeProgressAction>(_addTimeProgress).call,
|
||||||
TypedReducer<List<TimeProgress>, UpdateTimeProgressAction>(
|
TypedReducer<List<TimeProgress>, UpdateTimeProgressAction>(
|
||||||
_updateTimeProgress),
|
_updateTimeProgress).call,
|
||||||
TypedReducer<List<TimeProgress>, DeleteTimeProgressAction>(_deleteTimeProgress),
|
TypedReducer<List<TimeProgress>, DeleteTimeProgressAction>(_deleteTimeProgress).call,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
List<TimeProgress> _setLoadedTimeProgressList(
|
List<TimeProgress> _setLoadedTimeProgressList(
|
||||||
|
@ -9,6 +9,8 @@ class HomeScreen extends StatefulWidget {
|
|||||||
static const routeName = "/home";
|
static const routeName = "/home";
|
||||||
static const title = "Time Progress Tracker";
|
static const title = "Time Progress Tracker";
|
||||||
|
|
||||||
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return _HomeScreenState();
|
return _HomeScreenState();
|
||||||
@ -18,9 +20,9 @@ class HomeScreen extends StatefulWidget {
|
|||||||
class _HomeScreenState extends State<HomeScreen> {
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
int _currentIndex = 0;
|
int _currentIndex = 0;
|
||||||
final List<Widget> _children = [
|
final List<Widget> _children = [
|
||||||
HomeActiveProgressesTab(),
|
const HomeActiveProgressesTab(),
|
||||||
HomeInactiveProgressesTab(),
|
const HomeInactiveProgressesTab(),
|
||||||
HomeSettingsTab(),
|
const HomeSettingsTab(),
|
||||||
];
|
];
|
||||||
|
|
||||||
void onBottomTabTapped(int index) {
|
void onBottomTabTapped(int index) {
|
||||||
@ -31,13 +33,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final ThemeData appTheme = Theme.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(HomeScreen.title),
|
title: const Text(HomeScreen.title),
|
||||||
|
backgroundColor: appTheme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
body: _children[_currentIndex],
|
body: _children[_currentIndex],
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||||
floatingActionButton: _currentIndex != 2 ? CreateProgressButton() : null,
|
floatingActionButton: _currentIndex != 2 ? const CreateProgressButton() : null,
|
||||||
bottomNavigationBar: HomeBottomNavBar(
|
bottomNavigationBar: HomeBottomNavBar(
|
||||||
currentIndex: _currentIndex,
|
currentIndex: _currentIndex,
|
||||||
onTap: onBottomTabTapped,
|
onTap: onBottomTabTapped,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:time_progress_tracker/actions/actions.dart';
|
import 'package:time_progress_tracker/actions/actions.dart';
|
||||||
@ -13,6 +12,8 @@ class ProgressCreationScreen extends StatefulWidget {
|
|||||||
static const routeName = "/create-progress";
|
static const routeName = "/create-progress";
|
||||||
static const title = "Create Time Progress";
|
static const title = "Create Time Progress";
|
||||||
|
|
||||||
|
const ProgressCreationScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return _ProgressCreationScreenState();
|
return _ProgressCreationScreenState();
|
||||||
@ -20,15 +21,16 @@ class ProgressCreationScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
|
class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
|
||||||
TimeProgress timeProgressToCreate;
|
TimeProgress? timeProgressToCreate;
|
||||||
bool _isProgressValid = false;
|
bool _isProgressValid = false;
|
||||||
|
|
||||||
void initTimeProgress(TimeProgress timeProgress) {
|
void initTimeProgress(TimeProgress timeProgress) {
|
||||||
if (timeProgressToCreate == null)
|
if (timeProgressToCreate == null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
timeProgressToCreate = timeProgress;
|
timeProgressToCreate = timeProgress;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onTimeProgressChanged(
|
void onTimeProgressChanged(
|
||||||
TimeProgress newTimeProgress, bool isNewProgressValid) {
|
TimeProgress newTimeProgress, bool isNewProgressValid) {
|
||||||
@ -40,19 +42,25 @@ class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final ThemeData appTheme = Theme.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(ProgressCreationScreen.title),
|
title: const Text(ProgressCreationScreen.title),
|
||||||
|
backgroundColor: appTheme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: StoreConnector<AppState, _ViewModel>(
|
child: StoreConnector<AppState, _ViewModel>(
|
||||||
onInit: loadSettingsIfUnloaded,
|
onInit: loadSettingsIfUnloaded,
|
||||||
converter: (store) => _ViewModel.create(store),
|
converter: (store) => _ViewModel.create(store),
|
||||||
builder: (context, _ViewModel viewModel) {
|
builder: (context, _ViewModel viewModel) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
initTimeProgress(viewModel.defaultDurationProgress);
|
initTimeProgress(viewModel.defaultDurationProgress);
|
||||||
|
});
|
||||||
return ProgressEditorWidget(
|
return ProgressEditorWidget(
|
||||||
timeProgress: timeProgressToCreate,
|
timeProgress:
|
||||||
|
timeProgressToCreate ?? viewModel.defaultDurationProgress,
|
||||||
onTimeProgressChanged: onTimeProgressChanged,
|
onTimeProgressChanged: onTimeProgressChanged,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -66,23 +74,24 @@ class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
|
|||||||
converter: (store) => _ViewModel.create(store),
|
converter: (store) => _ViewModel.create(store),
|
||||||
builder: (context, _ViewModel vm) => FloatingActionButton(
|
builder: (context, _ViewModel vm) => FloatingActionButton(
|
||||||
heroTag: "createTimeProgressBTN",
|
heroTag: "createTimeProgressBTN",
|
||||||
child: Icon(Icons.save),
|
|
||||||
onPressed: _isProgressValid
|
onPressed: _isProgressValid
|
||||||
? () {
|
? () {
|
||||||
vm.onAddTimeProgress(timeProgressToCreate);
|
vm.onAddTimeProgress(
|
||||||
|
timeProgressToCreate ?? vm.defaultDurationProgress);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
child: const Icon(Icons.save),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
heroTag: "cancelTimeProgressCreationBTN",
|
heroTag: "cancelTimeProgressCreationBTN",
|
||||||
child: Icon(Icons.cancel),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
|
child: const Icon(Icons.cancel),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -96,21 +105,21 @@ class _ViewModel {
|
|||||||
final void Function(TimeProgress) onAddTimeProgress;
|
final void Function(TimeProgress) onAddTimeProgress;
|
||||||
|
|
||||||
_ViewModel({
|
_ViewModel({
|
||||||
@required this.defaultDurationProgress,
|
required this.defaultDurationProgress,
|
||||||
@required this.onAddTimeProgress,
|
required this.onAddTimeProgress,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory _ViewModel.create(Store<AppState> store) {
|
factory _ViewModel.create(Store<AppState> store) {
|
||||||
AppSettings settings = appSettingsSelector(store.state);
|
AppSettings settings = appSettingsSelector(store.state);
|
||||||
|
|
||||||
_onAddTimeProgress(TimeProgress tp) {
|
onAddTimeProgress(TimeProgress tp) {
|
||||||
if (TimeProgress.isValid(tp)) store.dispatch(AddTimeProgressAction(tp));
|
if (TimeProgress.isValid(tp)) store.dispatch(AddTimeProgressAction(tp));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _ViewModel(
|
return _ViewModel(
|
||||||
defaultDurationProgress:
|
defaultDurationProgress:
|
||||||
TimeProgress.defaultFromDuration(settings.duration),
|
TimeProgress.defaultFromDuration(settings.duration),
|
||||||
onAddTimeProgress: _onAddTimeProgress,
|
onAddTimeProgress: onAddTimeProgress,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ class ProgressDetailScreen extends StatefulWidget {
|
|||||||
static const routeName = "/progress";
|
static const routeName = "/progress";
|
||||||
static const title = "Progress View";
|
static const title = "Progress View";
|
||||||
|
|
||||||
|
const ProgressDetailScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return _ProgressDetailScreenState();
|
return _ProgressDetailScreenState();
|
||||||
@ -25,7 +27,7 @@ class ProgressDetailScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
||||||
bool _editMode = false, _isEditedProgressValid = false;
|
bool _editMode = false, _isEditedProgressValid = false;
|
||||||
TimeProgress _editedProgress, _originalProgress;
|
TimeProgress? _editedProgress, _originalProgress;
|
||||||
|
|
||||||
void _initEditedProgress(TimeProgress tp) {
|
void _initEditedProgress(TimeProgress tp) {
|
||||||
if (_editedProgress == null) {
|
if (_editedProgress == null) {
|
||||||
@ -57,31 +59,35 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
|
|
||||||
List<Widget> _renderColumnChildren(
|
List<Widget> _renderColumnChildren(
|
||||||
SettingsViewModel settingsVm, TimeProgressViewModel tpVm) {
|
SettingsViewModel settingsVm, TimeProgressViewModel tpVm) {
|
||||||
List<Widget> columnChildren = [
|
List<Widget> columnChildren = [];
|
||||||
Expanded(
|
if (!_editMode) {
|
||||||
|
columnChildren.add(Expanded(
|
||||||
child: ProgressViewWidget(
|
child: ProgressViewWidget(
|
||||||
timeProgress: _editMode ? _editedProgress : tpVm.tp,
|
timeProgress: _editMode ? _editedProgress ?? tpVm.tp : tpVm.tp,
|
||||||
doneColor: settingsVm.appSettings.doneColor,
|
doneColor: settingsVm.appSettings.doneColor,
|
||||||
leftColor: settingsVm.appSettings.leftColor,
|
leftColor: settingsVm.appSettings.leftColor,
|
||||||
))
|
)));
|
||||||
];
|
} else {
|
||||||
if (_editMode)
|
|
||||||
columnChildren.add(Expanded(
|
columnChildren.add(Expanded(
|
||||||
child: ProgressEditorWidget(
|
child: ProgressEditorWidget(
|
||||||
timeProgress: _editedProgress,
|
timeProgress: _editedProgress ?? tpVm.tp,
|
||||||
onTimeProgressChanged: _onEditedProgressChanged,
|
onTimeProgressChanged: _onEditedProgressChanged,
|
||||||
)));
|
)));
|
||||||
|
}
|
||||||
return columnChildren;
|
return columnChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ProgressDetailScreenArguments args =
|
final ThemeData appTheme = Theme.of(context);
|
||||||
ModalRoute.of(context).settings.arguments;
|
final ProgressDetailScreenArguments args = ModalRoute.of(context)
|
||||||
|
?.settings
|
||||||
|
.arguments as ProgressDetailScreenArguments;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(ProgressDetailScreen.title),
|
title: const Text(ProgressDetailScreen.title),
|
||||||
|
backgroundColor: appTheme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
body: SettingsStoreConnector(
|
body: SettingsStoreConnector(
|
||||||
loadedBuilder: (context, settingsVm) {
|
loadedBuilder: (context, settingsVm) {
|
||||||
@ -90,10 +96,11 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
loadedBuilder: (context, tpVm) {
|
loadedBuilder: (context, tpVm) {
|
||||||
_initEditedProgress(tpVm.tp);
|
_initEditedProgress(tpVm.tp);
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.all(8),
|
margin: const EdgeInsets.all(8),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: _renderColumnChildren(settingsVm, tpVm),
|
children: _renderColumnChildren(settingsVm, tpVm),
|
||||||
));
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -102,12 +109,12 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
floatingActionButton: TimeProgressStoreConnector(
|
floatingActionButton: TimeProgressStoreConnector(
|
||||||
timeProgressId: args.id,
|
timeProgressId: args.id,
|
||||||
loadedBuilder: (context, tpVm) {
|
loadedBuilder: (context, tpVm) {
|
||||||
void _saveEditedProgress() {
|
void saveEditedProgress() {
|
||||||
tpVm.updateTimeProgress(_editedProgress);
|
tpVm.updateTimeProgress(_editedProgress ?? tpVm.tp);
|
||||||
_switchEditMode(false);
|
_switchEditMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _deleteTimeProgress() {
|
void deleteTimeProgress() {
|
||||||
tpVm.deleteTimeProgress();
|
tpVm.deleteTimeProgress();
|
||||||
Navigator.popUntil(
|
Navigator.popUntil(
|
||||||
context, ModalRoute.withName(HomeScreen.routeName));
|
context, ModalRoute.withName(HomeScreen.routeName));
|
||||||
@ -116,12 +123,12 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
return DetailScreenFloatingActionButtons(
|
return DetailScreenFloatingActionButtons(
|
||||||
editMode: _editMode,
|
editMode: _editMode,
|
||||||
originalProgress: tpVm.tp,
|
originalProgress: tpVm.tp,
|
||||||
editedProgress: _editedProgress,
|
editedProgress: _editedProgress ?? tpVm.tp,
|
||||||
isEditedProgressValid: _isEditedProgressValid,
|
isEditedProgressValid: _isEditedProgressValid,
|
||||||
onEditProgress: () => _switchEditMode(true),
|
onEditProgress: () => _switchEditMode(true),
|
||||||
onSaveEditedProgress: _saveEditedProgress,
|
onSaveEditedProgress: saveEditedProgress,
|
||||||
onCancelEditProgress: _cancelEditMode,
|
onCancelEditProgress: _cancelEditMode,
|
||||||
onDeleteProgress: _deleteTimeProgress);
|
onDeleteProgress: deleteTimeProgress);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -45,10 +45,11 @@ List<TimeProgress> pastTimeProgressesSelector(AppState state) =>
|
|||||||
DateTime.now().millisecondsSinceEpoch)
|
DateTime.now().millisecondsSinceEpoch)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
TimeProgress timeProgressByIdSelector(AppState state, String id) {
|
TimeProgress? timeProgressByIdSelector(AppState state, String id) {
|
||||||
if (state.timeProgressList.length < 1) return null;
|
if (state.timeProgressList.isEmpty) return null;
|
||||||
return state.timeProgressList
|
return state.timeProgressList.firstWhere(
|
||||||
.firstWhere((timeProgress) => timeProgress.id == id, orElse: () => null);
|
(timeProgress) => timeProgress.id == id,
|
||||||
|
orElse: () => TimeProgress.initialDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
AppSettings appSettingsSelector(AppState state) {
|
AppSettings appSettingsSelector(AppState state) {
|
||||||
|
@ -5,12 +5,12 @@ class AppYesNoDialog extends StatelessWidget {
|
|||||||
final String contentText;
|
final String contentText;
|
||||||
final void Function() onYesPressed;
|
final void Function() onYesPressed;
|
||||||
|
|
||||||
AppYesNoDialog({
|
const AppYesNoDialog({
|
||||||
Key key,
|
super.key,
|
||||||
@required this.titleText,
|
required this.titleText,
|
||||||
@required this.contentText,
|
required this.contentText,
|
||||||
@required this.onYesPressed,
|
required this.onYesPressed,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -18,15 +18,15 @@ class AppYesNoDialog extends StatelessWidget {
|
|||||||
title: Text(titleText),
|
title: Text(titleText),
|
||||||
content: Text(contentText),
|
content: Text(contentText),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
TextButton(
|
||||||
child: Text("Yes"),
|
|
||||||
onPressed: onYesPressed,
|
onPressed: onYesPressed,
|
||||||
|
child: const Text("Yes"),
|
||||||
),
|
),
|
||||||
FlatButton(
|
TextButton(
|
||||||
child: Text("No"),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
|
child: const Text("No"),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -7,11 +7,12 @@ class ColorPickerButton extends StatelessWidget {
|
|||||||
final Color selectedColor;
|
final Color selectedColor;
|
||||||
final void Function(Color) onColorPicked;
|
final void Function(Color) onColorPicked;
|
||||||
|
|
||||||
ColorPickerButton({
|
const ColorPickerButton({
|
||||||
@required this.title,
|
super.key,
|
||||||
@required this.dialogTitle,
|
required this.title,
|
||||||
@required this.selectedColor,
|
required this.dialogTitle,
|
||||||
@required this.onColorPicked,
|
required this.selectedColor,
|
||||||
|
required this.onColorPicked,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -34,13 +35,13 @@ class ColorPickerButton extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(title),
|
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
primary: useBrightBackground(selectedColor)
|
foregroundColor: useBrightBackground(selectedColor)
|
||||||
? appTheme.primaryTextTheme.button.color
|
? appTheme.primaryTextTheme.labelLarge?.color
|
||||||
: appTheme.textTheme.button.color,
|
: appTheme.textTheme.labelLarge?.color,
|
||||||
backgroundColor: selectedColor,
|
backgroundColor: selectedColor,
|
||||||
),
|
),
|
||||||
|
child: Text(title),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,17 @@ import 'package:time_progress_tracker/screens/progress_creation_screen.dart';
|
|||||||
class CreateProgressButton extends StatelessWidget {
|
class CreateProgressButton extends StatelessWidget {
|
||||||
final String _heroTag = "createProgressBTN";
|
final String _heroTag = "createProgressBTN";
|
||||||
|
|
||||||
|
const CreateProgressButton({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
void _onButtonPressed() =>
|
void onButtonPressed() =>
|
||||||
Navigator.pushNamed(context, ProgressCreationScreen.routeName);
|
Navigator.pushNamed(context, ProgressCreationScreen.routeName);
|
||||||
|
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
heroTag: _heroTag,
|
heroTag: _heroTag,
|
||||||
child: Icon(Icons.add),
|
onPressed: onButtonPressed,
|
||||||
onPressed: _onButtonPressed,
|
child: const Icon(Icons.add),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@ import 'package:flutter/material.dart';
|
|||||||
class DatePickerBtn extends StatelessWidget {
|
class DatePickerBtn extends StatelessWidget {
|
||||||
final String leadingString;
|
final String leadingString;
|
||||||
final DateTime pickedDate;
|
final DateTime pickedDate;
|
||||||
final void Function(DateTime) onDatePicked;
|
final void Function(DateTime?) onDatePicked;
|
||||||
|
|
||||||
DatePickerBtn({
|
const DatePickerBtn({
|
||||||
@required this.leadingString,
|
super.key,
|
||||||
@required this.pickedDate,
|
required this.leadingString,
|
||||||
@required this.onDatePicked,
|
required this.pickedDate,
|
||||||
}) : super();
|
required this.onDatePicked,
|
||||||
|
});
|
||||||
|
|
||||||
void _onButtonPressed(BuildContext context) async {
|
void _onButtonPressed(BuildContext context) async {
|
||||||
onDatePicked(await showDatePicker(
|
onDatePicked(await showDatePicker(
|
||||||
@ -25,12 +26,12 @@ class DatePickerBtn extends StatelessWidget {
|
|||||||
ThemeData appTheme = Theme.of(context);
|
ThemeData appTheme = Theme.of(context);
|
||||||
return TextButton(
|
return TextButton(
|
||||||
onPressed: () => _onButtonPressed(context),
|
onPressed: () => _onButtonPressed(context),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: appTheme.primaryTextTheme.labelLarge?.color,
|
||||||
|
backgroundColor: appTheme.colorScheme.secondary,
|
||||||
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"$leadingString ${pickedDate.toLocal().toString().split(" ")[0]}"),
|
"$leadingString ${pickedDate.toLocal().toString().split(" ")[0]}"),
|
||||||
style: TextButton.styleFrom(
|
|
||||||
primary: appTheme.primaryTextTheme.button.color,
|
|
||||||
backgroundColor: appTheme.accentColor,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,10 @@ class SelectDurationBtn extends StatelessWidget {
|
|||||||
final Duration duration;
|
final Duration duration;
|
||||||
final void Function(Duration) updateDuration;
|
final void Function(Duration) updateDuration;
|
||||||
|
|
||||||
SelectDurationBtn({
|
const SelectDurationBtn({
|
||||||
@required this.duration,
|
super.key,
|
||||||
@required this.updateDuration,
|
required this.duration,
|
||||||
|
required this.updateDuration,
|
||||||
});
|
});
|
||||||
|
|
||||||
void _onPickerConfirm(Picker picker, List<int> values) {
|
void _onPickerConfirm(Picker picker, List<int> values) {
|
||||||
@ -25,7 +26,7 @@ class SelectDurationBtn extends StatelessWidget {
|
|||||||
]),
|
]),
|
||||||
hideHeader: false,
|
hideHeader: false,
|
||||||
title: const Text("Default Duration"),
|
title: const Text("Default Duration"),
|
||||||
selectedTextStyle: TextStyle(color: appTheme.accentColor),
|
selectedTextStyle: TextStyle(color: appTheme.colorScheme.secondary),
|
||||||
onConfirm: _onPickerConfirm)
|
onConfirm: _onPickerConfirm)
|
||||||
.showModal(context);
|
.showModal(context);
|
||||||
|
|
||||||
@ -38,10 +39,10 @@ class SelectDurationBtn extends StatelessWidget {
|
|||||||
int days = duration.inDays - (365 * years) - (30 * months);
|
int days = duration.inDays - (365 * years) - (30 * months);
|
||||||
return TextButton(
|
return TextButton(
|
||||||
onPressed: () => _onButtonPressed(context, appTheme),
|
onPressed: () => _onButtonPressed(context, appTheme),
|
||||||
child: Text("$years Years $months Months $days Days"),
|
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
primary: appTheme.primaryTextTheme.button.color,
|
foregroundColor: appTheme.primaryTextTheme.labelLarge?.color,
|
||||||
backgroundColor: appTheme.accentColor,
|
backgroundColor: appTheme.colorScheme.secondary,
|
||||||
));
|
),
|
||||||
|
child: Text("$years Years $months Months $days Days"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,26 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
|||||||
onCancelEditProgress,
|
onCancelEditProgress,
|
||||||
onDeleteProgress;
|
onDeleteProgress;
|
||||||
|
|
||||||
DetailScreenFloatingActionButtons({
|
const DetailScreenFloatingActionButtons({
|
||||||
@required this.editMode,
|
super.key,
|
||||||
@required this.originalProgress,
|
required this.editMode,
|
||||||
@required this.editedProgress,
|
required this.originalProgress,
|
||||||
@required this.isEditedProgressValid,
|
required this.editedProgress,
|
||||||
@required this.onEditProgress,
|
required this.isEditedProgressValid,
|
||||||
@required this.onSaveEditedProgress,
|
required this.onEditProgress,
|
||||||
@required this.onCancelEditProgress,
|
required this.onSaveEditedProgress,
|
||||||
@required this.onDeleteProgress,
|
required this.onCancelEditProgress,
|
||||||
|
required this.onDeleteProgress,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ThemeData appTheme = Theme.of(context);
|
final ThemeData appTheme = Theme.of(context);
|
||||||
|
|
||||||
void _onCancelEditTimeProgressBTN() {
|
void onCancelEditTimeProgressBTN() {
|
||||||
if (originalProgress == editedProgress)
|
if (originalProgress == editedProgress) {
|
||||||
onCancelEditProgress();
|
onCancelEditProgress();
|
||||||
else {
|
} else {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => AppYesNoDialog(
|
builder: (_) => AppYesNoDialog(
|
||||||
@ -44,7 +45,7 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDeleteTimeProgressBTN() {
|
void onDeleteTimeProgressBTN() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => AppYesNoDialog(
|
builder: (_) => AppYesNoDialog(
|
||||||
@ -61,13 +62,13 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
|||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
heroTag:
|
heroTag:
|
||||||
editMode ? "saveEditedTimeProgressBTN" : "editTimeProgressBTN",
|
editMode ? "saveEditedTimeProgressBTN" : "editTimeProgressBTN",
|
||||||
child: editMode ? Icon(Icons.save) : Icon(Icons.edit),
|
backgroundColor: editMode ? Colors.green : appTheme.colorScheme.secondary,
|
||||||
backgroundColor: editMode ? Colors.green : appTheme.accentColor,
|
|
||||||
onPressed: editMode
|
onPressed: editMode
|
||||||
? isEditedProgressValid
|
? isEditedProgressValid
|
||||||
? onSaveEditedProgress
|
? onSaveEditedProgress
|
||||||
: null
|
: null
|
||||||
: onEditProgress,
|
: onEditProgress,
|
||||||
|
child: editMode ? const Icon(Icons.save) : const Icon(Icons.edit),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -75,11 +76,11 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
|||||||
heroTag: editMode
|
heroTag: editMode
|
||||||
? "cancelEditTimeProgressBTN"
|
? "cancelEditTimeProgressBTN"
|
||||||
: "deleteTimeProgressBTN",
|
: "deleteTimeProgressBTN",
|
||||||
child: editMode ? Icon(Icons.cancel) : Icon(Icons.delete),
|
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
onPressed: editMode
|
onPressed: editMode
|
||||||
? _onCancelEditTimeProgressBTN
|
? onCancelEditTimeProgressBTN
|
||||||
: _onDeleteTimeProgressBTN,
|
: onDeleteTimeProgressBTN,
|
||||||
|
child: editMode ? const Icon(Icons.cancel) : const Icon(Icons.delete),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -2,13 +2,13 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
class HomeBottomNavBar extends StatelessWidget {
|
class HomeBottomNavBar extends StatelessWidget {
|
||||||
final int currentIndex;
|
final int currentIndex;
|
||||||
final Function onTap;
|
final void Function(int)? onTap;
|
||||||
|
|
||||||
HomeBottomNavBar({
|
const HomeBottomNavBar({
|
||||||
Key key,
|
super.key,
|
||||||
@required this.currentIndex,
|
required this.currentIndex,
|
||||||
@required this.onTap,
|
required this.onTap,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -19,21 +19,21 @@ class HomeBottomNavBar extends StatelessWidget {
|
|||||||
currentIndex: currentIndex,
|
currentIndex: currentIndex,
|
||||||
items: [
|
items: [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: new Icon(
|
icon: Icon(
|
||||||
Icons.alarm,
|
Icons.alarm,
|
||||||
color: appTheme.primaryColor,
|
color: appTheme.primaryColor,
|
||||||
),
|
),
|
||||||
label: "Active Progresses",
|
label: "Active Progresses",
|
||||||
),
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: new Icon(
|
icon: Icon(
|
||||||
Icons.alarm_off,
|
Icons.alarm_off,
|
||||||
color: appTheme.primaryColor,
|
color: appTheme.primaryColor,
|
||||||
),
|
),
|
||||||
label: "Inactive Progresses",
|
label: "Inactive Progresses",
|
||||||
),
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: new Icon(
|
icon: Icon(
|
||||||
Icons.settings,
|
Icons.settings,
|
||||||
color: appTheme.primaryColor,
|
color: appTheme.primaryColor,
|
||||||
),
|
),
|
||||||
|
@ -6,6 +6,8 @@ import 'package:time_progress_tracker/widgets/store_connectors/settings_store_co
|
|||||||
import 'package:time_progress_tracker/widgets/store_connectors/time_progress_list_store_connector.dart';
|
import 'package:time_progress_tracker/widgets/store_connectors/time_progress_list_store_connector.dart';
|
||||||
|
|
||||||
class HomeActiveProgressesTab extends StatelessWidget {
|
class HomeActiveProgressesTab extends StatelessWidget {
|
||||||
|
const HomeActiveProgressesTab({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SettingsStoreConnector(
|
return SettingsStoreConnector(
|
||||||
@ -14,14 +16,15 @@ class HomeActiveProgressesTab extends StatelessWidget {
|
|||||||
loadedBuilder: (context, tpListVm) {
|
loadedBuilder: (context, tpListVm) {
|
||||||
List<TimeProgress> activeTpList =
|
List<TimeProgress> activeTpList =
|
||||||
selectActiveProgresses(tpListVm.tpList);
|
selectActiveProgresses(tpListVm.tpList);
|
||||||
if (activeTpList.length < 1)
|
if (activeTpList.isEmpty) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Center(
|
child: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"You don't have any active time progress, that are tracked."),
|
"You don't have any active time progress, that are tracked."),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return ProgressListView(
|
return ProgressListView(
|
||||||
timeProgressList: activeTpList,
|
timeProgressList: activeTpList,
|
||||||
|
@ -6,6 +6,8 @@ import 'package:time_progress_tracker/widgets/store_connectors/settings_store_co
|
|||||||
import 'package:time_progress_tracker/widgets/store_connectors/time_progress_list_store_connector.dart';
|
import 'package:time_progress_tracker/widgets/store_connectors/time_progress_list_store_connector.dart';
|
||||||
|
|
||||||
class HomeInactiveProgressesTab extends StatelessWidget {
|
class HomeInactiveProgressesTab extends StatelessWidget {
|
||||||
|
const HomeInactiveProgressesTab({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SettingsStoreConnector(
|
return SettingsStoreConnector(
|
||||||
@ -14,14 +16,15 @@ class HomeInactiveProgressesTab extends StatelessWidget {
|
|||||||
loadedBuilder: (context, tpListVm) {
|
loadedBuilder: (context, tpListVm) {
|
||||||
List<TimeProgress> inactiveTpList =
|
List<TimeProgress> inactiveTpList =
|
||||||
selectInactiveProgresses(tpListVm.tpList);
|
selectInactiveProgresses(tpListVm.tpList);
|
||||||
if (inactiveTpList.length < 1)
|
if (inactiveTpList.isEmpty) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Center(
|
child: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"You don't have any currently inactive time progresses, that are tracked."),
|
"You don't have any currently inactive time progresses, that are tracked."),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return ProgressListView(
|
return ProgressListView(
|
||||||
timeProgressList: inactiveTpList,
|
timeProgressList: inactiveTpList,
|
||||||
|
@ -5,12 +5,14 @@ import 'package:time_progress_tracker/widgets/home/tabs/settings/duration_settin
|
|||||||
import 'package:time_progress_tracker/widgets/store_connectors/settings_store_connector.dart';
|
import 'package:time_progress_tracker/widgets/store_connectors/settings_store_connector.dart';
|
||||||
|
|
||||||
class HomeSettingsTab extends StatelessWidget {
|
class HomeSettingsTab extends StatelessWidget {
|
||||||
|
const HomeSettingsTab({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SettingsStoreConnector(
|
return SettingsStoreConnector(
|
||||||
loadedBuilder: (context, settingsVm) {
|
loadedBuilder: (context, settingsVm) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -28,7 +30,7 @@ class HomeSettingsTab extends StatelessWidget {
|
|||||||
updateDuration: settingsVm.updateDuration,
|
updateDuration: settingsVm.updateDuration,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Spacer(),
|
const Spacer(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -39,7 +41,7 @@ class HomeSettingsTab extends StatelessWidget {
|
|||||||
applicationLegalese:
|
applicationLegalese:
|
||||||
'\u00a9Andreas Fahrecker 2020-2021');
|
'\u00a9Andreas Fahrecker 2020-2021');
|
||||||
},
|
},
|
||||||
child: Text("About"),
|
child: const Text("About"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -5,11 +5,12 @@ class ColorSettingsWidget extends StatelessWidget {
|
|||||||
final Color doneColor, leftColor;
|
final Color doneColor, leftColor;
|
||||||
final void Function(Color) updateDoneColor, updateLeftColor;
|
final void Function(Color) updateDoneColor, updateLeftColor;
|
||||||
|
|
||||||
ColorSettingsWidget({
|
const ColorSettingsWidget({
|
||||||
@required this.doneColor,
|
super.key,
|
||||||
@required this.leftColor,
|
required this.doneColor,
|
||||||
@required this.updateDoneColor,
|
required this.leftColor,
|
||||||
@required this.updateLeftColor,
|
required this.updateDoneColor,
|
||||||
|
required this.updateLeftColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -21,14 +22,14 @@ class ColorSettingsWidget extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Color Settings",
|
"Color Settings",
|
||||||
style: appTheme.textTheme.headline6,
|
style: appTheme.textTheme.titleLarge,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(right: 5),
|
padding: const EdgeInsets.only(right: 5),
|
||||||
child: ColorPickerButton(
|
child: ColorPickerButton(
|
||||||
title: "Done Color",
|
title: "Done Color",
|
||||||
dialogTitle: "Select Done Color",
|
dialogTitle: "Select Done Color",
|
||||||
@ -39,7 +40,7 @@ class ColorSettingsWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(left: 5),
|
padding: const EdgeInsets.only(left: 5),
|
||||||
child: ColorPickerButton(
|
child: ColorPickerButton(
|
||||||
title: "Left Color",
|
title: "Left Color",
|
||||||
dialogTitle: "Select Left Color",
|
dialogTitle: "Select Left Color",
|
||||||
|
@ -5,24 +5,25 @@ class DurationSettingsWidget extends StatelessWidget {
|
|||||||
final Duration duration;
|
final Duration duration;
|
||||||
final void Function(Duration) updateDuration;
|
final void Function(Duration) updateDuration;
|
||||||
|
|
||||||
DurationSettingsWidget({
|
const DurationSettingsWidget({
|
||||||
@required this.duration,
|
super.key,
|
||||||
@required this.updateDuration,
|
required this.duration,
|
||||||
|
required this.updateDuration,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
ThemeData appTheme = Theme.of(context);
|
ThemeData appTheme = Theme.of(context);
|
||||||
|
|
||||||
int years = duration.inDays ~/ 365;
|
//int years = duration.inDays ~/ 365;
|
||||||
int months = (duration.inDays - (365 * years)) ~/ 30;
|
//int months = (duration.inDays - (365 * years)) ~/ 30;
|
||||||
int days = duration.inDays - (365 * years) - (30 * months);
|
//int days = duration.inDays - (365 * years) - (30 * months);
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Duration Settings",
|
"Duration Settings",
|
||||||
style: appTheme.textTheme.headline6,
|
style: appTheme.textTheme.titleLarge,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||||
import 'package:time_progress_tracker/widgets/buttons/date_picker_btn.dart';
|
import 'package:time_progress_tracker/widgets/buttons/date_picker_btn.dart';
|
||||||
|
|
||||||
@ -6,9 +7,10 @@ class ProgressEditorWidget extends StatefulWidget {
|
|||||||
final TimeProgress timeProgress;
|
final TimeProgress timeProgress;
|
||||||
final Function(TimeProgress, bool) onTimeProgressChanged;
|
final Function(TimeProgress, bool) onTimeProgressChanged;
|
||||||
|
|
||||||
ProgressEditorWidget({
|
const ProgressEditorWidget({
|
||||||
@required this.timeProgress,
|
super.key,
|
||||||
@required this.onTimeProgressChanged,
|
required this.timeProgress,
|
||||||
|
required this.onTimeProgressChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -31,7 +33,10 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onStartDateChanged(DateTime newStartDate) {
|
void _onStartDateChanged(DateTime? newStartDate) {
|
||||||
|
if (newStartDate == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TimeProgress newProgress =
|
TimeProgress newProgress =
|
||||||
widget.timeProgress.copyWith(startTime: newStartDate);
|
widget.timeProgress.copyWith(startTime: newStartDate);
|
||||||
widget.onTimeProgressChanged(
|
widget.onTimeProgressChanged(
|
||||||
@ -42,7 +47,10 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onEndDateChanged(DateTime newEndDate) {
|
void _onEndDateChanged(DateTime? newEndDate) {
|
||||||
|
if (newEndDate == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TimeProgress newProgress =
|
TimeProgress newProgress =
|
||||||
widget.timeProgress.copyWith(endTime: newEndDate);
|
widget.timeProgress.copyWith(endTime: newEndDate);
|
||||||
widget.onTimeProgressChanged(
|
widget.onTimeProgressChanged(
|
||||||
@ -62,12 +70,15 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
double heightFactor = (!_validDate) ? 0.3 : 0.5;
|
||||||
|
|
||||||
List<Widget> columnChildren = [
|
List<Widget> columnChildren = [
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * heightFactor,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _nameTextController,
|
controller: _nameTextController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
labelText: "Progress Name",
|
labelText: "Progress Name",
|
||||||
errorText: _validName
|
errorText: _validName
|
||||||
? null
|
? null
|
||||||
@ -75,12 +86,13 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * heightFactor,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(right: 5),
|
padding: const EdgeInsets.only(right: 5),
|
||||||
child: DatePickerBtn(
|
child: DatePickerBtn(
|
||||||
leadingString: "Start Date:",
|
leadingString: "Start Date:",
|
||||||
pickedDate: widget.timeProgress.startTime,
|
pickedDate: widget.timeProgress.startTime,
|
||||||
@ -90,7 +102,7 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(left: 5),
|
padding: const EdgeInsets.only(left: 5),
|
||||||
child: DatePickerBtn(
|
child: DatePickerBtn(
|
||||||
leadingString: "End Date:",
|
leadingString: "End Date:",
|
||||||
pickedDate: widget.timeProgress.endTime,
|
pickedDate: widget.timeProgress.endTime,
|
||||||
@ -103,10 +115,11 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!_validDate)
|
if (!_validDate) {
|
||||||
columnChildren.add(
|
columnChildren.add(
|
||||||
Expanded(
|
SizedBox(
|
||||||
child: Center(
|
height: MediaQuery.of(context).size.height * heightFactor,
|
||||||
|
child: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Invalid Dates. The Start Date has to be before the End Date",
|
"Invalid Dates. The Start Date has to be before the End Date",
|
||||||
style: TextStyle(color: Colors.red),
|
style: TextStyle(color: Colors.red),
|
||||||
@ -114,8 +127,10 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Container(
|
return SingleChildScrollView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: columnChildren,
|
children: columnChildren,
|
||||||
),
|
),
|
||||||
|
@ -18,17 +18,19 @@ class ProgressListTile extends StatelessWidget {
|
|||||||
final TimeProgress timeProgress;
|
final TimeProgress timeProgress;
|
||||||
final Color doneColor, leftColor;
|
final Color doneColor, leftColor;
|
||||||
|
|
||||||
ProgressListTile({
|
const ProgressListTile({super.key,
|
||||||
@required this.timeProgress,
|
required this.timeProgress,
|
||||||
@required this.doneColor,
|
required this.doneColor,
|
||||||
@required this.leftColor,
|
required this.leftColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
Widget _renderSubtitle(BuildContext context) {
|
Widget _renderSubtitle(BuildContext context) {
|
||||||
if (!timeProgress.hasStarted())
|
if (!timeProgress.hasStarted()) {
|
||||||
return Text(ProgressListTileStrings.startsInDaysString(timeProgress));
|
return Text(ProgressListTileStrings.startsInDaysString(timeProgress));
|
||||||
if (timeProgress.hasEnded())
|
}
|
||||||
|
if (timeProgress.hasEnded()) {
|
||||||
return Text(ProgressListTileStrings.endedDaysAgoString(timeProgress));
|
return Text(ProgressListTileStrings.endedDaysAgoString(timeProgress));
|
||||||
|
}
|
||||||
return LinearPercentIndicator(
|
return LinearPercentIndicator(
|
||||||
center: Text(ProgressListTileStrings.percentString(timeProgress)),
|
center: Text(ProgressListTileStrings.percentString(timeProgress)),
|
||||||
percent: timeProgress.percentDone(),
|
percent: timeProgress.percentDone(),
|
||||||
@ -40,14 +42,14 @@ class ProgressListTile extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
void _onTileTap() =>
|
void onTileTap() =>
|
||||||
Navigator.pushNamed(context, ProgressDetailScreen.routeName,
|
Navigator.pushNamed(context, ProgressDetailScreen.routeName,
|
||||||
arguments: ProgressDetailScreenArguments(timeProgress.id));
|
arguments: ProgressDetailScreenArguments(timeProgress.id));
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(timeProgress.name),
|
title: Text(timeProgress.name),
|
||||||
subtitle: _renderSubtitle(context),
|
subtitle: _renderSubtitle(context),
|
||||||
onTap: _onTileTap,
|
onTap: onTileTap,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,11 @@ class ProgressListView extends StatelessWidget {
|
|||||||
final List<TimeProgress> timeProgressList;
|
final List<TimeProgress> timeProgressList;
|
||||||
final Color doneColor, leftColor;
|
final Color doneColor, leftColor;
|
||||||
|
|
||||||
ProgressListView({
|
const ProgressListView({
|
||||||
@required this.timeProgressList,
|
super.key,
|
||||||
@required this.doneColor,
|
required this.timeProgressList,
|
||||||
@required this.leftColor,
|
required this.doneColor,
|
||||||
|
required this.leftColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
List<Widget> _renderListViewChildren() {
|
List<Widget> _renderListViewChildren() {
|
||||||
@ -27,7 +28,7 @@ class ProgressListView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
children: _renderListViewChildren(),
|
children: _renderListViewChildren(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,31 +8,37 @@ class ProgressViewWidget extends StatelessWidget {
|
|||||||
final Color doneColor;
|
final Color doneColor;
|
||||||
final Color leftColor;
|
final Color leftColor;
|
||||||
|
|
||||||
ProgressViewWidget({
|
const ProgressViewWidget({
|
||||||
@required this.timeProgress,
|
super.key,
|
||||||
@required this.doneColor,
|
required this.timeProgress,
|
||||||
@required this.leftColor,
|
required this.doneColor,
|
||||||
|
required this.leftColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return SingleChildScrollView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height *
|
||||||
|
0.3, // adjust the value as needed
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.fitWidth,
|
fit: BoxFit.fitWidth,
|
||||||
child: Text(
|
child: Text(
|
||||||
timeProgress.name,
|
timeProgress.name,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.black87,
|
color: Colors.black87,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height *
|
||||||
|
0.3, // adjust the value as needed
|
||||||
child: CircularPercentIndicator(
|
child: CircularPercentIndicator(
|
||||||
radius: 100,
|
radius: 100,
|
||||||
lineWidth: 10,
|
lineWidth: 10,
|
||||||
@ -42,14 +48,16 @@ class ProgressViewWidget extends StatelessWidget {
|
|||||||
center: Text("${(timeProgress.percentDone() * 100).floor()} %"),
|
center: Text("${(timeProgress.percentDone() * 100).floor()} %"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height *
|
||||||
|
0.3, // adjust the value as needed
|
||||||
child: LinearPercentIndicator(
|
child: LinearPercentIndicator(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
percent: timeProgress.percentDone(),
|
percent: timeProgress.percentDone(),
|
||||||
leading: Text("${timeProgress.daysBehind()} Days"),
|
leading: Text("${timeProgress.daysBehind()} Days"),
|
||||||
center: Text(
|
center: Text(
|
||||||
"${(timeProgress.percentDone() * 100).floor()} %",
|
"${(timeProgress.percentDone() * 100).floor()} %",
|
||||||
style: TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
trailing: Text("${timeProgress.daysLeft()} Days"),
|
trailing: Text("${timeProgress.daysLeft()} Days"),
|
||||||
progressColor: doneColor,
|
progressColor: doneColor,
|
||||||
|
@ -8,8 +8,9 @@ import 'package:time_progress_tracker/models/app_state.dart';
|
|||||||
class SettingsStoreConnector extends StatelessWidget {
|
class SettingsStoreConnector extends StatelessWidget {
|
||||||
final Widget Function(BuildContext, SettingsViewModel) loadedBuilder;
|
final Widget Function(BuildContext, SettingsViewModel) loadedBuilder;
|
||||||
|
|
||||||
SettingsStoreConnector({
|
const SettingsStoreConnector({
|
||||||
@required this.loadedBuilder,
|
super.key,
|
||||||
|
required this.loadedBuilder,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -18,10 +19,11 @@ class SettingsStoreConnector extends StatelessWidget {
|
|||||||
onInit: loadSettingsIfUnloaded,
|
onInit: loadSettingsIfUnloaded,
|
||||||
converter: (store) => SettingsViewModel._create(store),
|
converter: (store) => SettingsViewModel._create(store),
|
||||||
builder: (context, SettingsViewModel vm) {
|
builder: (context, SettingsViewModel vm) {
|
||||||
if (!vm.hasSettingsLoaded)
|
if (!vm.hasSettingsLoaded) {
|
||||||
return Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return loadedBuilder(context, vm);
|
return loadedBuilder(context, vm);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -44,17 +46,17 @@ class SettingsViewModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
factory SettingsViewModel._create(Store<AppState> store) {
|
factory SettingsViewModel._create(Store<AppState> store) {
|
||||||
AppSettings _appSettings = store.state.appSettings;
|
AppSettings appSettings = store.state.appSettings;
|
||||||
|
|
||||||
void _updateDoneColor(Color dC) => store.dispatch(
|
void updateDoneColor(Color dC) => store.dispatch(
|
||||||
UpdateAppSettingsActions(_appSettings.copyWith(doneColor: dC)));
|
UpdateAppSettingsActions(appSettings.copyWith(doneColor: dC)));
|
||||||
void _updateLeftColor(Color lC) => store.dispatch(
|
void updateLeftColor(Color lC) => store.dispatch(
|
||||||
UpdateAppSettingsActions(_appSettings.copyWith(leftColor: lC)));
|
UpdateAppSettingsActions(appSettings.copyWith(leftColor: lC)));
|
||||||
|
|
||||||
void _updateDuration(Duration d) => store
|
void updateDuration(Duration d) => store
|
||||||
.dispatch(UpdateAppSettingsActions(_appSettings.copyWith(duration: d)));
|
.dispatch(UpdateAppSettingsActions(appSettings.copyWith(duration: d)));
|
||||||
|
|
||||||
return SettingsViewModel(_appSettings, store.state.hasSettingsLoaded,
|
return SettingsViewModel(appSettings, store.state.hasSettingsLoaded,
|
||||||
_updateDoneColor, _updateLeftColor, _updateDuration);
|
updateDoneColor, updateLeftColor, updateDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ import 'package:time_progress_tracker/models/time_progress.dart';
|
|||||||
class TimeProgressListStoreConnector extends StatelessWidget {
|
class TimeProgressListStoreConnector extends StatelessWidget {
|
||||||
final Widget Function(BuildContext, TimeProgressListViewModel) loadedBuilder;
|
final Widget Function(BuildContext, TimeProgressListViewModel) loadedBuilder;
|
||||||
|
|
||||||
TimeProgressListStoreConnector({
|
const TimeProgressListStoreConnector({
|
||||||
@required this.loadedBuilder,
|
super.key,
|
||||||
|
required this.loadedBuilder,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -18,10 +19,11 @@ class TimeProgressListStoreConnector extends StatelessWidget {
|
|||||||
onInit: loadTimeProgressListIfUnloaded,
|
onInit: loadTimeProgressListIfUnloaded,
|
||||||
converter: (store) => TimeProgressListViewModel._create(store),
|
converter: (store) => TimeProgressListViewModel._create(store),
|
||||||
builder: (context, TimeProgressListViewModel vm) {
|
builder: (context, TimeProgressListViewModel vm) {
|
||||||
if (!vm.hasTpListLoaded)
|
if (!vm.hasTpListLoaded) {
|
||||||
return Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return loadedBuilder(context, vm);
|
return loadedBuilder(context, vm);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -11,9 +11,10 @@ class TimeProgressStoreConnector extends StatelessWidget {
|
|||||||
final String timeProgressId;
|
final String timeProgressId;
|
||||||
final Widget Function(BuildContext, TimeProgressViewModel) loadedBuilder;
|
final Widget Function(BuildContext, TimeProgressViewModel) loadedBuilder;
|
||||||
|
|
||||||
TimeProgressStoreConnector({
|
const TimeProgressStoreConnector({
|
||||||
@required this.timeProgressId,
|
super.key,
|
||||||
@required this.loadedBuilder,
|
required this.timeProgressId,
|
||||||
|
required this.loadedBuilder,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -23,14 +24,11 @@ class TimeProgressStoreConnector extends StatelessWidget {
|
|||||||
converter: (store) =>
|
converter: (store) =>
|
||||||
TimeProgressViewModel._create(store, timeProgressId),
|
TimeProgressViewModel._create(store, timeProgressId),
|
||||||
builder: (context, TimeProgressViewModel vm) {
|
builder: (context, TimeProgressViewModel vm) {
|
||||||
if (!vm.hasTpListLoaded)
|
if (!vm.hasTpListLoaded) {
|
||||||
return Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
if (vm.tp == null)
|
}
|
||||||
return Center(
|
|
||||||
child: Text("Error Invalid Time Progress"),
|
|
||||||
);
|
|
||||||
return loadedBuilder(context, vm);
|
return loadedBuilder(context, vm);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -52,15 +50,15 @@ class TimeProgressViewModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
factory TimeProgressViewModel._create(Store<AppState> store, String id) {
|
factory TimeProgressViewModel._create(Store<AppState> store, String id) {
|
||||||
void _updateTimeProgress(TimeProgress tp) =>
|
void updateTimeProgress(TimeProgress tp) =>
|
||||||
store.dispatch(UpdateTimeProgressAction(id, tp));
|
store.dispatch(UpdateTimeProgressAction(id, tp));
|
||||||
void _deleteTimeProgress() => store.dispatch(DeleteTimeProgressAction(id));
|
void deleteTimeProgress() => store.dispatch(DeleteTimeProgressAction(id));
|
||||||
|
|
||||||
return TimeProgressViewModel(
|
return TimeProgressViewModel(
|
||||||
selectProgressById(store.state.timeProgressList, id),
|
selectProgressById(store.state.timeProgressList, id),
|
||||||
store.state.hasProgressesLoaded,
|
store.state.hasProgressesLoaded,
|
||||||
_updateTimeProgress,
|
updateTimeProgress,
|
||||||
_deleteTimeProgress,
|
deleteTimeProgress,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
106
pubspec.lock
106
pubspec.lock
@ -109,18 +109,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: d97fffd9d86f3dccc7a9059128b468a99320c69007cc9d41a3a1bda07d4e86dc
|
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "2.1.2"
|
||||||
file:
|
file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: file
|
name: file
|
||||||
sha256: "9fd2163d866769f60f4df8ac1dc59f52498d810c356fe78022e383dd3c57c0e1"
|
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.0"
|
version: "7.0.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -189,10 +189,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: js
|
name: js
|
||||||
sha256: d9bdfd70d828eeb352390f81b18d6a354ef2044aa28ef25682079797fa7cd174
|
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.3"
|
version: "0.7.1"
|
||||||
json_annotation:
|
json_annotation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -269,26 +269,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_linux
|
name: path_provider_linux
|
||||||
sha256: "938d2b6591587bcb009d2109a6ea464fd8fb2a75dc6423171b0d0afb1d27c708"
|
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.2.1"
|
||||||
path_provider_platform_interface:
|
path_provider_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_platform_interface
|
name: path_provider_platform_interface
|
||||||
sha256: "2e14fc474b8acfc4111ac8eb0e37c2fe70234f9f8cd796f1560d03aa1689fa51"
|
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.2"
|
||||||
path_provider_windows:
|
path_provider_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_windows
|
name: path_provider_windows
|
||||||
sha256: ecd4d04c225596bcf0fbb86408a1f40084a02dfa412e60172ad52a7f12a781ef
|
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.2.1"
|
||||||
percent_indicator:
|
percent_indicator:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -309,18 +309,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: platform
|
name: platform
|
||||||
sha256: ebc79f16b5f6b609aad4a5e63447d4795d16f7adee46e93ed03200848c006735
|
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0"
|
version: "3.1.4"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
sha256: c2c49e16d42fd6983eb55e44b7f197fdf16b4da7aab7f8e1d21da307cad3fb02
|
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.8"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -329,14 +329,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.7.4"
|
version: "3.7.4"
|
||||||
process:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: process
|
|
||||||
sha256: c7b9f7d8a6ee4407ab4f8a7d4a951f8f5659c40df14c0924e2e97c32372e9b14
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.1.0"
|
|
||||||
redux:
|
redux:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -349,50 +341,58 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: shared_preferences
|
name: shared_preferences
|
||||||
sha256: "2ead304936605c686c0c1a5ce3d9771dbc2e60d76db68b9cd313eb860ca8f9e3"
|
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.2.2"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.5"
|
||||||
shared_preferences_linux:
|
shared_preferences_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_linux
|
name: shared_preferences_linux
|
||||||
sha256: "33fc7c6ced70d226645a9612132fbff9890805df4edd34f30840e7e738866fee"
|
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.3.2"
|
||||||
shared_preferences_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_macos
|
|
||||||
sha256: "5d2bad07b196b6ad4cf21af6f7197a87264ef569199502b9352f76e5054f06ae"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0"
|
|
||||||
shared_preferences_platform_interface:
|
shared_preferences_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_platform_interface
|
name: shared_preferences_platform_interface
|
||||||
sha256: "992f0fdc46d0a3c0ac2e5859f2de0e577bbe51f78a77ee8f357cbe626a2ad32d"
|
sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.3.2"
|
||||||
shared_preferences_web:
|
shared_preferences_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_web
|
name: shared_preferences_web
|
||||||
sha256: "09b72ec530a1b1f26cdbec6b138f980d97d4d86ebb86dbf6365369fbd4bb05c8"
|
sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.3.0"
|
||||||
shared_preferences_windows:
|
shared_preferences_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_windows
|
name: shared_preferences_windows
|
||||||
sha256: "76c54a0148780d779a3fe332ece9ba8ad2c9dd0bc717ee7fce58bd06b5e8118f"
|
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.3.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -450,10 +450,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee"
|
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.2"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -470,22 +470,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "13.0.0"
|
version: "13.0.0"
|
||||||
|
web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web
|
||||||
|
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.1"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
sha256: c6a3f4e4058b70b46e27b2935de2d1562c50680e7fb44833911d981db73826c2
|
sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "5.3.0"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: xdg_directories
|
name: xdg_directories
|
||||||
sha256: "0186b3f2d66be9a12b0295bddcf8b6f8c0b0cc2f85c6287344e2a6366bc28457"
|
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0"
|
version: "1.0.4"
|
||||||
xml:
|
xml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -504,4 +512,4 @@ packages:
|
|||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.3.1 <4.0.0"
|
dart: ">=3.3.1 <4.0.0"
|
||||||
flutter: ">=2.12.0"
|
flutter: ">=3.19.0"
|
||||||
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 0.0.19+19
|
version: 0.0.21+21
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.1 <4.0.0'
|
sdk: '>=3.3.1 <4.0.0'
|
||||||
|
@ -3,8 +3,9 @@ import 'package:flutter/material.dart';
|
|||||||
class MaterialTesterWidget extends StatelessWidget {
|
class MaterialTesterWidget extends StatelessWidget {
|
||||||
final Widget widget;
|
final Widget widget;
|
||||||
|
|
||||||
MaterialTesterWidget({
|
const MaterialTesterWidget({
|
||||||
@required this.widget,
|
super.key,
|
||||||
|
required this.widget,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
@ -13,34 +13,34 @@ import 'package:time_progress_tracker/models/time_progress.dart';
|
|||||||
import 'package:time_progress_tracker/widgets/progress_list_view/progress_list_tile.dart';
|
import 'package:time_progress_tracker/widgets/progress_list_view/progress_list_tile.dart';
|
||||||
import 'package:time_progress_tracker/widgets/progress_list_view/progress_list_view.dart';
|
import 'package:time_progress_tracker/widgets/progress_list_view/progress_list_view.dart';
|
||||||
|
|
||||||
import 'MaterialTesterWidget.dart';
|
import 'material_tester_widget.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final AppSettings _defaultAppSettings = AppSettings.defaults();
|
final AppSettings defaultAppSettings = AppSettings.defaults();
|
||||||
final int _thisYear = DateTime.now().year;
|
final int thisYear = DateTime.now().year;
|
||||||
final TimeProgress _activeProgress = TimeProgress(
|
final TimeProgress activeProgress = TimeProgress(
|
||||||
"TestProgress", DateTime(_thisYear - 2), DateTime(_thisYear + 2));
|
"TestProgress", DateTime(thisYear - 2), DateTime(thisYear + 2));
|
||||||
|
|
||||||
void _findStringOnce(String str) => expect(find.text(str), findsOneWidget);
|
void findStringOnce(String str) => expect(find.text(str), findsOneWidget);
|
||||||
|
|
||||||
testWidgets("Progress List Tile with currently active progress works",
|
testWidgets("Progress List Tile with currently active progress works",
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(MaterialTesterWidget(
|
await tester.pumpWidget(MaterialTesterWidget(
|
||||||
widget: ProgressListTile(
|
widget: ProgressListTile(
|
||||||
timeProgress: _activeProgress,
|
timeProgress: activeProgress,
|
||||||
doneColor: _defaultAppSettings.doneColor,
|
doneColor: defaultAppSettings.doneColor,
|
||||||
leftColor: _defaultAppSettings.leftColor,
|
leftColor: defaultAppSettings.leftColor,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
_findStringOnce(_activeProgress.name);
|
findStringOnce(activeProgress.name);
|
||||||
_findStringOnce(ProgressListTileStrings.percentString(_activeProgress));
|
findStringOnce(ProgressListTileStrings.percentString(activeProgress));
|
||||||
|
|
||||||
WidgetPredicate linearPercentPredicate = (Widget widget) =>
|
linearPercentPredicate(Widget widget) =>
|
||||||
widget is LinearPercentIndicator &&
|
widget is LinearPercentIndicator &&
|
||||||
widget.percent == _activeProgress.percentDone() &&
|
widget.percent == activeProgress.percentDone() &&
|
||||||
widget.progressColor == _defaultAppSettings.doneColor &&
|
widget.progressColor == defaultAppSettings.doneColor &&
|
||||||
widget.backgroundColor == _defaultAppSettings.leftColor;
|
widget.backgroundColor == defaultAppSettings.leftColor;
|
||||||
expect(find.byWidgetPredicate(linearPercentPredicate), findsOneWidget);
|
expect(find.byWidgetPredicate(linearPercentPredicate), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,40 +48,40 @@ void main() {
|
|||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
TimeProgress futureProgress = TimeProgress(
|
TimeProgress futureProgress = TimeProgress(
|
||||||
"Test Progress",
|
"Test Progress",
|
||||||
DateTime(_thisYear + 1),
|
DateTime(thisYear + 1),
|
||||||
DateTime(_thisYear + 2),
|
DateTime(thisYear + 2),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialTesterWidget(
|
await tester.pumpWidget(MaterialTesterWidget(
|
||||||
widget: ProgressListTile(
|
widget: ProgressListTile(
|
||||||
timeProgress: futureProgress,
|
timeProgress: futureProgress,
|
||||||
doneColor: _defaultAppSettings.doneColor,
|
doneColor: defaultAppSettings.doneColor,
|
||||||
leftColor: _defaultAppSettings.leftColor,
|
leftColor: defaultAppSettings.leftColor,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
_findStringOnce(futureProgress.name);
|
findStringOnce(futureProgress.name);
|
||||||
_findStringOnce(ProgressListTileStrings.startsInDaysString(futureProgress));
|
findStringOnce(ProgressListTileStrings.startsInDaysString(futureProgress));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets("Progress List Tile with past progress works",
|
testWidgets("Progress List Tile with past progress works",
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
TimeProgress pastProgress = TimeProgress(
|
TimeProgress pastProgress = TimeProgress(
|
||||||
"Test Progress",
|
"Test Progress",
|
||||||
DateTime(_thisYear - 2),
|
DateTime(thisYear - 2),
|
||||||
DateTime(_thisYear - 1),
|
DateTime(thisYear - 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialTesterWidget(
|
await tester.pumpWidget(MaterialTesterWidget(
|
||||||
widget: ProgressListTile(
|
widget: ProgressListTile(
|
||||||
timeProgress: pastProgress,
|
timeProgress: pastProgress,
|
||||||
doneColor: _defaultAppSettings.doneColor,
|
doneColor: defaultAppSettings.doneColor,
|
||||||
leftColor: _defaultAppSettings.leftColor,
|
leftColor: defaultAppSettings.leftColor,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
_findStringOnce(pastProgress.name);
|
findStringOnce(pastProgress.name);
|
||||||
_findStringOnce(ProgressListTileStrings.endedDaysAgoString(pastProgress));
|
findStringOnce(ProgressListTileStrings.endedDaysAgoString(pastProgress));
|
||||||
});
|
});
|
||||||
|
|
||||||
WidgetPredicate getProgressListTilePredicate(
|
WidgetPredicate getProgressListTilePredicate(
|
||||||
@ -96,35 +96,37 @@ void main() {
|
|||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(MaterialTesterWidget(
|
await tester.pumpWidget(MaterialTesterWidget(
|
||||||
widget: ProgressListView(
|
widget: ProgressListView(
|
||||||
timeProgressList: [_activeProgress],
|
timeProgressList: [activeProgress],
|
||||||
doneColor: _defaultAppSettings.doneColor,
|
doneColor: defaultAppSettings.doneColor,
|
||||||
leftColor: _defaultAppSettings.leftColor,
|
leftColor: defaultAppSettings.leftColor,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
_findStringOnce(_activeProgress.name);
|
findStringOnce(activeProgress.name);
|
||||||
expect(
|
expect(
|
||||||
find.byWidgetPredicate(
|
find.byWidgetPredicate(
|
||||||
getProgressListTilePredicate(_activeProgress, _defaultAppSettings)),
|
getProgressListTilePredicate(activeProgress, defaultAppSettings)),
|
||||||
findsOneWidget);
|
findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets("Progress List View displays file tiles",
|
testWidgets("Progress List View displays file tiles",
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
List<TimeProgress> tpList = [];
|
List<TimeProgress> tpList = [];
|
||||||
for (int i = 0; i < 5; i++) tpList.add(_activeProgress);
|
for (int i = 0; i < 5; i++) {
|
||||||
|
tpList.add(activeProgress);
|
||||||
|
}
|
||||||
await tester.pumpWidget(MaterialTesterWidget(
|
await tester.pumpWidget(MaterialTesterWidget(
|
||||||
widget: ProgressListView(
|
widget: ProgressListView(
|
||||||
timeProgressList: tpList,
|
timeProgressList: tpList,
|
||||||
doneColor: _defaultAppSettings.doneColor,
|
doneColor: defaultAppSettings.doneColor,
|
||||||
leftColor: _defaultAppSettings.leftColor,
|
leftColor: defaultAppSettings.leftColor,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
expect(find.text(_activeProgress.name), findsNWidgets(5));
|
expect(find.text(activeProgress.name), findsNWidgets(5));
|
||||||
expect(
|
expect(
|
||||||
find.byWidgetPredicate(
|
find.byWidgetPredicate(
|
||||||
getProgressListTilePredicate(_activeProgress, _defaultAppSettings)),
|
getProgressListTilePredicate(activeProgress, defaultAppSettings)),
|
||||||
findsNWidgets(5));
|
findsNWidgets(5));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user