Small fixes

This commit is contained in:
zontreck 2024-05-17 17:40:04 -07:00
parent a54d0e4c0f
commit 043b06dedc
8 changed files with 2678 additions and 93 deletions

2597
lib/LastNames.dart Normal file

File diff suppressed because it is too large Load diff

View file

@ -63,8 +63,9 @@ class Settings {
NbtUtils.writeBoolean(tag, "loggedIn", settings.loggedIn);
tag.put("name", StringTag.valueOf(settings.userName));
tag.put("display", StringTag.valueOf(settings.displayName));
if (settings.currentUser != null)
if (settings.currentUser != null) {
tag.put("user", settings.currentUser!.save());
}
return tag;
}

View file

@ -8,7 +8,7 @@ import 'package:zontreck/Packets.dart';
import 'package:zontreck/Settings.dart';
class LoginAccountPage extends StatefulWidget {
LoginAccountPage({super.key});
const LoginAccountPage({super.key});
@override
State<StatefulWidget> createState() => LoginAccountState();
@ -25,35 +25,35 @@ class LoginAccountState extends State<LoginAccountPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("OpenSim - Login"),
title: const Text("OpenSim - Login"),
backgroundColor: Constants.TITLEBAR_COLOR,
),
body: Padding(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
child: SingleChildScrollView(
child: Column(
children: [
ListTile(
title: Text("First Name"),
title: const Text("First Name"),
subtitle: TextField(
controller: first,
decoration: InputDecoration(hintText: "Jane"),
decoration: const InputDecoration(hintText: "Jane"),
),
),
ListTile(
title: Text("Last Name"),
title: const Text("Last Name"),
subtitle: TextField(
controller: last,
decoration: InputDecoration(hintText: "Smith"),
decoration: const InputDecoration(hintText: "Smith"),
),
),
ListTile(
title: Text("Password"),
title: const Text("Password"),
subtitle: TextField(
controller: pass,
obscureText: true,
obscuringCharacter: "*",
decoration: InputDecoration(hintText: "*******"),
decoration: const InputDecoration(hintText: "*******"),
),
),
ElevatedButton(
@ -68,7 +68,7 @@ class LoginAccountState extends State<LoginAccountPage> {
print("RESPONSE : ${response.encode()}");
if (response.loggedIn) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Login success")));
const SnackBar(content: Text("Login success")));
settings.loggedIn = true;
settings.currentUser = response.user;
@ -87,7 +87,7 @@ class LoginAccountState extends State<LoginAccountPage> {
"Error while logging in: ${response.reason}")));
}
},
child: Text("Login"))
child: const Text("Login"))
],
),
),

View file

@ -16,10 +16,10 @@ class MainPage extends StatelessWidget {
routes: {
"/": (context) => const HomePage(),
"/opensim": (context) => const OpenSimPage(),
"/opensim/register": (context) => RegisterAccountPage(),
"/opensim/login": (context) => LoginAccountPage(),
"/portfolio": (context) => PortfolioPage(),
"/portfolio/coun": (context) => CardsOfUtterNonsense()
"/opensim/register": (context) => const RegisterAccountPage(),
"/opensim/login": (context) => const LoginAccountPage(),
"/portfolio": (context) => const PortfolioPage(),
"/portfolio/coun": (context) => const CardsOfUtterNonsense()
},
theme: ThemeData.dark(),
);
@ -87,9 +87,9 @@ class HomePageState extends State<HomePage> {
},
),
ListTile(
title: Text("P O R T F O L I O"),
subtitle: Text("View my work"),
leading: Icon(Icons.book_online),
title: const Text("P O R T F O L I O"),
subtitle: const Text("View my work"),
leading: const Icon(Icons.book_online),
onTap: () {
Navigator.pushNamed(context, "/portfolio");
},

View file

@ -117,7 +117,7 @@ class OpenSimPageState extends State<OpenSimPage> {
SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.containsKey("settings")) {
String encoded = prefs.getString("settings")!;
CompoundTag tag = await NbtIo.readBase64String(encoded) as CompoundTag;
CompoundTag tag = await NbtIo.readBase64String(encoded);
if (tag.contains("user")) {
settings.currentUser = User.load(tag.get("user") as CompoundTag);
settings.loggedIn = true;
@ -157,7 +157,7 @@ class OpenSimPageState extends State<OpenSimPage> {
await showDialog(
context: context,
builder: (B) {
return CreateInventoryPopup();
return const CreateInventoryPopup();
});
activating = false;
// Force user to re-login
@ -188,7 +188,7 @@ class OpenSimPageState extends State<OpenSimPage> {
padding: const EdgeInsets.all(8),
child: SingleChildScrollView(
child: polling
? Column(
? const Column(
children: [
ListTile(
title: Text("Please wait... downloading content"),
@ -236,7 +236,7 @@ class OpenSimPageState extends State<OpenSimPage> {
didChangeDependencies();
},
child: Text("LOGOUT"))
child: const Text("LOGOUT"))
],
)
: Center(
@ -249,14 +249,14 @@ class OpenSimPageState extends State<OpenSimPage> {
didChangeDependencies();
},
child: Text("Login")),
child: const Text("Login")),
ElevatedButton(
onPressed: () async {
await Navigator.pushNamed(
context, "/opensim/register");
didChangeDependencies();
},
child: Text("Register Account"))
child: const Text("Register Account"))
],
))
],

View file

@ -4,13 +4,13 @@ import 'package:footer/footer_view.dart';
import 'package:zontreck/Constants.dart';
class PortfolioPage extends StatelessWidget {
PortfolioPage({super.key});
const PortfolioPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Zontreck.com - Portfolio of Tara Piccari"),
title: const Text("Zontreck.com - Portfolio of Tara Piccari"),
backgroundColor: Constants.TITLEBAR_COLOR,
),
body: FooterView(
@ -21,26 +21,26 @@ class PortfolioPage extends StatelessWidget {
const Text("${Constants.COPYRIGHT}\n${Constants.VERSION}")),
children: [
Padding(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
child: SingleChildScrollView(
child: Row(
children: [
PortfolioEntry(
title: ListTile(title: Text("Cards of Utter Nonsense")),
body: Text(
title: const ListTile(title: Text("Cards of Utter Nonsense")),
body: const Text(
"A product I created for Second Life, but may port to the mobile phone at some point"),
onTap: () {
Navigator.pushNamed(context, "/portfolio/coun");
},
),
PortfolioEntry(
title: Text("Zontreck.com"),
body: Text(
title: const Text("Zontreck.com"),
body: const Text(
("This website, which is written entirely in Flutter, with some supporting API files in PHP")),
onTap: () {}),
PortfolioEntry(
title: Text("Minecraft Modding"),
body: Text(
title: const Text("Minecraft Modding"),
body: const Text(
"These mods are all written in Java. The various mods I currently maintain, previously maintained, or have contributed to are: Thresholds, Aria's Essentials, LibZontreck, Let's Do Beachparty, WatchMyDurability"),
onTap: () {})
],
@ -56,8 +56,8 @@ class PortfolioEntry extends StatelessWidget {
final Widget body;
final Function() onTap;
PortfolioEntry(
{required this.title, required this.body, required this.onTap});
const PortfolioEntry(
{super.key, required this.title, required this.body, required this.onTap});
@override
Widget build(BuildContext context) {
@ -67,14 +67,14 @@ class PortfolioEntry extends StatelessWidget {
child: InkWell(
onTap: onTap,
child: Padding(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
child: SizedBox(
width: 225,
height: 325,
child: Column(
children: [
title,
Divider(
const Divider(
thickness: 4,
),
body
@ -88,14 +88,16 @@ class PortfolioEntry extends StatelessWidget {
}
class CardsOfUtterNonsense extends StatelessWidget {
const CardsOfUtterNonsense({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Portfolio Entry - Cards of Utter Nonsense"),
title: const Text("Portfolio Entry - Cards of Utter Nonsense"),
backgroundColor: Constants.TITLEBAR_COLOR,
),
body: Padding(
body: const Padding(
padding: EdgeInsets.all(8),
child: SingleChildScrollView(
child: Column(

View file

@ -6,8 +6,10 @@ import 'package:zontreck/Constants.dart';
import 'package:zontreck/Packets.dart';
import 'package:zontreck/Settings.dart';
import '../LastNames.dart';
class RegisterAccountPage extends StatefulWidget {
RegisterAccountPage({super.key});
const RegisterAccountPage({super.key});
@override
RegisterAccountState createState() => RegisterAccountState();
@ -48,7 +50,7 @@ class RegisterAccountState extends State<RegisterAccountPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("OpenSim - Register Account"),
title: const Text("OpenSim - Register Account"),
backgroundColor: Constants.TITLEBAR_COLOR,
),
floatingActionButton: canSubmit
@ -70,17 +72,17 @@ class RegisterAccountState extends State<RegisterAccountPage> {
APIEndpoint.Register, packet) as S2CSimpleReplyPacket;
if (response.done) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
"User Account Created. You must now login to finish setting up the account")));
Navigator.pop(context);
} else {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content:
Text("Fatal error when creating user account")));
}
},
child: Text("Create my Account"))
child: const Text("Create my Account"))
: null,
body: FooterView(
footer: Footer(
@ -90,20 +92,20 @@ class RegisterAccountState extends State<RegisterAccountPage> {
const Text("${Constants.COPYRIGHT}\n${Constants.VERSION}")),
children: [
Padding(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
child: SingleChildScrollView(
child: Column(
children: [
settings.hasNoUsers
? ListTile(
title: Text("There are no users on this grid."),
title: const Text("There are no users on this grid."),
tileColor: Constants.TITLEBAR_COLOR,
subtitle: Text(
"This account will be granted Level 240, and the User Title : ${UserTitles.OPERATOR.title}"),
)
: SizedBox(),
: const SizedBox(),
ListTile(
title: Text("First Name"),
title: const Text("First Name"),
subtitle: TextField(
controller: firstNameController,
onChanged: (v) {
@ -112,7 +114,7 @@ class RegisterAccountState extends State<RegisterAccountPage> {
),
),
ListTile(
title: Text("Last Name"),
title: const Text("Last Name"),
subtitle: Constants.ALLOW_ANY_LAST_NAME ||
settings.hasNoUsers
? TextField(
@ -131,10 +133,10 @@ class RegisterAccountState extends State<RegisterAccountPage> {
LastNames.getCurrentNames(),
)),
ListTile(
title: Text("Password"),
title: const Text("Password"),
subtitle: TextField(
controller: password,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: "*******",
),
obscureText: true,
@ -145,10 +147,10 @@ class RegisterAccountState extends State<RegisterAccountPage> {
),
),
ListTile(
title: Text("Password Confirmation"),
title: const Text("Password Confirmation"),
subtitle: TextField(
controller: confirm,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: "*******",
),
obscureText: true,
@ -160,21 +162,21 @@ class RegisterAccountState extends State<RegisterAccountPage> {
),
passwordMatches ||
password.text == "" && confirm.text == ""
? Divider(
? const Divider(
thickness: 2,
)
: ListTile(
: const ListTile(
title: Text("Passwords do not match"),
tileColor: Constants.TITLEBAR_COLOR,
),
ListTile(
title: Text("Email Address"),
title: const Text("Email Address"),
subtitle: TextField(
onChanged: (V) {
setState(() {});
},
controller: email,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText:
"Your email address. It is not used by zontreck.com, but if needed, can be used to reach you"),
),
@ -186,23 +188,3 @@ class RegisterAccountState extends State<RegisterAccountPage> {
]));
}
}
enum LastNames {
Aabye,
Aarde,
Bailey,
Caballero;
static List<DropdownMenuEntry<Object?>> getCurrentNames() {
return [
LastNames.Aabye.getEntry(),
LastNames.Aarde.getEntry(),
LastNames.Bailey.getEntry(),
LastNames.Caballero.getEntry()
];
}
DropdownMenuEntry<String> getEntry() {
return DropdownMenuEntry(value: this.name, label: this.name);
}
}

View file

@ -47,6 +47,8 @@ enum InventoryFolder {
}
class CreateInventoryPopup extends StatefulWidget {
const CreateInventoryPopup({super.key});
@override
State<StatefulWidget> createState() => CreateInventoryState();
}
@ -70,7 +72,7 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
setState(() {
status = "Enabling user account";
});
await Future.delayed(Duration(milliseconds: 500));
await Future.delayed(const Duration(milliseconds: 500));
Settings settings = Settings();
C2SActivateUserPacket activate =
@ -83,11 +85,11 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
});
}
await Future.delayed(Duration(seconds: 1));
await Future.delayed(const Duration(seconds: 1));
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
"Inventory successfully created. Your account is now active")));
}
@ -95,7 +97,7 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
bool processing = false;
Future<void> startProcessing() async {
total = InventoryFolder.values.length;
await Future.delayed(Duration(seconds: 5));
await Future.delayed(const Duration(seconds: 5));
UUID rootFolder = UUID.generate(4);
@ -130,8 +132,8 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
client: Constants.CLIENTPSK);
setState(() {
status = ("Creating Inventory Folder: ${name}");
if (Constants.DEBUG) print("Creating Inventory Folder: ${name}");
status = ("Creating Inventory Folder: $name");
if (Constants.DEBUG) print("Creating Inventory Folder: $name");
});
var reply = await settings.sendPacketToEndpoint(
@ -143,16 +145,17 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
context: context,
builder: (V) {
return AlertDialog(
title: Text("FATAL ERROR"),
title: const Text("FATAL ERROR"),
content: Text(
"For an unknown reason, we failed to create the inventory folders. Some may have been created, but there was an error while processing: ${makeFolder.encodeSafe()}"),
);
});
} else
} else {
setState(() {
status = ("Created Inventory Folder : ${name}");
if (Constants.DEBUG) print("Created Inventory Folder: ${name}");
status = ("Created Inventory Folder : $name");
if (Constants.DEBUG) print("Created Inventory Folder: $name");
});
}
value++;
@ -161,23 +164,23 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
});
}
Timer.periodic(Duration(milliseconds: 500), createFolder);
Timer.periodic(const Duration(milliseconds: 500), createFolder);
}
@override
Widget build(BuildContext context) {
return AlertDialog(
icon: Icon(Icons.folder_copy),
title: Text("Please Wait... Activating Account"),
icon: const Icon(Icons.folder_copy),
title: const Text("Please Wait... Activating Account"),
content: SizedBox(
height: 75,
child: Column(
children: [
Text("Creating necessary Inventory Folders"),
const Text("Creating necessary Inventory Folders"),
Text(
status,
),
Divider(),
const Divider(),
LinearProgressIndicator(
value: getProgress(),
color: Constants.PORTFOLIO_CARD_COLOR,