Add a message that is to be displayed after saving the state data when performing actions.

This commit is contained in:
zontreck 2025-06-13 19:07:41 -07:00
parent 09a52d2865
commit ced927c306
4 changed files with 36 additions and 4 deletions

View file

@ -9,7 +9,7 @@ class TTConsts {
static get SESSION_SERVER => static get SESSION_SERVER =>
"https://api.zontreck.com/timetrack/$UPDATE_CHANNEL/timetrack.php"; "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 bool UPDATE_AVAILABLE = false;
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta; static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;

View file

@ -38,6 +38,8 @@ class SessionData {
static Callbacks Calls = Callbacks(); static Callbacks Calls = Callbacks();
static String LastSessionID = ""; static String LastSessionID = "";
static String DisplayError = ""; static String DisplayError = "";
static String DisplayMessage = "";
static bool DirtyState = false;
static double? TotalPay; static double? TotalPay;
static bool ContainsTripTimes = true; static bool ContainsTripTimes = true;
static bool IsSavedData = false; static bool IsSavedData = false;
@ -84,10 +86,10 @@ class SessionData {
seconds: diff.inSeconds, seconds: diff.inSeconds,
); );
stamp.add(diffTime); stamp.add(diffTime);
print("Add timestamp; ${diff}; ${diffTime}"); print("Add timestamp; $diff; $diffTime");
} }
print("Final time: ${stamp}"); print("Final time: $stamp");
return stamp.toDuration(); return stamp.toDuration();
} }
@ -356,6 +358,11 @@ class SessionData {
static Future<void> SaveCacheState() async { static Future<void> SaveCacheState() async {
CompoundTag ct = IsOnTheClock ? await _serializeToNBT() : CompoundTag(); CompoundTag ct = IsOnTheClock ? await _serializeToNBT() : CompoundTag();
await NBTHelper.CommitNBT(data: ct, name: "appstate"); await NBTHelper.CommitNBT(data: ct, name: "appstate");
if (DirtyState) {
DirtyState = false;
DisplayMessage = "Saved cache state";
}
} }
static Future<void> _deserialize(CompoundTag ct) async { static Future<void> _deserialize(CompoundTag ct) async {

View file

@ -42,6 +42,18 @@ class _HomePageState extends State<HomePage> {
SessionData.DisplayError = ""; SessionData.DisplayError = "";
} }
if (SessionData.DisplayMessage.isNotEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(SessionData.DisplayMessage),
elevation: 8,
duration: Duration(seconds: 5),
),
);
SessionData.DisplayMessage = "";
}
} }
@override @override
@ -123,6 +135,7 @@ class _HomePageState extends State<HomePage> {
onTap: () async { onTap: () async {
setState(() { setState(() {
SessionData.ResetAppSession(); SessionData.ResetAppSession();
SessionData.DirtyState = true;
}); });
}, },
), ),
@ -167,6 +180,8 @@ class _HomePageState extends State<HomePage> {
); );
} }
setState(() {}); setState(() {});
SessionData.DirtyState = true;
}, },
child: Text("ENGAGE"), child: Text("ENGAGE"),
), ),
@ -211,6 +226,8 @@ class _HomePageState extends State<HomePage> {
SessionData.EndTrip(); SessionData.EndTrip();
setState(() {}); setState(() {});
SessionData.DirtyState = true;
}, },
child: Text("Yes"), child: Text("Yes"),
), ),
@ -254,6 +271,8 @@ class _HomePageState extends State<HomePage> {
SessionData.GetNewDelivery(); SessionData.GetNewDelivery();
setState(() {}); setState(() {});
SessionData.DirtyState = true;
}, },
child: Text("Yes"), child: Text("Yes"),
), ),
@ -295,6 +314,8 @@ class _HomePageState extends State<HomePage> {
SessionData.GetNewDelivery(); SessionData.GetNewDelivery();
setState(() {}); setState(() {});
SessionData.DirtyState = true;
}, },
child: Text("Yes"), child: Text("Yes"),
), ),
@ -363,6 +384,8 @@ class _HomePageState extends State<HomePage> {
await SessionData.Logout(); await SessionData.Logout();
setState(() {}); setState(() {});
SessionData.DirtyState = true;
}, },
child: Text("Yes"), child: Text("Yes"),
), ),
@ -400,6 +423,8 @@ class _HomePageState extends State<HomePage> {
} }
class OverlayWidget extends StatefulWidget { class OverlayWidget extends StatefulWidget {
const OverlayWidget({super.key});
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
return _Overlay(); return _Overlay();

View file

@ -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 # 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 # 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. # 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: environment:
sdk: ^3.7.2 sdk: ^3.7.2