Begin implementing GPS related functions, and initial UI for trip and delivery
This commit is contained in:
parent
061fd46f89
commit
770c1e7c74
6 changed files with 276 additions and 3 deletions
|
@ -1,6 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:libac_dart/utils/TimeUtils.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:libacflutter/Prompt.dart';
|
||||
import 'package:timetrack/consts.dart';
|
||||
import 'package:timetrack/data.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
@ -51,10 +54,150 @@ class _HomePageState extends State<HomePage> {
|
|||
},
|
||||
leading: Icon(Icons.update),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("RESET APP SESSION"),
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
SessionData.IsOnTheClock = false;
|
||||
SessionData.StartTime = 0;
|
||||
SessionData.Trips = [];
|
||||
SessionData.currentDelivery = null;
|
||||
SessionData.currentTrip = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if (!SessionData.IsOnTheClock)
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
SessionData.Login();
|
||||
});
|
||||
},
|
||||
child: Text("ENGAGE"),
|
||||
),
|
||||
),
|
||||
|
||||
if (SessionData.IsOnTheClock) GetLoggedInWidgets(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget GetTripWidgets() {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"Trip started; Base Pay: \$${SessionData.currentTrip!.BasePay}",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
Text(
|
||||
"To end both your current delivery, and the trip, tap on END TRIP",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
Text(
|
||||
"You are currently on Delivery #${SessionData.currentTrip!.deliveries.length}",
|
||||
),
|
||||
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();
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: Text("END TRIP"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget GetDeliveryWidgets() {
|
||||
return Column(
|
||||
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();
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: Text("Start new delivery"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget GetLoggedInWidgets() {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"You are now on the clock\nYour location is being tracked for record keeping purposes.\n\nYou started at ${SessionData.StartTimeAsDateTime}\n\n",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
if (SessionData.currentTrip != null) GetTripWidgets(),
|
||||
if (SessionData.currentDelivery != null) GetDeliveryWidgets(),
|
||||
if (SessionData.currentTrip == null)
|
||||
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.GetNewDelivery();
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: Text("Start New Trip"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue