diff --git a/lib/consts.dart b/lib/consts.dart index 2a3a22e..9aea815 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -9,7 +9,7 @@ class TTConsts { static get SESSION_SERVER => "https://api.zontreck.com/timetrack/$UPDATE_CHANNEL/timetrack.php"; - static const VERSION = "1.0.0-beta.30"; + static const VERSION = "1.0.0-beta.31"; static bool UPDATE_AVAILABLE = false; static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta; diff --git a/lib/data.dart b/lib/data.dart index 32b137e..9097219 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -38,6 +38,8 @@ class SessionData { static Callbacks Calls = Callbacks(); static String LastSessionID = ""; static String DisplayError = ""; + static String DisplayMessage = ""; + static bool DirtyState = false; static double? TotalPay; static bool ContainsTripTimes = true; static bool IsSavedData = false; @@ -84,10 +86,10 @@ class SessionData { seconds: diff.inSeconds, ); stamp.add(diffTime); - print("Add timestamp; ${diff}; ${diffTime}"); + print("Add timestamp; $diff; $diffTime"); } - print("Final time: ${stamp}"); + print("Final time: $stamp"); return stamp.toDuration(); } @@ -356,6 +358,11 @@ class SessionData { static Future SaveCacheState() async { CompoundTag ct = IsOnTheClock ? await _serializeToNBT() : CompoundTag(); await NBTHelper.CommitNBT(data: ct, name: "appstate"); + + if (DirtyState) { + DirtyState = false; + DisplayMessage = "Saved cache state"; + } } static Future _deserialize(CompoundTag ct) async { diff --git a/lib/pages/HomePage.dart b/lib/pages/HomePage.dart index 88ac22f..80e185d 100644 --- a/lib/pages/HomePage.dart +++ b/lib/pages/HomePage.dart @@ -42,6 +42,18 @@ class _HomePageState extends State { SessionData.DisplayError = ""; } + + if (SessionData.DisplayMessage.isNotEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(SessionData.DisplayMessage), + elevation: 8, + duration: Duration(seconds: 5), + ), + ); + + SessionData.DisplayMessage = ""; + } } @override @@ -123,6 +135,7 @@ class _HomePageState extends State { onTap: () async { setState(() { SessionData.ResetAppSession(); + SessionData.DirtyState = true; }); }, ), @@ -167,6 +180,8 @@ class _HomePageState extends State { ); } setState(() {}); + + SessionData.DirtyState = true; }, child: Text("ENGAGE"), ), @@ -211,6 +226,8 @@ class _HomePageState extends State { SessionData.EndTrip(); setState(() {}); + + SessionData.DirtyState = true; }, child: Text("Yes"), ), @@ -254,6 +271,8 @@ class _HomePageState extends State { SessionData.GetNewDelivery(); setState(() {}); + + SessionData.DirtyState = true; }, child: Text("Yes"), ), @@ -295,6 +314,8 @@ class _HomePageState extends State { SessionData.GetNewDelivery(); setState(() {}); + + SessionData.DirtyState = true; }, child: Text("Yes"), ), @@ -363,6 +384,8 @@ class _HomePageState extends State { await SessionData.Logout(); setState(() {}); + + SessionData.DirtyState = true; }, child: Text("Yes"), ), @@ -400,6 +423,8 @@ class _HomePageState extends State { } class OverlayWidget extends StatefulWidget { + const OverlayWidget({super.key}); + @override State createState() { return _Overlay(); diff --git a/pubspec.yaml b/pubspec.yaml index 7ca04eb..bd8696c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0-beta.30 +version: 1.0.0-beta.31 environment: sdk: ^3.7.2