diff --git a/lib/pages/home/main.dart b/lib/pages/home/main.dart index bc609bee..ca418da2 100644 --- a/lib/pages/home/main.dart +++ b/lib/pages/home/main.dart @@ -1068,7 +1068,14 @@ class BudgetList extends StatelessWidget { child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final List widgets = []; + final DateTime now = tzHandler + .sNow() + .setTimeOfDay(const TimeOfDay(hour: 12, minute: 0)); + final DateTime lastDayInMonth = + tzHandler.sTime(now.copyWith(month: now.month + 1, day: 0)); + final double passedDays = now.day / lastDayInMonth.day; for (BudgetLimitRead budget in snapshot.data!) { + final List stackWidgets = []; final double spent = (double.tryParse(budget.attributes.spent ?? "0") ?? 0).abs(); final double available = @@ -1099,40 +1106,38 @@ class BudgetList extends StatelessWidget { if (widgets.isNotEmpty) { widgets.add(const SizedBox(height: 8)); } - widgets.add( - RichText( - text: TextSpan( - children: [ - TextSpan( - text: budgetInfo.name, - style: Theme.of(context).textTheme.titleSmall, - ), - TextSpan( - text: budget.attributes.period?.isNotEmpty ?? false - ? S.of(context).homeMainBudgetInterval( - tzHandler - .sTime(budget.attributes.start) - .toLocal(), - tzHandler - .sTime(budget.attributes.end) - .toLocal(), - budget.attributes.period!, - ) - : S.of(context).homeMainBudgetIntervalSingle( - tzHandler - .sTime(budget.attributes.start) - .toLocal(), - tzHandler - .sTime(budget.attributes.end) - .toLocal(), - ), - style: Theme.of(context).textTheme.bodyMedium, - ), - ], - ), + widgets.add(RichText( + text: TextSpan( + children: [ + TextSpan( + text: budgetInfo.name, + style: Theme.of(context).textTheme.titleSmall, + ), + TextSpan( + text: budget.attributes.period?.isNotEmpty ?? false + ? S.of(context).homeMainBudgetInterval( + tzHandler + .sTime(budget.attributes.start) + .toLocal(), + tzHandler + .sTime(budget.attributes.end) + .toLocal(), + budget.attributes.period!, + ) + : S.of(context).homeMainBudgetIntervalSingle( + tzHandler + .sTime(budget.attributes.start) + .toLocal(), + tzHandler + .sTime(budget.attributes.end) + .toLocal(), + ), + style: Theme.of(context).textTheme.bodyMedium, + ), + ], ), - ); - widgets.add(Row( + )); + stackWidgets.add(Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( @@ -1161,10 +1166,35 @@ class BudgetList extends StatelessWidget { ), ], )); - widgets.add(LinearProgressIndicator( - color: lineColor, - backgroundColor: bgColor, - value: value, + stackWidgets.add(Positioned.fill( + top: 20, // Height of Row() with text + bottom: 4, + child: LinearProgressIndicator( + color: lineColor, + backgroundColor: bgColor, + value: value, + ), + )); + widgets.add(LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) => + Stack( + children: [ + // Row + ProgressIndicator + Bottom Padding + const SizedBox(height: 20 + 4 + 4), + ...stackWidgets, + Positioned( + left: constraints.biggest.width * passedDays, + top: 16, + bottom: 0, + width: 3, + child: Container( + color: (spent / available > passedDays) + ? Colors.redAccent + : Colors.blueAccent, + ), + ), + ], + ), )); } return Column( diff --git a/pubspec.yaml b/pubspec.yaml index de9ec29b..c857dcde 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -59,11 +59,11 @@ dependencies: dev_dependencies: flutter_lints: ^5.0.0 # needed for swagger_dart_code_generator - build_runner: ^2.4.7 - chopper_generator: ^8.0.2 - json_serializable: ^6.7.1 - swagger_dart_code_generator: ^3.0.0 - flutter_native_splash: ^2.3.10 + build_runner: ^2.4.13 + chopper_generator: ^8.0.3 + json_serializable: ^6.9.0 + swagger_dart_code_generator: ^3.0.1 + flutter_native_splash: ^2.4.3 translations_cleaner: ^0.0.5 flutter: