Remove everything to do with pay and only track miles and hours worked.
This commit is contained in:
parent
9b50945e3b
commit
ee0fed6d6b
6 changed files with 44 additions and 110 deletions
|
@ -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.3";
|
||||
static const VERSION = "1.0.0-beta.4";
|
||||
|
||||
static bool UPDATE_AVAILABLE = false;
|
||||
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;
|
||||
|
|
|
@ -18,7 +18,7 @@ class SessionData {
|
|||
|
||||
static Delivery? currentDelivery;
|
||||
static Trip? currentTrip;
|
||||
static List<Position> positions = [];
|
||||
static List<SmallPosition> positions = [];
|
||||
static late StreamSubscription<Position> _listener;
|
||||
static Callbacks Calls = Callbacks();
|
||||
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.
|
||||
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() {
|
||||
double total = 0;
|
||||
total = _totalMilesTraveled(
|
||||
|
@ -106,7 +82,7 @@ class SessionData {
|
|||
/// * [minDistanceMeters] – drop segments shorter than this (jitter).
|
||||
/// * [maxDistanceMeters] – drop segments longer than this (impossible jump).
|
||||
static double _totalMilesTraveled(
|
||||
List<Position> positions, {
|
||||
List<SmallPosition> positions, {
|
||||
double minDistanceMeters = 5,
|
||||
double? maxDistanceMeters,
|
||||
}) {
|
||||
|
@ -171,7 +147,7 @@ class SessionData {
|
|||
_listener.cancel();
|
||||
return;
|
||||
}
|
||||
positions.add(pos);
|
||||
positions.add(SmallPosition.fromPosition(pos));
|
||||
|
||||
SessionData.Calls.dispatch();
|
||||
});
|
||||
|
@ -214,7 +190,7 @@ class SessionData {
|
|||
|
||||
List<Map<String, dynamic>> _pos = [];
|
||||
for (var pos in positions) {
|
||||
_pos.add(pos.toJson());
|
||||
_pos.add(pos.toMap());
|
||||
}
|
||||
|
||||
saveData["trips"] = _trips;
|
||||
|
@ -252,7 +228,7 @@ class SessionData {
|
|||
}
|
||||
|
||||
for (var position in _pos) {
|
||||
positions.add(Position.fromMap(position));
|
||||
positions.add(SmallPosition.fromMap(position));
|
||||
}
|
||||
|
||||
IsReadOnly = true;
|
||||
|
@ -266,8 +242,8 @@ class SessionData {
|
|||
return pos;
|
||||
}
|
||||
|
||||
static Trip GetNewTrip({required double basePay}) {
|
||||
currentTrip = Trip(BasePay: basePay);
|
||||
static Trip GetNewTrip() {
|
||||
currentTrip = Trip();
|
||||
Trips.add(currentTrip!);
|
||||
return currentTrip!;
|
||||
}
|
||||
|
@ -290,7 +266,6 @@ class SessionData {
|
|||
}
|
||||
|
||||
class Delivery {
|
||||
double TipAmount = 0;
|
||||
Position? endLocation;
|
||||
DateTime StartTime = DateTime.now();
|
||||
|
||||
|
@ -305,7 +280,6 @@ class Delivery {
|
|||
|
||||
Map<String, dynamic> toJsonMap() {
|
||||
return {
|
||||
"tip": TipAmount,
|
||||
"start": StartTime.toString(),
|
||||
"endPos": endLocation?.toJson() ?? "incomplete",
|
||||
};
|
||||
|
@ -314,7 +288,6 @@ class Delivery {
|
|||
static Delivery fromMap(Map<String, dynamic> jsx) {
|
||||
Delivery delivery = Delivery();
|
||||
delivery.StartTime = DateTime.parse(jsx['start'] as String);
|
||||
delivery.TipAmount = jsx['tip'] as double;
|
||||
if (jsx['endPos'] as String == "incomplete")
|
||||
delivery.endLocation = null;
|
||||
else
|
||||
|
@ -329,9 +302,7 @@ class Trip {
|
|||
|
||||
DateTime StartTime = DateTime(0);
|
||||
|
||||
double BasePay = 0.0;
|
||||
|
||||
Trip({required this.BasePay}) {
|
||||
Trip() {
|
||||
StartTime = DateTime.now();
|
||||
}
|
||||
|
||||
|
@ -343,7 +314,7 @@ class Trip {
|
|||
}
|
||||
|
||||
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 = [];
|
||||
for (var delivery in deliveries) {
|
||||
_dropOffs.add(delivery.toJsonMap());
|
||||
|
@ -355,8 +326,7 @@ class Trip {
|
|||
}
|
||||
|
||||
static Trip fromJsonMap(Map<String, dynamic> jsx) {
|
||||
Trip trip = Trip(BasePay: 0);
|
||||
trip.BasePay = jsx['pay'] as double;
|
||||
Trip trip = Trip();
|
||||
trip.StartTime = DateTime.parse(jsx['start'] as String);
|
||||
trip.deliveries = [];
|
||||
List<Map<String, dynamic>> _dropOffs =
|
||||
|
@ -383,3 +353,29 @@ class Callbacks {
|
|||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:libacflutter/Prompt.dart';
|
||||
import 'package:timetrack/consts.dart';
|
||||
import 'package:timetrack/data.dart';
|
||||
|
||||
|
@ -151,10 +150,7 @@ class _HomePageState extends State<HomePage> {
|
|||
Widget GetTripWidgets() {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"Trip started; Base Pay: \$${SessionData.currentTrip!.BasePay}",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
Text("Trip started", style: TextStyle(fontSize: 18)),
|
||||
Text(
|
||||
"To end both your current delivery, and the trip, tap on END TRIP",
|
||||
style: TextStyle(fontSize: 18),
|
||||
|
@ -164,20 +160,6 @@ class _HomePageState extends State<HomePage> {
|
|||
),
|
||||
ElevatedButton(
|
||||
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.EndTrip();
|
||||
|
@ -195,21 +177,6 @@ class _HomePageState extends State<HomePage> {
|
|||
children: [
|
||||
ElevatedButton(
|
||||
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.GetNewDelivery();
|
||||
|
||||
|
@ -226,20 +193,7 @@ class _HomePageState extends State<HomePage> {
|
|||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
var reply = await showDialog(
|
||||
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.GetNewTrip();
|
||||
SessionData.GetNewDelivery();
|
||||
|
||||
setState(() {});
|
||||
|
|
|
@ -67,9 +67,6 @@ class _MapPage extends State<MapPage> {
|
|||
title: Text(
|
||||
"Trip #${SessionData.Trips.indexOf(trip) + 1}; DropOff #${trip.deliveries.indexOf(dropOff) + 1}",
|
||||
),
|
||||
content: Text(
|
||||
"Pay: \$${trip.BasePay}\nTip: \$${dropOff.TipAmount}",
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -51,23 +51,7 @@ class _WorkData extends State<WorkDataPage> {
|
|||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
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(
|
||||
"Total Estimated Miles: ${SessionData.GetTotalMilesAsString()}\n(Note: The miles displayed above may not be 100% accurate)",
|
||||
style: TextStyle(fontSize: 24),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue