Remove everything to do with pay and only track miles and hours worked.

This commit is contained in:
zontreck 2025-05-17 00:33:41 -07:00
parent 9b50945e3b
commit ee0fed6d6b
6 changed files with 44 additions and 110 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.3"; static const VERSION = "1.0.0-beta.4";
static bool UPDATE_AVAILABLE = false; static bool UPDATE_AVAILABLE = false;
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta; static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;

View file

@ -18,7 +18,7 @@ class SessionData {
static Delivery? currentDelivery; static Delivery? currentDelivery;
static Trip? currentTrip; static Trip? currentTrip;
static List<Position> positions = []; static List<SmallPosition> positions = [];
static late StreamSubscription<Position> _listener; static late StreamSubscription<Position> _listener;
static Callbacks Calls = Callbacks(); static Callbacks Calls = Callbacks();
static String LastSessionID = ""; static String LastSessionID = "";
@ -27,30 +27,6 @@ class SessionData {
/// This flag is usually set when data is loaded from a saved state. Or when accessed using the Web version of the app. /// This flag is usually set when data is loaded from a saved state. Or when accessed using the Web version of the app.
static bool IsReadOnly = false; static bool IsReadOnly = false;
static double GetTotalBasePay() {
double total = 0;
for (var trip in Trips) {
total += trip.BasePay;
}
return total;
}
static double GetTotalTips() {
double total = 0;
for (var trip in Trips) {
for (var drop in trip.deliveries) {
total += drop.TipAmount;
}
}
return total;
}
static double GetTotalPay() {
return GetTotalBasePay() + GetTotalTips();
}
static double GetTotalMiles() { static double GetTotalMiles() {
double total = 0; double total = 0;
total = _totalMilesTraveled( total = _totalMilesTraveled(
@ -106,7 +82,7 @@ class SessionData {
/// * [minDistanceMeters] drop segments shorter than this (jitter). /// * [minDistanceMeters] drop segments shorter than this (jitter).
/// * [maxDistanceMeters] drop segments longer than this (impossible jump). /// * [maxDistanceMeters] drop segments longer than this (impossible jump).
static double _totalMilesTraveled( static double _totalMilesTraveled(
List<Position> positions, { List<SmallPosition> positions, {
double minDistanceMeters = 5, double minDistanceMeters = 5,
double? maxDistanceMeters, double? maxDistanceMeters,
}) { }) {
@ -171,7 +147,7 @@ class SessionData {
_listener.cancel(); _listener.cancel();
return; return;
} }
positions.add(pos); positions.add(SmallPosition.fromPosition(pos));
SessionData.Calls.dispatch(); SessionData.Calls.dispatch();
}); });
@ -214,7 +190,7 @@ class SessionData {
List<Map<String, dynamic>> _pos = []; List<Map<String, dynamic>> _pos = [];
for (var pos in positions) { for (var pos in positions) {
_pos.add(pos.toJson()); _pos.add(pos.toMap());
} }
saveData["trips"] = _trips; saveData["trips"] = _trips;
@ -252,7 +228,7 @@ class SessionData {
} }
for (var position in _pos) { for (var position in _pos) {
positions.add(Position.fromMap(position)); positions.add(SmallPosition.fromMap(position));
} }
IsReadOnly = true; IsReadOnly = true;
@ -266,8 +242,8 @@ class SessionData {
return pos; return pos;
} }
static Trip GetNewTrip({required double basePay}) { static Trip GetNewTrip() {
currentTrip = Trip(BasePay: basePay); currentTrip = Trip();
Trips.add(currentTrip!); Trips.add(currentTrip!);
return currentTrip!; return currentTrip!;
} }
@ -290,7 +266,6 @@ class SessionData {
} }
class Delivery { class Delivery {
double TipAmount = 0;
Position? endLocation; Position? endLocation;
DateTime StartTime = DateTime.now(); DateTime StartTime = DateTime.now();
@ -305,7 +280,6 @@ class Delivery {
Map<String, dynamic> toJsonMap() { Map<String, dynamic> toJsonMap() {
return { return {
"tip": TipAmount,
"start": StartTime.toString(), "start": StartTime.toString(),
"endPos": endLocation?.toJson() ?? "incomplete", "endPos": endLocation?.toJson() ?? "incomplete",
}; };
@ -314,7 +288,6 @@ class Delivery {
static Delivery fromMap(Map<String, dynamic> jsx) { static Delivery fromMap(Map<String, dynamic> jsx) {
Delivery delivery = Delivery(); Delivery delivery = Delivery();
delivery.StartTime = DateTime.parse(jsx['start'] as String); delivery.StartTime = DateTime.parse(jsx['start'] as String);
delivery.TipAmount = jsx['tip'] as double;
if (jsx['endPos'] as String == "incomplete") if (jsx['endPos'] as String == "incomplete")
delivery.endLocation = null; delivery.endLocation = null;
else else
@ -329,9 +302,7 @@ class Trip {
DateTime StartTime = DateTime(0); DateTime StartTime = DateTime(0);
double BasePay = 0.0; Trip() {
Trip({required this.BasePay}) {
StartTime = DateTime.now(); StartTime = DateTime.now();
} }
@ -343,7 +314,7 @@ class Trip {
} }
Map<String, dynamic> toJsonMap() { Map<String, dynamic> toJsonMap() {
Map<String, Object> _trip = {"start": StartTime.toString(), "pay": BasePay}; Map<String, Object> _trip = {"start": StartTime.toString()};
List<Map<String, dynamic>> _dropOffs = []; List<Map<String, dynamic>> _dropOffs = [];
for (var delivery in deliveries) { for (var delivery in deliveries) {
_dropOffs.add(delivery.toJsonMap()); _dropOffs.add(delivery.toJsonMap());
@ -355,8 +326,7 @@ class Trip {
} }
static Trip fromJsonMap(Map<String, dynamic> jsx) { static Trip fromJsonMap(Map<String, dynamic> jsx) {
Trip trip = Trip(BasePay: 0); Trip trip = Trip();
trip.BasePay = jsx['pay'] as double;
trip.StartTime = DateTime.parse(jsx['start'] as String); trip.StartTime = DateTime.parse(jsx['start'] as String);
trip.deliveries = []; trip.deliveries = [];
List<Map<String, dynamic>> _dropOffs = List<Map<String, dynamic>> _dropOffs =
@ -383,3 +353,29 @@ class Callbacks {
if (WorkDataCallback != null) WorkDataCallback!(); if (WorkDataCallback != null) WorkDataCallback!();
} }
} }
/// A simple wrapper for a position that strips away unnecessary information to create a more compact piece of save data
class SmallPosition {
double latitude;
double longitude;
SmallPosition({required this.latitude, required this.longitude});
static SmallPosition fromPosition(Position position) {
return SmallPosition(
latitude: position.latitude,
longitude: position.longitude,
);
}
Map<String, dynamic> toMap() {
return {"latitude": latitude, "longitude": longitude};
}
static SmallPosition fromMap(Map<String, dynamic> map) {
return SmallPosition(
latitude: map['latitude'] as double,
longitude: map['longitude'] as double,
);
}
}

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:libacflutter/Constants.dart'; import 'package:libacflutter/Constants.dart';
import 'package:libacflutter/Prompt.dart';
import 'package:timetrack/consts.dart'; import 'package:timetrack/consts.dart';
import 'package:timetrack/data.dart'; import 'package:timetrack/data.dart';
@ -151,10 +150,7 @@ class _HomePageState extends State<HomePage> {
Widget GetTripWidgets() { Widget GetTripWidgets() {
return Column( return Column(
children: [ children: [
Text( Text("Trip started", style: TextStyle(fontSize: 18)),
"Trip started; Base Pay: \$${SessionData.currentTrip!.BasePay}",
style: TextStyle(fontSize: 18),
),
Text( Text(
"To end both your current delivery, and the trip, tap on END TRIP", "To end both your current delivery, and the trip, tap on END TRIP",
style: TextStyle(fontSize: 18), style: TextStyle(fontSize: 18),
@ -164,20 +160,6 @@ class _HomePageState extends State<HomePage> {
), ),
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
var reply = await showDialog(
context: context,
builder: (bld) {
return InputPrompt(
title: "What was the tip?",
prompt: "If there was no tip, enter a 0, or just hit submit.",
type: InputPromptType.Number,
);
},
);
if (reply == null || reply == "") reply = "0";
double tip = double.parse(reply as String);
SessionData.currentDelivery!.TipAmount = tip;
SessionData.currentDelivery!.MarkEndLocation(); SessionData.currentDelivery!.MarkEndLocation();
SessionData.EndTrip(); SessionData.EndTrip();
@ -195,21 +177,6 @@ class _HomePageState extends State<HomePage> {
children: [ children: [
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
var reply = await showDialog(
context: context,
builder: (bld) {
return InputPrompt(
title: "What was the tip?",
prompt:
"If there was no tip, enter a 0, or hit submit and leave blank",
type: InputPromptType.Number,
);
},
);
if (reply == null || reply == "") reply = "0";
double tip = double.parse(reply as String);
SessionData.currentDelivery!.TipAmount = tip;
SessionData.currentDelivery!.MarkEndLocation(); SessionData.currentDelivery!.MarkEndLocation();
SessionData.GetNewDelivery(); SessionData.GetNewDelivery();
@ -226,20 +193,7 @@ class _HomePageState extends State<HomePage> {
children: [ children: [
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
var reply = await showDialog( SessionData.GetNewTrip();
context: context,
builder: (builder) {
return InputPrompt(
title: "What is the base pay?",
prompt: "Enter the base pay amount below.",
type: InputPromptType.Number,
);
},
);
if (reply == null || reply == "") reply = "0";
double basePay = double.parse(reply as String);
SessionData.GetNewTrip(basePay: basePay);
SessionData.GetNewDelivery(); SessionData.GetNewDelivery();
setState(() {}); setState(() {});

View file

@ -67,9 +67,6 @@ class _MapPage extends State<MapPage> {
title: Text( title: Text(
"Trip #${SessionData.Trips.indexOf(trip) + 1}; DropOff #${trip.deliveries.indexOf(dropOff) + 1}", "Trip #${SessionData.Trips.indexOf(trip) + 1}; DropOff #${trip.deliveries.indexOf(dropOff) + 1}",
), ),
content: Text(
"Pay: \$${trip.BasePay}\nTip: \$${dropOff.TipAmount}",
),
); );
}, },
); );

View file

@ -51,23 +51,7 @@ class _WorkData extends State<WorkDataPage> {
style: TextStyle(fontSize: 18), style: TextStyle(fontSize: 18),
), ),
SizedBox(height: 20), SizedBox(height: 20),
Text(
"Total Trips: ${SessionData.Trips.length}",
style: TextStyle(fontSize: 18),
),
Text(
"Total Base Pay: \$${SessionData.GetTotalBasePay()}",
style: TextStyle(fontSize: 18),
),
Text(
"Total Tips: \$${SessionData.GetTotalTips()}",
style: TextStyle(fontSize: 18),
),
Text(
"Total Earnings: \$${SessionData.GetTotalPay()}",
style: TextStyle(fontSize: 18),
),
SizedBox(height: 20),
Text( Text(
"Total Estimated Miles: ${SessionData.GetTotalMilesAsString()}\n(Note: The miles displayed above may not be 100% accurate)", "Total Estimated Miles: ${SessionData.GetTotalMilesAsString()}\n(Note: The miles displayed above may not be 100% accurate)",
style: TextStyle(fontSize: 24), style: TextStyle(fontSize: 24),

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.3 version: 1.0.0-beta.4
environment: environment:
sdk: ^3.7.2 sdk: ^3.7.2
@ -67,6 +67,9 @@ flutter:
# the material Icons class. # the material Icons class.
uses-material-design: true uses-material-design: true
assets:
- server/php/timetrack.php
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg