Fixed Simple Problem, that occured after migrating to new version.
Still WIP need to fix more Problems
This commit is contained in:
@ -5,7 +5,7 @@ class AppYesNoDialog extends StatelessWidget {
|
||||
final String contentText;
|
||||
final void Function() onYesPressed;
|
||||
|
||||
AppYesNoDialog({
|
||||
const AppYesNoDialog({
|
||||
Key key,
|
||||
@required this.titleText,
|
||||
@required this.contentText,
|
||||
@ -19,11 +19,11 @@ class AppYesNoDialog extends StatelessWidget {
|
||||
content: Text(contentText),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Yes"),
|
||||
child: const Text("Yes"),
|
||||
onPressed: onYesPressed,
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("No"),
|
||||
child: const Text("No"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
|
@ -7,7 +7,7 @@ class ColorPickerButton extends StatelessWidget {
|
||||
final Color selectedColor;
|
||||
final void Function(Color) onColorPicked;
|
||||
|
||||
ColorPickerButton({
|
||||
const ColorPickerButton({super.key,
|
||||
@required this.title,
|
||||
@required this.dialogTitle,
|
||||
@required this.selectedColor,
|
||||
@ -34,13 +34,13 @@ class ColorPickerButton extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Text(title),
|
||||
style: TextButton.styleFrom(
|
||||
primary: useBrightBackground(selectedColor)
|
||||
? appTheme.primaryTextTheme.button.color
|
||||
: appTheme.textTheme.button.color,
|
||||
? appTheme.primaryTextTheme.labelLarge.color
|
||||
: appTheme.textTheme.labelLarge.color,
|
||||
backgroundColor: selectedColor,
|
||||
),
|
||||
child: Text(title),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,17 @@ import 'package:time_progress_tracker/screens/progress_creation_screen.dart';
|
||||
class CreateProgressButton extends StatelessWidget {
|
||||
final String _heroTag = "createProgressBTN";
|
||||
|
||||
const CreateProgressButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
void _onButtonPressed() =>
|
||||
void onButtonPressed() =>
|
||||
Navigator.pushNamed(context, ProgressCreationScreen.routeName);
|
||||
|
||||
return FloatingActionButton(
|
||||
heroTag: _heroTag,
|
||||
child: Icon(Icons.add),
|
||||
onPressed: _onButtonPressed,
|
||||
onPressed: onButtonPressed,
|
||||
child: const Icon(Icons.add),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ class DatePickerBtn extends StatelessWidget {
|
||||
final DateTime pickedDate;
|
||||
final void Function(DateTime) onDatePicked;
|
||||
|
||||
DatePickerBtn({
|
||||
const DatePickerBtn({super.key,
|
||||
@required this.leadingString,
|
||||
@required this.pickedDate,
|
||||
@required this.onDatePicked,
|
||||
}) : super();
|
||||
});
|
||||
|
||||
void _onButtonPressed(BuildContext context) async {
|
||||
onDatePicked(await showDatePicker(
|
||||
@ -25,12 +25,12 @@ class DatePickerBtn extends StatelessWidget {
|
||||
ThemeData appTheme = Theme.of(context);
|
||||
return TextButton(
|
||||
onPressed: () => _onButtonPressed(context),
|
||||
child: Text(
|
||||
"$leadingString ${pickedDate.toLocal().toString().split(" ")[0]}"),
|
||||
style: TextButton.styleFrom(
|
||||
primary: appTheme.primaryTextTheme.button.color,
|
||||
primary: appTheme.primaryTextTheme.labelLarge.color,
|
||||
backgroundColor: appTheme.accentColor,
|
||||
),
|
||||
child: Text(
|
||||
"$leadingString ${pickedDate.toLocal().toString().split(" ")[0]}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ class SelectDurationBtn extends StatelessWidget {
|
||||
final Duration duration;
|
||||
final void Function(Duration) updateDuration;
|
||||
|
||||
SelectDurationBtn({
|
||||
const SelectDurationBtn({
|
||||
super.key,
|
||||
@required this.duration,
|
||||
@required this.updateDuration,
|
||||
});
|
||||
@ -38,10 +39,10 @@ class SelectDurationBtn extends StatelessWidget {
|
||||
int days = duration.inDays - (365 * years) - (30 * months);
|
||||
return TextButton(
|
||||
onPressed: () => _onButtonPressed(context, appTheme),
|
||||
child: Text("$years Years $months Months $days Days"),
|
||||
style: TextButton.styleFrom(
|
||||
primary: appTheme.primaryTextTheme.button.color,
|
||||
primary: appTheme.primaryTextTheme.labelLarge.color,
|
||||
backgroundColor: appTheme.accentColor,
|
||||
));
|
||||
),
|
||||
child: Text("$years Years $months Months $days Days"));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
||||
onCancelEditProgress,
|
||||
onDeleteProgress;
|
||||
|
||||
DetailScreenFloatingActionButtons({
|
||||
const DetailScreenFloatingActionButtons({
|
||||
super.key,
|
||||
@required this.editMode,
|
||||
@required this.originalProgress,
|
||||
@required this.editedProgress,
|
||||
@ -25,10 +26,10 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData appTheme = Theme.of(context);
|
||||
|
||||
void _onCancelEditTimeProgressBTN() {
|
||||
if (originalProgress == editedProgress)
|
||||
void onCancelEditTimeProgressBTN() {
|
||||
if (originalProgress == editedProgress) {
|
||||
onCancelEditProgress();
|
||||
else {
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AppYesNoDialog(
|
||||
@ -44,7 +45,7 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
void _onDeleteTimeProgressBTN() {
|
||||
void onDeleteTimeProgressBTN() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AppYesNoDialog(
|
||||
@ -61,13 +62,13 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
||||
child: FloatingActionButton(
|
||||
heroTag:
|
||||
editMode ? "saveEditedTimeProgressBTN" : "editTimeProgressBTN",
|
||||
child: editMode ? Icon(Icons.save) : Icon(Icons.edit),
|
||||
backgroundColor: editMode ? Colors.green : appTheme.accentColor,
|
||||
onPressed: editMode
|
||||
? isEditedProgressValid
|
||||
? onSaveEditedProgress
|
||||
: null
|
||||
: onEditProgress,
|
||||
child: editMode ? const Icon(Icons.save) : const Icon(Icons.edit),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -75,11 +76,11 @@ class DetailScreenFloatingActionButtons extends StatelessWidget {
|
||||
heroTag: editMode
|
||||
? "cancelEditTimeProgressBTN"
|
||||
: "deleteTimeProgressBTN",
|
||||
child: editMode ? Icon(Icons.cancel) : Icon(Icons.delete),
|
||||
backgroundColor: Colors.red,
|
||||
onPressed: editMode
|
||||
? _onCancelEditTimeProgressBTN
|
||||
: _onDeleteTimeProgressBTN,
|
||||
? onCancelEditTimeProgressBTN
|
||||
: onDeleteTimeProgressBTN,
|
||||
child: editMode ? const Icon(Icons.cancel) : const Icon(Icons.delete),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -4,11 +4,11 @@ class HomeBottomNavBar extends StatelessWidget {
|
||||
final int currentIndex;
|
||||
final Function onTap;
|
||||
|
||||
HomeBottomNavBar({
|
||||
Key key,
|
||||
const HomeBottomNavBar({
|
||||
super.key,
|
||||
@required this.currentIndex,
|
||||
@required this.onTap,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -19,21 +19,21 @@ class HomeBottomNavBar extends StatelessWidget {
|
||||
currentIndex: currentIndex,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: new Icon(
|
||||
icon: Icon(
|
||||
Icons.alarm,
|
||||
color: appTheme.primaryColor,
|
||||
),
|
||||
label: "Active Progresses",
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: new Icon(
|
||||
icon: Icon(
|
||||
Icons.alarm_off,
|
||||
color: appTheme.primaryColor,
|
||||
),
|
||||
label: "Inactive Progresses",
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: new Icon(
|
||||
icon: Icon(
|
||||
Icons.settings,
|
||||
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';
|
||||
|
||||
class HomeActiveProgressesTab extends StatelessWidget {
|
||||
const HomeActiveProgressesTab({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsStoreConnector(
|
||||
@ -14,14 +16,15 @@ class HomeActiveProgressesTab extends StatelessWidget {
|
||||
loadedBuilder: (context, tpListVm) {
|
||||
List<TimeProgress> activeTpList =
|
||||
selectActiveProgresses(tpListVm.tpList);
|
||||
if (activeTpList.length < 1)
|
||||
if (activeTpList.isEmpty) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"You don't have any active time progress, that are tracked."),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ProgressListView(
|
||||
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';
|
||||
|
||||
class HomeInactiveProgressesTab extends StatelessWidget {
|
||||
const HomeInactiveProgressesTab({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsStoreConnector(
|
||||
@ -14,14 +16,15 @@ class HomeInactiveProgressesTab extends StatelessWidget {
|
||||
loadedBuilder: (context, tpListVm) {
|
||||
List<TimeProgress> inactiveTpList =
|
||||
selectInactiveProgresses(tpListVm.tpList);
|
||||
if (inactiveTpList.length < 1)
|
||||
if (inactiveTpList.isEmpty) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"You don't have any currently inactive time progresses, that are tracked."),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ProgressListView(
|
||||
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';
|
||||
|
||||
class HomeSettingsTab extends StatelessWidget {
|
||||
const HomeSettingsTab({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsStoreConnector(
|
||||
loadedBuilder: (context, settingsVm) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
@ -28,7 +30,7 @@ class HomeSettingsTab extends StatelessWidget {
|
||||
updateDuration: settingsVm.updateDuration,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
@ -39,7 +41,7 @@ class HomeSettingsTab extends StatelessWidget {
|
||||
applicationLegalese:
|
||||
'\u00a9Andreas Fahrecker 2020-2021');
|
||||
},
|
||||
child: Text("About"),
|
||||
child: const Text("About"),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -5,7 +5,8 @@ class ColorSettingsWidget extends StatelessWidget {
|
||||
final Color doneColor, leftColor;
|
||||
final void Function(Color) updateDoneColor, updateLeftColor;
|
||||
|
||||
ColorSettingsWidget({
|
||||
const ColorSettingsWidget({
|
||||
super.key,
|
||||
@required this.doneColor,
|
||||
@required this.leftColor,
|
||||
@required this.updateDoneColor,
|
||||
@ -21,14 +22,14 @@ class ColorSettingsWidget extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Color Settings",
|
||||
style: appTheme.textTheme.headline6,
|
||||
style: appTheme.textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(right: 5),
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: ColorPickerButton(
|
||||
title: "Done Color",
|
||||
dialogTitle: "Select Done Color",
|
||||
@ -39,7 +40,7 @@ class ColorSettingsWidget extends StatelessWidget {
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: ColorPickerButton(
|
||||
title: "Left Color",
|
||||
dialogTitle: "Select Left Color",
|
||||
|
@ -5,7 +5,8 @@ class DurationSettingsWidget extends StatelessWidget {
|
||||
final Duration duration;
|
||||
final void Function(Duration) updateDuration;
|
||||
|
||||
DurationSettingsWidget({
|
||||
const DurationSettingsWidget({
|
||||
super.key,
|
||||
@required this.duration,
|
||||
@required this.updateDuration,
|
||||
});
|
||||
@ -14,15 +15,15 @@ class DurationSettingsWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
ThemeData appTheme = Theme.of(context);
|
||||
|
||||
int years = duration.inDays ~/ 365;
|
||||
int months = (duration.inDays - (365 * years)) ~/ 30;
|
||||
int days = duration.inDays - (365 * years) - (30 * months);
|
||||
//int years = duration.inDays ~/ 365;
|
||||
//int months = (duration.inDays - (365 * years)) ~/ 30;
|
||||
//int days = duration.inDays - (365 * years) - (30 * months);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Duration Settings",
|
||||
style: appTheme.textTheme.headline6,
|
||||
style: appTheme.textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
|
@ -6,7 +6,8 @@ class ProgressEditorWidget extends StatefulWidget {
|
||||
final TimeProgress timeProgress;
|
||||
final Function(TimeProgress, bool) onTimeProgressChanged;
|
||||
|
||||
ProgressEditorWidget({
|
||||
const ProgressEditorWidget({
|
||||
super.key,
|
||||
@required this.timeProgress,
|
||||
@required this.onTimeProgressChanged,
|
||||
});
|
||||
@ -67,7 +68,7 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
||||
child: TextField(
|
||||
controller: _nameTextController,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: "Progress Name",
|
||||
errorText: _validName
|
||||
? null
|
||||
@ -80,7 +81,7 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(right: 5),
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: DatePickerBtn(
|
||||
leadingString: "Start Date:",
|
||||
pickedDate: widget.timeProgress.startTime,
|
||||
@ -90,7 +91,7 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: DatePickerBtn(
|
||||
leadingString: "End Date:",
|
||||
pickedDate: widget.timeProgress.endTime,
|
||||
@ -103,9 +104,9 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
||||
)
|
||||
];
|
||||
|
||||
if (!_validDate)
|
||||
if (!_validDate) {
|
||||
columnChildren.add(
|
||||
Expanded(
|
||||
const Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Invalid Dates. The Start Date has to be before the End Date",
|
||||
@ -114,11 +115,10 @@ class _ProgressEditorWidgetState extends State<ProgressEditorWidget> {
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
child: Column(
|
||||
children: columnChildren,
|
||||
),
|
||||
return Column(
|
||||
children: columnChildren,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,17 +18,19 @@ class ProgressListTile extends StatelessWidget {
|
||||
final TimeProgress timeProgress;
|
||||
final Color doneColor, leftColor;
|
||||
|
||||
ProgressListTile({
|
||||
const ProgressListTile({super.key,
|
||||
@required this.timeProgress,
|
||||
@required this.doneColor,
|
||||
@required this.leftColor,
|
||||
});
|
||||
|
||||
Widget _renderSubtitle(BuildContext context) {
|
||||
if (!timeProgress.hasStarted())
|
||||
if (!timeProgress.hasStarted()) {
|
||||
return Text(ProgressListTileStrings.startsInDaysString(timeProgress));
|
||||
if (timeProgress.hasEnded())
|
||||
}
|
||||
if (timeProgress.hasEnded()) {
|
||||
return Text(ProgressListTileStrings.endedDaysAgoString(timeProgress));
|
||||
}
|
||||
return LinearPercentIndicator(
|
||||
center: Text(ProgressListTileStrings.percentString(timeProgress)),
|
||||
percent: timeProgress.percentDone(),
|
||||
@ -40,14 +42,14 @@ class ProgressListTile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
void _onTileTap() =>
|
||||
void onTileTap() =>
|
||||
Navigator.pushNamed(context, ProgressDetailScreen.routeName,
|
||||
arguments: ProgressDetailScreenArguments(timeProgress.id));
|
||||
|
||||
return ListTile(
|
||||
title: Text(timeProgress.name),
|
||||
subtitle: _renderSubtitle(context),
|
||||
onTap: _onTileTap,
|
||||
onTap: onTileTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ class ProgressListView extends StatelessWidget {
|
||||
final List<TimeProgress> timeProgressList;
|
||||
final Color doneColor, leftColor;
|
||||
|
||||
ProgressListView({
|
||||
const ProgressListView({
|
||||
super.key,
|
||||
@required this.timeProgressList,
|
||||
@required this.doneColor,
|
||||
@required this.leftColor,
|
||||
@ -27,7 +28,7 @@ class ProgressListView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.all(8),
|
||||
padding: const EdgeInsets.all(8),
|
||||
children: _renderListViewChildren(),
|
||||
);
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ class ProgressViewWidget extends StatelessWidget {
|
||||
final Color doneColor;
|
||||
final Color leftColor;
|
||||
|
||||
ProgressViewWidget({
|
||||
const ProgressViewWidget({
|
||||
super.key,
|
||||
@required this.timeProgress,
|
||||
@required this.doneColor,
|
||||
@required this.leftColor,
|
||||
@ -16,49 +17,47 @@ class ProgressViewWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fitWidth,
|
||||
child: Text(
|
||||
timeProgress.name,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fitWidth,
|
||||
child: Text(
|
||||
timeProgress.name,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CircularPercentIndicator(
|
||||
radius: 100,
|
||||
lineWidth: 10,
|
||||
percent: timeProgress.percentDone(),
|
||||
progressColor: doneColor,
|
||||
backgroundColor: leftColor,
|
||||
center: Text("${(timeProgress.percentDone() * 100).floor()} %"),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CircularPercentIndicator(
|
||||
radius: 100,
|
||||
lineWidth: 10,
|
||||
percent: timeProgress.percentDone(),
|
||||
progressColor: doneColor,
|
||||
backgroundColor: leftColor,
|
||||
center: Text("${(timeProgress.percentDone() * 100).floor()} %"),
|
||||
),
|
||||
Expanded(
|
||||
child: LinearPercentIndicator(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
percent: timeProgress.percentDone(),
|
||||
leading: Text("${timeProgress.daysBehind()} Days"),
|
||||
center: Text(
|
||||
"${(timeProgress.percentDone() * 100).floor()} %",
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
trailing: Text("${timeProgress.daysLeft()} Days"),
|
||||
progressColor: doneColor,
|
||||
backgroundColor: leftColor,
|
||||
lineHeight: 25,
|
||||
),
|
||||
Expanded(
|
||||
child: LinearPercentIndicator(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
percent: timeProgress.percentDone(),
|
||||
leading: Text("${timeProgress.daysBehind()} Days"),
|
||||
center: Text(
|
||||
"${(timeProgress.percentDone() * 100).floor()} %",
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
trailing: Text("${timeProgress.daysLeft()} Days"),
|
||||
progressColor: doneColor,
|
||||
backgroundColor: leftColor,
|
||||
lineHeight: 25,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import 'package:time_progress_tracker/models/app_state.dart';
|
||||
class SettingsStoreConnector extends StatelessWidget {
|
||||
final Widget Function(BuildContext, SettingsViewModel) loadedBuilder;
|
||||
|
||||
SettingsStoreConnector({
|
||||
const SettingsStoreConnector({
|
||||
super.key,
|
||||
@required this.loadedBuilder,
|
||||
});
|
||||
|
||||
@ -18,10 +19,11 @@ class SettingsStoreConnector extends StatelessWidget {
|
||||
onInit: loadSettingsIfUnloaded,
|
||||
converter: (store) => SettingsViewModel._create(store),
|
||||
builder: (context, SettingsViewModel vm) {
|
||||
if (!vm.hasSettingsLoaded)
|
||||
return Center(
|
||||
if (!vm.hasSettingsLoaded) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
return loadedBuilder(context, vm);
|
||||
},
|
||||
);
|
||||
@ -44,17 +46,17 @@ class SettingsViewModel {
|
||||
);
|
||||
|
||||
factory SettingsViewModel._create(Store<AppState> store) {
|
||||
AppSettings _appSettings = store.state.appSettings;
|
||||
AppSettings appSettings = store.state.appSettings;
|
||||
|
||||
void _updateDoneColor(Color dC) => store.dispatch(
|
||||
UpdateAppSettingsActions(_appSettings.copyWith(doneColor: dC)));
|
||||
void _updateLeftColor(Color lC) => store.dispatch(
|
||||
UpdateAppSettingsActions(_appSettings.copyWith(leftColor: lC)));
|
||||
void updateDoneColor(Color dC) => store.dispatch(
|
||||
UpdateAppSettingsActions(appSettings.copyWith(doneColor: dC)));
|
||||
void updateLeftColor(Color lC) => store.dispatch(
|
||||
UpdateAppSettingsActions(appSettings.copyWith(leftColor: lC)));
|
||||
|
||||
void _updateDuration(Duration d) => store
|
||||
.dispatch(UpdateAppSettingsActions(_appSettings.copyWith(duration: d)));
|
||||
void updateDuration(Duration d) => store
|
||||
.dispatch(UpdateAppSettingsActions(appSettings.copyWith(duration: d)));
|
||||
|
||||
return SettingsViewModel(_appSettings, store.state.hasSettingsLoaded,
|
||||
_updateDoneColor, _updateLeftColor, _updateDuration);
|
||||
return SettingsViewModel(appSettings, store.state.hasSettingsLoaded,
|
||||
updateDoneColor, updateLeftColor, updateDuration);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import 'package:time_progress_tracker/models/time_progress.dart';
|
||||
class TimeProgressListStoreConnector extends StatelessWidget {
|
||||
final Widget Function(BuildContext, TimeProgressListViewModel) loadedBuilder;
|
||||
|
||||
TimeProgressListStoreConnector({
|
||||
const TimeProgressListStoreConnector({
|
||||
super.key,
|
||||
@required this.loadedBuilder,
|
||||
});
|
||||
|
||||
@ -18,10 +19,11 @@ class TimeProgressListStoreConnector extends StatelessWidget {
|
||||
onInit: loadTimeProgressListIfUnloaded,
|
||||
converter: (store) => TimeProgressListViewModel._create(store),
|
||||
builder: (context, TimeProgressListViewModel vm) {
|
||||
if (!vm.hasTpListLoaded)
|
||||
return Center(
|
||||
if (!vm.hasTpListLoaded) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
return loadedBuilder(context, vm);
|
||||
},
|
||||
);
|
||||
|
@ -11,7 +11,8 @@ class TimeProgressStoreConnector extends StatelessWidget {
|
||||
final String timeProgressId;
|
||||
final Widget Function(BuildContext, TimeProgressViewModel) loadedBuilder;
|
||||
|
||||
TimeProgressStoreConnector({
|
||||
const TimeProgressStoreConnector({
|
||||
super.key,
|
||||
@required this.timeProgressId,
|
||||
@required this.loadedBuilder,
|
||||
});
|
||||
@ -23,14 +24,16 @@ class TimeProgressStoreConnector extends StatelessWidget {
|
||||
converter: (store) =>
|
||||
TimeProgressViewModel._create(store, timeProgressId),
|
||||
builder: (context, TimeProgressViewModel vm) {
|
||||
if (!vm.hasTpListLoaded)
|
||||
return Center(
|
||||
if (!vm.hasTpListLoaded) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
if (vm.tp == null)
|
||||
return Center(
|
||||
}
|
||||
if (vm.tp == null) {
|
||||
return const Center(
|
||||
child: Text("Error Invalid Time Progress"),
|
||||
);
|
||||
}
|
||||
return loadedBuilder(context, vm);
|
||||
},
|
||||
);
|
||||
@ -52,15 +55,15 @@ class TimeProgressViewModel {
|
||||
);
|
||||
|
||||
factory TimeProgressViewModel._create(Store<AppState> store, String id) {
|
||||
void _updateTimeProgress(TimeProgress tp) =>
|
||||
void updateTimeProgress(TimeProgress tp) =>
|
||||
store.dispatch(UpdateTimeProgressAction(id, tp));
|
||||
void _deleteTimeProgress() => store.dispatch(DeleteTimeProgressAction(id));
|
||||
void deleteTimeProgress() => store.dispatch(DeleteTimeProgressAction(id));
|
||||
|
||||
return TimeProgressViewModel(
|
||||
selectProgressById(store.state.timeProgressList, id),
|
||||
store.state.hasProgressesLoaded,
|
||||
_updateTimeProgress,
|
||||
_deleteTimeProgress,
|
||||
updateTimeProgress,
|
||||
deleteTimeProgress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user