Upload current progress. bedtime
This commit is contained in:
parent
c0eef32f56
commit
d79133974c
2 changed files with 41 additions and 1 deletions
|
@ -1,6 +1,20 @@
|
|||
import 'package:dio/dio.dart';
|
||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||
|
||||
enum APIEndpoint {
|
||||
SetupCheck(script: "SetupCheck.php", path: "/ac/home/"),
|
||||
Login(script: "Login.php", path: "/ac/home/");
|
||||
|
||||
final String script;
|
||||
final String path;
|
||||
const APIEndpoint({required this.script, required this.path});
|
||||
|
||||
String getURL() {
|
||||
Settings settings = Settings();
|
||||
return "${settings.API_SERVER}${path}${script}";
|
||||
}
|
||||
}
|
||||
|
||||
class Settings {
|
||||
static Settings? _inst = null;
|
||||
Settings._() {}
|
||||
|
@ -25,6 +39,7 @@ class Settings {
|
|||
}
|
||||
|
||||
String API_SERVER = "";
|
||||
bool OpenSimSetupCompleted = false;
|
||||
|
||||
void setServices(Map<String, dynamic> js) {
|
||||
var protocol = js['api']['protocol'] as String;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:zontreck/Constants.dart';
|
||||
import 'package:zontreck/Settings.dart';
|
||||
|
||||
class OpenSimPage extends StatefulWidget {
|
||||
OpenSimPage({super.key});
|
||||
|
@ -9,6 +12,21 @@ class OpenSimPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class OpenSimPageState extends State<OpenSimPage> {
|
||||
Settings settings = Settings();
|
||||
|
||||
@override
|
||||
Future<void> didChangeDependencies() async {
|
||||
// Send check for setup completion
|
||||
var reply = await settings.dio.get(APIEndpoint.SetupCheck.getURL());
|
||||
|
||||
var replyJson = json.decode(reply.data);
|
||||
if (replyJson['done'] as String == "true") {
|
||||
setState(() {
|
||||
settings.OpenSimSetupCompleted = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -20,7 +38,14 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
padding: EdgeInsets.all(8),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [],
|
||||
children: [
|
||||
settings.OpenSimSetupCompleted
|
||||
? ListTile(
|
||||
title: Text("Login Required"),
|
||||
tileColor: Constants.TITLEBAR_COLOR,
|
||||
)
|
||||
: Text("You need to set up the database")
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue