113 lines
3.9 KiB
Dart
113 lines
3.9 KiB
Dart
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});
|
|
|
|
@override
|
|
OpenSimPageState createState() => OpenSimPageState();
|
|
}
|
|
|
|
class OpenSimPageState extends State<OpenSimPage> {
|
|
Settings settings = Settings();
|
|
|
|
TextEditingController databaseHostController = TextEditingController();
|
|
TextEditingController databaseUsernameController = TextEditingController();
|
|
TextEditingController databasePasswordController = TextEditingController();
|
|
TextEditingController databaseNameController = TextEditingController();
|
|
TextEditingController PSKController = TextEditingController();
|
|
|
|
@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 bool == true) {
|
|
setState(() {
|
|
settings.OpenSimSetupCompleted = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Constants.TITLEBAR_COLOR,
|
|
title: Text("Zontreck.com - OpenSim Manager"),
|
|
),
|
|
body: Padding(
|
|
padding: EdgeInsets.all(8),
|
|
child: SingleChildScrollView(
|
|
child: settings.OpenSimSetupCompleted
|
|
? Column(
|
|
children: [],
|
|
)
|
|
: Column(
|
|
children: [
|
|
ListTile(
|
|
title: Text("Initial Setup Required"),
|
|
tileColor: Constants.TITLEBAR_COLOR,
|
|
),
|
|
ListTile(
|
|
title: Text("Database Host"),
|
|
subtitle: TextField(
|
|
controller: databaseHostController,
|
|
decoration:
|
|
InputDecoration(hintText: "example.com:3306"),
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text("Database Username"),
|
|
subtitle: TextField(
|
|
controller: databaseUsernameController,
|
|
decoration: InputDecoration(hintText: "Username"),
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text("Database Password"),
|
|
subtitle: TextField(
|
|
decoration:
|
|
InputDecoration(hintText: "****", hintMaxLines: 1),
|
|
obscureText: true,
|
|
obscuringCharacter: "*",
|
|
controller: databasePasswordController,
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text("Database Name"),
|
|
subtitle: TextField(
|
|
decoration:
|
|
InputDecoration(hintText: "acwi", hintMaxLines: 1),
|
|
controller: databaseNameController,
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text("PreShared Secret"),
|
|
subtitle: TextField(
|
|
controller: PSKController,
|
|
decoration: InputDecoration(
|
|
hintText:
|
|
"Pre-Shared Key. Long text that gets hashed"),
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
var PSK = await settings.hashPSK(PSKController.text);
|
|
|
|
setState(() {
|
|
PSKController.text = PSK;
|
|
});
|
|
},
|
|
child: Text("Submit"))
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|