Fixed Remaining Migration Errors

This commit is contained in:
2024-03-15 22:47:43 +01:00
parent 421d19f91f
commit ead31e12c0
9 changed files with 120 additions and 94 deletions

View File

@ -27,6 +27,7 @@ class TimeProgressTrackerApp extends StatelessWidget {
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.indigo,
accentColor: Colors.indigoAccent,
backgroundColor: Colors.white
),
brightness: Brightness.light,
visualDensity: VisualDensity.adaptivePlatformDensity,

View File

@ -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 name = json["name"] as String;
final DateTime startTime =

View File

@ -16,7 +16,6 @@ class TimeProgressRepository {
}
return Future<List<TimeProgressEntity>>.value(codec
.decode(jsonString)["timers"]
.cast<Map<String, Object>>()
.map<TimeProgressEntity>(TimeProgressEntity.fromJson)
.toList(growable: false));
}

View File

@ -33,9 +33,12 @@ class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
final ThemeData appTheme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: const Text(HomeScreen.title),
backgroundColor: appTheme.colorScheme.primary,
),
body: _children[_currentIndex],
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,

View File

@ -42,9 +42,12 @@ class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
@override
Widget build(BuildContext context) {
final ThemeData appTheme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: const Text(ProgressCreationScreen.title),
backgroundColor: appTheme.colorScheme.primary,
),
body: Container(
padding: const EdgeInsets.all(12),
@ -52,7 +55,9 @@ class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
onInit: loadSettingsIfUnloaded,
converter: (store) => _ViewModel.create(store),
builder: (context, _ViewModel viewModel) {
initTimeProgress(viewModel.defaultDurationProgress);
WidgetsBinding.instance.addPostFrameCallback((_) {
initTimeProgress(viewModel.defaultDurationProgress);
});
return ProgressEditorWidget(
timeProgress:
timeProgressToCreate ?? viewModel.defaultDurationProgress,

View File

@ -79,12 +79,15 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
@override
Widget build(BuildContext context) {
final ProgressDetailScreenArguments args =
ModalRoute.of(context)?.settings.arguments as ProgressDetailScreenArguments;
final ThemeData appTheme = Theme.of(context);
final ProgressDetailScreenArguments args = ModalRoute.of(context)
?.settings
.arguments as ProgressDetailScreenArguments;
return Scaffold(
appBar: AppBar(
title: const Text(ProgressDetailScreen.title),
backgroundColor: appTheme.colorScheme.primary,
),
body: SettingsStoreConnector(
loadedBuilder: (context, settingsVm) {
@ -93,10 +96,11 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
loadedBuilder: (context, tpVm) {
_initEditedProgress(tpVm.tp);
return Container(
margin: const EdgeInsets.all(8),
child: Column(
children: _renderColumnChildren(settingsVm, tpVm),
));
margin: const EdgeInsets.all(8),
child: Column(
children: _renderColumnChildren(settingsVm, tpVm),
),
);
},
);
},

View File

@ -18,46 +18,46 @@ class ProgressViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
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,
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: 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),
Expanded(
child: CircularPercentIndicator(
radius: 100,
lineWidth: 10,
percent: timeProgress.percentDone(),
progressColor: doneColor,
backgroundColor: leftColor,
center: Text("${(timeProgress.percentDone() * 100).floor()} %"),
),
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,
),
),
],
);
}
}