import 'package:flutter/material.dart'; import 'package:libacflutter/Constants.dart'; import 'package:timetrack/data.dart'; class WorkDataPage extends StatefulWidget { const WorkDataPage({super.key}); @override State createState() { return _WorkData(); } } class _WorkData extends State { void call() { setState(() {}); } @override void initState() { SessionData.Calls.WorkDataCallback = call; super.initState(); } @override void dispose() { SessionData.Calls.WorkDataCallback = null; super.dispose(); } Widget GetDurationWidgets() { return Column( children: [ Text("Paid Driving Hours: ${SessionData.GetPaidHours()}"), Text("Unpaid Driving Hours: ${SessionData.GetUnpaidHours()}"), ], ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Time Tracker - Work Data"), backgroundColor: LibACFlutterConstants.TITLEBAR_COLOR, ), body: Padding( padding: EdgeInsets.all(8), child: SingleChildScrollView( child: Column( children: [ // This is where we'll display all the work data, like total earnings, and present a editor Text( "Total saved GPS Positions: ${SessionData.positions.length}", style: TextStyle(fontSize: 18), ), if (SessionData.StartTime.year > 2000) Text( "Start Date & Time: ${SessionData.StartTime.toString()}", style: TextStyle(fontSize: 18), ), if (SessionData.IsReadOnly && SessionData.StartTime.year > 2000) Text( "End Date & Time: ${SessionData.EndTime.toString()}", style: TextStyle(fontSize: 18), ), if (SessionData.StartTime.year > 2000) Text( "Total time worked: ${SessionData.GetTotalTimeWorked(SessionData.StartTime, SessionData.EndTime)}", style: TextStyle(fontSize: 18), ), if (SessionData.StartTime.year < 2000) ListTile( title: Text("ERROR"), subtitle: Text( "This TTX session file appears to have been saved in an early alpha version. It does not contain the Start time or End timestamp information.", ), tileColor: LibACFlutterConstants.TITLEBAR_COLOR, ), SizedBox(height: 10), if (SessionData.TotalPay == null) ListTile( title: Text("ERROR"), subtitle: Text( "This TTX session file appears to have been saved in a early beta build. It does not contain the total pay.", ), tileColor: LibACFlutterConstants.TITLEBAR_COLOR, ), if (SessionData.ContainsTripTimes) GetDurationWidgets(), if (!SessionData.ContainsTripTimes) ListTile( title: Text("ERROR"), subtitle: Text( "This TTX session file is older than Beta 13. It does not contain trip end times. For that reason, the app cannot display the paid driving hours and unpaid driving hours.", ), tileColor: LibACFlutterConstants.TITLEBAR_COLOR, ), if (SessionData.TotalPay != null) Text( "Total Pay: \$${SessionData.TotalPay!}", style: TextStyle(fontSize: 18), ), SizedBox(height: 20), Text( "Total Estimated Miles: ${SessionData.GetTotalMilesAsString()}\n(Note: The miles displayed above may not be 100% accurate)", style: TextStyle(fontSize: 24), ), SizedBox(height: 40), Text( "Total Number of Trips: ${SessionData.Trips.length}", style: TextStyle(fontSize: 18), ), Text( "Total Deliveries: ${SessionData.GetTotalDeliveries()}", style: TextStyle(fontSize: 18), ), ElevatedButton( onPressed: () async { // Process data export to GPX format. }, child: Text("Export as GPX"), ), ], ), ), ), ); } }