Apply autofixes

This commit is contained in:
zontreck 2024-05-15 15:54:13 -07:00
parent 7c358d48e0
commit 10d7b8be65
5 changed files with 49 additions and 45 deletions

View file

@ -7,7 +7,7 @@ class Constants {
static const TITLEBAR_COLOR = Color.fromARGB(255, 97, 0, 0);
static const DRAWER_COLOR = Color.fromARGB(148, 0, 97, 97);
static const VERSION = "1.0.051524.1458";
static const VERSION = "1.0.051524.1554";
static const COPYRIGHT = "Copyright 2024 - Tara Piccari. All rights Reserved";
static const CLIENTPSK = "";

View file

@ -17,22 +17,22 @@ enum APIEndpoint {
String getURL() {
Settings settings = Settings();
return "${settings.API_SERVER}${path}${script}";
return "${settings.API_SERVER}$path$script";
}
}
enum HTTPMethod { Get, Post, Put, Delete }
class Settings {
static Settings? _inst = null;
Settings._() {}
static Settings? _inst;
Settings._();
Dio dio = Dio();
factory Settings() {
if (Settings._inst != null)
if (Settings._inst != null) {
return Settings._inst!;
else {
} else {
Settings._inst = Settings._();
return Settings._inst!;
}
@ -56,13 +56,13 @@ class Settings {
var port = js['api']['port'] as int;
var host = js['api']['host'] as String;
API_SERVER = "${protocol}://${host}:${port}/";
API_SERVER = "$protocol://$host:$port/";
}
Future<String> hashPSK(String PSK) async {
String hash = Hashing.md5Hash("AriasCreations");
for (int i = 0; i < 8192; i++) {
hash = Hashing.sha256Hash("${hash}:${PSK}");
hash = Hashing.sha256Hash("$hash:$PSK");
}
hash = Hashing.sha256Hash(hash);
@ -70,8 +70,8 @@ class Settings {
}
Future<String> createDerivedPSK(String hashedPSK, String purpose) async {
String hash = await hashPSK("${hashedPSK}:${purpose}");
return await hashPSK("${hash}:${hashedPSK}:${purpose}"); // The derived PSK
String hash = await hashPSK("$hashedPSK:$purpose");
return await hashPSK("$hash:$hashedPSK:$purpose"); // The derived PSK
}
Future<IPacket> sendPacketToEndpoint(

View file

@ -7,5 +7,5 @@ void main() async {
Settings settings = Settings();
var services = await Constants.pullServicesJson();
settings.setServices(services);
runApp(new MainPage());
runApp(const MainPage());
}

View file

@ -5,12 +5,14 @@ import 'package:zontreck/Constants.dart';
import 'package:zontreck/pages/OpenSim.dart';
class MainPage extends StatelessWidget {
const MainPage({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: {
"/": (context) => HomePage(),
"/opensim": (context) => OpenSimPage()
"/": (context) => const HomePage(),
"/opensim": (context) => const OpenSimPage()
},
theme: ThemeData.dark(),
);
@ -18,7 +20,7 @@ class MainPage extends StatelessWidget {
}
class HomePage extends StatefulWidget {
HomePage({super.key});
const HomePage({super.key});
@override
HomePageState createState() => HomePageState();
@ -30,10 +32,14 @@ class HomePageState extends State<HomePage> {
return Scaffold(
appBar: AppBar(
backgroundColor: Constants.TITLEBAR_COLOR,
title: Text("Zontreck.com"),
title: const Text("Zontreck.com"),
),
body: FooterView(
children: [
footer: Footer(
alignment: Alignment.center,
backgroundColor: ThemeData.dark().focusColor,
child: const Text("${Constants.COPYRIGHT}\n${Constants.VERSION}")),
children: const [
Column(
children: [
Center(
@ -49,17 +55,13 @@ class HomePageState extends State<HomePage> {
],
),
],
footer: Footer(
alignment: Alignment.center,
child: Text("${Constants.COPYRIGHT}\n${Constants.VERSION}"),
backgroundColor: ThemeData.dark().focusColor),
),
drawer: Drawer(
elevation: 8,
backgroundColor: Constants.DRAWER_COLOR,
child: Column(
children: [
DrawerHeader(
const DrawerHeader(
child: Column(
children: [
Text("Zontreck.com"),
@ -69,9 +71,9 @@ class HomePageState extends State<HomePage> {
],
)),
ListTile(
title: Text("O P E N S I M"),
leading: Icon(Icons.front_hand_outlined),
subtitle: Text("OpenSim management interface for private grid"),
title: const Text("O P E N S I M"),
leading: const Icon(Icons.front_hand_outlined),
subtitle: const Text("OpenSim management interface for private grid"),
onTap: () {
Navigator.pushNamed(context, "/opensim");
},

View file

@ -6,7 +6,7 @@ import 'package:zontreck/Packets.dart';
import 'package:zontreck/Settings.dart';
class OpenSimPage extends StatefulWidget {
OpenSimPage({super.key});
const OpenSimPage({super.key});
@override
OpenSimPageState createState() => OpenSimPageState();
@ -30,8 +30,9 @@ class OpenSimPageState extends State<OpenSimPage> {
var simpleReply = reply as S2CSimpleReplyPacket;
if (simpleReply.done) {
settings.OpenSimSetupCompleted = true;
} else
} else {
settings.OpenSimSetupCompleted = false;
}
var pong =
await settings.sendPacketToEndpoint(APIEndpoint.Ping, NullPacket());
@ -44,48 +45,48 @@ class OpenSimPageState extends State<OpenSimPage> {
return Scaffold(
appBar: AppBar(
backgroundColor: Constants.TITLEBAR_COLOR,
title: Text("Zontreck.com - OpenSim Manager"),
title: const Text("Zontreck.com - OpenSim Manager"),
),
body: FooterView(
footer: Footer(
alignment: Alignment.center,
child: Text("${Constants.COPYRIGHT}\n${Constants.VERSION}"),
backgroundColor: ThemeData.dark().focusColor),
backgroundColor: ThemeData.dark().focusColor,
child: const Text("${Constants.COPYRIGHT}\n${Constants.VERSION}")),
children: [
Padding(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
child: SingleChildScrollView(
child: settings.OpenSimSetupCompleted
? Column(
? const Column(
children: [],
)
: Column(
children: [
ListTile(
const ListTile(
title: Text("Initial Setup Required"),
subtitle: Text(
"Please use the same database/user as robust's database\n\nNOTE: Only MySQL/MariaDB is supported by this interface"),
tileColor: Constants.TITLEBAR_COLOR,
),
ListTile(
title: Text("Database Host"),
title: const Text("Database Host"),
subtitle: TextField(
controller: databaseHostController,
decoration:
InputDecoration(hintText: "example.com:3306"),
const InputDecoration(hintText: "example.com:3306"),
),
),
ListTile(
title: Text("Database Username"),
title: const Text("Database Username"),
subtitle: TextField(
controller: databaseUsernameController,
decoration: InputDecoration(hintText: "Username"),
decoration: const InputDecoration(hintText: "Username"),
),
),
ListTile(
title: Text("Database Password"),
title: const Text("Database Password"),
subtitle: TextField(
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: "****", hintMaxLines: 1),
obscureText: true,
obscuringCharacter: "*",
@ -93,23 +94,23 @@ class OpenSimPageState extends State<OpenSimPage> {
),
),
ListTile(
title: Text("Database Name"),
title: const Text("Database Name"),
subtitle: TextField(
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: "acwi", hintMaxLines: 1),
controller: databaseNameController,
),
),
ListTile(
const ListTile(
title: Text(
"For the PreShared Secret, please enter any text you wish. This is hashed 8192 times for the server key. And an additional 16384 times for the client, and any derived key thereafter"),
tileColor: Constants.TITLEBAR_COLOR,
),
ListTile(
title: Text("PreShared Secret"),
title: const Text("PreShared Secret"),
subtitle: TextField(
controller: PSKController,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText:
"Pre-Shared Key. Some text that gets hashed several thousand times to create a server and client key"),
),
@ -138,12 +139,13 @@ class OpenSimPageState extends State<OpenSimPage> {
if (responsePacket.done) {
settings.OpenSimSetupCompleted = true;
} else
} else {
settings.OpenSimSetupCompleted = false;
}
setState(() {});
},
child: Text("Submit"))
child: const Text("Submit"))
],
),
),