Do some refactoring for protocol v2
This commit is contained in:
parent
d9c79a4ee9
commit
8adaf6169a
5 changed files with 122 additions and 3 deletions
|
@ -411,7 +411,7 @@ class _HomePageState extends State<HomePage> {
|
|||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"You are now on the clock\nYour location is being tracked for record keeping purposes.\n\nYou started ${SessionData.GetTotalTimeWorked(SessionData.StartTime, DateTime.now())} ago\n\n",
|
||||
"Your location is being tracked for record keeping purposes.\n\nYou started ${SessionData.GetTotalTimeWorked(SessionData.StartTime, DateTime.now())} ago\n\n",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
if (SessionData.currentTrip != null) GetTripWidgets(),
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:timetrack/consts.dart';
|
||||
|
@ -19,9 +21,31 @@ class _WebMain extends State<WebMain> {
|
|||
@override
|
||||
void didChangeDependencies() {
|
||||
sessionIDController.text = SessionData.LastSessionID;
|
||||
|
||||
// Check if FirstRun
|
||||
if (SessionData.Calls.HomeCallback == null) {
|
||||
SessionData.Calls.HomeCallback = _callback;
|
||||
// After doing this, we also want to schedule the timer
|
||||
Timer.periodic(Duration(seconds: 5), (timer) async {
|
||||
if (!SessionData.Recording) {
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the latest version number, compare, then redownload the data.
|
||||
int ver = await SessionData.FetchVersion();
|
||||
if (ver != SessionData.RecordingVersion) {
|
||||
await SessionData.DownloadData();
|
||||
}
|
||||
});
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
Future<void> _callback() async {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -132,6 +156,14 @@ class _WebMain extends State<WebMain> {
|
|||
),
|
||||
tileColor: const Color.fromARGB(255, 7, 123, 255),
|
||||
),
|
||||
if (SessionData.Recording)
|
||||
ListTile(
|
||||
title: Text("LIVE SESSION"),
|
||||
subtitle: Text(
|
||||
"This session is live! Recording is still in progress. Over time this live view will automatically refresh until the recording is ended.\n\nSession Version: ${SessionData.RecordingVersion}",
|
||||
),
|
||||
tileColor: LibACFlutterConstants.TITLEBAR_COLOR,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await showDialog(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue