Make some changes to the PHP URL to make it channel specific
This commit is contained in:
parent
762be79df6
commit
7c5e3360a5
6 changed files with 37 additions and 13 deletions
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"alpha": "1.0.0-dev.10"
|
||||
"alpha": "1.0.0-dev.10",
|
||||
"beta": "1.0.0-beta.1"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
@ -7,7 +6,10 @@ import 'package:geolocator/geolocator.dart';
|
|||
class TTConsts {
|
||||
static get UPDATE_URL =>
|
||||
"https://git.zontreck.com/AriasCreations/TimeTracker/raw/branch/main/latest-releases.json";
|
||||
static const VERSION = "1.0.0-dev.10";
|
||||
static get SESSION_SERVER =>
|
||||
"https://api.zontreck.com/timetrack/${UPDATE_CHANNEL}/timetrack.php";
|
||||
|
||||
static const VERSION = "1.0.0-beta.1";
|
||||
|
||||
static bool UPDATE_AVAILABLE = false;
|
||||
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.alpha;
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'dart:convert';
|
|||
import 'dart:math' as math;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:libac_dart/nbt/Stream.dart';
|
||||
import 'package:timetrack/consts.dart';
|
||||
|
@ -19,6 +21,7 @@ class SessionData {
|
|||
static List<Position> positions = [];
|
||||
static late StreamSubscription<Position> _listener;
|
||||
static Callbacks Calls = Callbacks();
|
||||
static String LastSessionID = "";
|
||||
|
||||
/// 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;
|
||||
|
@ -185,10 +188,22 @@ class SessionData {
|
|||
Trips = [];
|
||||
positions = [];
|
||||
|
||||
// TODO: Upload to the server.
|
||||
Dio dio = Dio();
|
||||
Map<String, dynamic> payload = {"cmd": "create", "data": saveData};
|
||||
|
||||
var reply = await dio.post(
|
||||
TTConsts.SESSION_SERVER,
|
||||
data: json.encode(payload),
|
||||
);
|
||||
Map<String, dynamic> replyJs = json.decode(reply.data as String);
|
||||
if (replyJs["status"] == "ok") {
|
||||
print("Successful upload");
|
||||
LastSessionID = replyJs['session'] as String;
|
||||
Calls.dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
static String SaveData() {
|
||||
static Map<String, dynamic> SaveData() {
|
||||
Map<String, dynamic> saveData = {};
|
||||
|
||||
List<Map<String, dynamic>> _trips = [];
|
||||
|
@ -204,7 +219,7 @@ class SessionData {
|
|||
saveData["trips"] = _trips;
|
||||
saveData["positions"] = _pos;
|
||||
|
||||
return json.encode(saveData);
|
||||
return saveData;
|
||||
}
|
||||
|
||||
void LoadData(String js) {
|
||||
|
|
|
@ -112,10 +112,17 @@ class _HomePageState extends State<HomePage> {
|
|||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Hit engage when you are ready to go online and start tracking location data, and trips.",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
if (!SessionData.IsOnTheClock)
|
||||
Text(
|
||||
"Hit engage when you are ready to go online and start tracking location data, and trips.",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
|
||||
if (SessionData.LastSessionID.isNotEmpty)
|
||||
Text(
|
||||
"Session ID Code: ${SessionData.LastSessionID}",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
if (!SessionData.IsOnTheClock)
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:timetrack/consts.dart';
|
||||
import 'package:timetrack/data.dart';
|
||||
|
||||
class WorkDataPage extends StatefulWidget {
|
||||
|
@ -70,7 +69,7 @@ class _WorkData extends State<WorkDataPage> {
|
|||
),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
"Total Miles: ${SessionData.GetTotalMilesAsString()}",
|
||||
"Total Estimated Miles: ${SessionData.GetTotalMilesAsString()}\n(Note: The miles displayed above may not be 100% accurate)",
|
||||
style: TextStyle(fontSize: 24),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -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
|
||||
# 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.
|
||||
version: 1.0.0-dev.10
|
||||
version: 1.0.0-beta.1
|
||||
|
||||
environment:
|
||||
sdk: ^3.7.2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue