Fix a typo
This commit is contained in:
parent
ad4b7fc4e7
commit
a0f0e95043
6 changed files with 118 additions and 37 deletions
81
lib/pages/LoginAccount.dart
Normal file
81
lib/pages/LoginAccount.dart
Normal file
|
@ -0,0 +1,81 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:zontreck/Constants.dart';
|
||||
import 'package:zontreck/Packets.dart';
|
||||
import 'package:zontreck/Settings.dart';
|
||||
|
||||
class LoginAccountPage extends StatefulWidget {
|
||||
LoginAccountPage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => LoginAccountState();
|
||||
}
|
||||
|
||||
class LoginAccountState extends State<LoginAccountPage> {
|
||||
TextEditingController first = TextEditingController();
|
||||
TextEditingController last = TextEditingController();
|
||||
TextEditingController pass = TextEditingController();
|
||||
|
||||
Settings settings = Settings();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("OpenSim - Login"),
|
||||
backgroundColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text("First Name"),
|
||||
subtitle: TextField(
|
||||
controller: first,
|
||||
decoration: InputDecoration(hintText: "Jane"),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Last Name"),
|
||||
subtitle: TextField(
|
||||
controller: last,
|
||||
decoration: InputDecoration(hintText: "Smith"),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Password"),
|
||||
subtitle: TextField(
|
||||
controller: pass,
|
||||
obscureText: true,
|
||||
obscuringCharacter: "*",
|
||||
decoration: InputDecoration(hintText: "*******"),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
C2SLoginPacket packet = C2SLoginPacket(
|
||||
first: first.text,
|
||||
last: last.text,
|
||||
password: pass.text);
|
||||
|
||||
var response = await settings.sendPacketToEndpoint(
|
||||
APIEndpoint.Login, packet) as S2CLoginResponsePacket;
|
||||
print("RESPONSE : ${response.encode()}");
|
||||
if (response.loggedIn) {
|
||||
Navigator.pop(context);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Login success")));
|
||||
|
||||
settings.loggedIn = true;
|
||||
settings.currentUser = response.user;
|
||||
}
|
||||
},
|
||||
child: Text("Login"))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue