diff --git a/lib/providers/special_day.dart b/lib/providers/special_day.dart index 8530e85..310fdc6 100644 --- a/lib/providers/special_day.dart +++ b/lib/providers/special_day.dart @@ -129,7 +129,7 @@ class SpecialDayProvider { } double getSpecialDayProgress(DateTime last, DateTime next) { - final totalDuration = next.difference(last).inSeconds.toDouble(); + final totalDuration = next.add(-const Duration(days: 1)).difference(last).inSeconds.toDouble(); final elapsedDuration = DateTime.now().difference(last).inSeconds.toDouble(); return (elapsedDuration / totalDuration).clamp(0.0, 1.0); } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 323fb44..e0c4e2f 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -12,6 +12,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:material_symbols_icons/symbols.dart'; import 'package:provider/provider.dart'; import 'package:relative_time/relative_time.dart'; +import 'package:slide_countdown/slide_countdown.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:flutter/material.dart'; import 'package:surface/providers/config.dart'; @@ -188,7 +189,7 @@ class _HomeDashSpecialDayWidget extends StatelessWidget { var (name, date) = nextOne; date = date.add(Duration(days: 1)); final progress = dayz.getSpecialDayProgress(lastOne.$2, date); - final diff = nextOne.$2.add(-const Duration(days: 1)).difference(lastOne.$2); + final diff = nextOne.$2.difference(DateTime.now()); return Card( child: ListTile( leading: Text(kSpecialDaysSymbol[name] ?? '๐ŸŽ‰').fontSize(24), @@ -196,8 +197,15 @@ class _HomeDashSpecialDayWidget extends StatelessWidget { subtitle: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text('${diff.inDays}d ยท ${(progress * 100).toStringAsFixed(2)}%'), - const Gap(8), + SlideCountdown( + duration: diff, + style: GoogleFonts.robotoMono(fontSize: 13), + separatorStyle: GoogleFonts.robotoMono(fontSize: 13), + separatorType: SeparatorType.symbol, + decoration: BoxDecoration(), + padding: EdgeInsets.zero, + ), + const Gap(12), Expanded( child: LinearProgressIndicator( value: progress, diff --git a/pubspec.lock b/pubspec.lock index 4153551..09a41da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -490,10 +490,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: c2376a6aae82358a9f9ccdd7d1f4006d08faa39a2767cce01031d9f593a8bd3b + sha256: c904b4ab56d53385563c7c39d8e9fa9af086f91495dfc48717ad84a42c3cf204 url: "https://pub.dev" source: hosted - version: "8.1.6" + version: "8.1.7" file_saver: dependency: "direct main" description: @@ -1354,6 +1354,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" + pausable_timer: + dependency: transitive + description: + name: pausable_timer + sha256: "6ef1a95441ec3439de6fb63f39a011b67e693198e7dae14e20675c3c00e86074" + url: "https://pub.dev" + source: hosted + version: "3.1.0+3" permission_handler: dependency: "direct main" description: @@ -1711,6 +1719,14 @@ packages: description: flutter source: sdk version: "0.0.0" + slide_countdown: + dependency: "direct main" + description: + name: slide_countdown + sha256: "363914f96389502467d4dc9c0f26e88f93df3d8e37de2d5ff05b16d981fe973d" + url: "https://pub.dev" + source: hosted + version: "2.0.2" sliver_tools: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 7798a3e..bf33e88 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -114,6 +114,7 @@ dependencies: flutter_colorpicker: ^1.1.0 fl_chart: ^0.70.0 flutter_webrtc: ^0.12.5+hotfix.1 + slide_countdown: ^2.0.2 dev_dependencies: flutter_test: