Add table creation

This commit is contained in:
Andrew 2023-04-11 02:42:20 +07:00
parent 09c9549004
commit 4a5039cb19
19 changed files with 1132 additions and 141 deletions

View file

@ -26,73 +26,75 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
final formWidth = screenSize.width <= 600 ? screenSize.width : 300.0;
return Stack(
children: [
AnimatedBackground(
behaviour: RandomParticleBehaviour(),
vsync: this,
child: const SizedBox.square(
dimension: 0,
return Scaffold(
body: Stack(
children: [
AnimatedBackground(
behaviour: RandomParticleBehaviour(),
vsync: this,
child: const SizedBox.square(
dimension: 0,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
LimitedBox(
maxWidth: formWidth,
child: Container(
color: Colors.black.withAlpha(100),
padding: const EdgeInsets.all(16),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
controller: loginController,
enabled: !submitted,
decoration: const InputDecoration(
labelText: 'Login',
hintText: 'Enter your login',
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
LimitedBox(
maxWidth: formWidth,
child: Container(
color: Colors.black.withAlpha(100),
padding: const EdgeInsets.all(16),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
controller: loginController,
enabled: !submitted,
decoration: const InputDecoration(
labelText: 'Login',
hintText: 'Enter your login',
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your Login';
}
return null;
},
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your Login';
}
return null;
},
),
TextFormField(
controller: passwordController,
obscureText: true,
enabled: !submitted,
decoration: const InputDecoration(
labelText: 'Password',
hintText: 'Enter your password',
TextFormField(
controller: passwordController,
obscureText: true,
enabled: !submitted,
decoration: const InputDecoration(
labelText: 'Password',
hintText: 'Enter your password',
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
return null;
},
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
return null;
},
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: submitted ? null : _submit,
child: const Text('Login'),
),
],
const SizedBox(height: 16),
ElevatedButton(
onPressed: submitted ? null : _submit,
child: const Text('Login'),
),
],
),
),
),
),
),
],
),
],
],
),
],
),
);
}
@ -121,13 +123,16 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
content: Text('Login successful'),
),
);
apiClient.setAccessToken(data.accessToken);
GetStorage()
.write("accessToken", data.accessToken)
.then((value) => GetStorage().save());
Timer(1.seconds, () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
WidgetsBinding.instance.addPostFrameCallback((_) {
Get.offAllNamed("/home");
.then((value) => GetStorage().save())
.then((value) {
Timer(1.seconds, () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
WidgetsBinding.instance.addPostFrameCallback((_) {
Get.offAllNamed("/home");
});
});
});
}, (error) {