Cleanup Code

This commit is contained in:
Moe Poi ~ 2022-04-25 22:28:58 +07:00
parent a00c2dc5c1
commit 82bbdd99d0
8 changed files with 28 additions and 30 deletions

View file

@ -13,14 +13,14 @@ Future<dynamic> getProduct(id) async {
return res;
}
Future<dynamic> RegisterPost({email, password, first_name, last_name}) async {
Future<dynamic> registerPost({email, password, firstName, lastName}) async {
Response req = await Dio().post(
(host + '/register'),
data: {
'email': email,
'password': password,
'first_name': first_name,
'last_name': last_name
'first_name': firstName,
'last_name': lastName
},
options: Options(
contentType: Headers.formUrlEncodedContentType,

View file

@ -51,9 +51,9 @@ class _MenuState extends State<Menu> {
} else if (index == 2) {
_selectedWidget = const Products();
} else if (index == 3) {
_selectedWidget = Checkout();
_selectedWidget = const Checkout();
} else if (index == 4) {
_selectedWidget = Register();
_selectedWidget = const Register();
}
});
}

View file

@ -1,14 +1,14 @@
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
class Register_Error extends StatefulWidget {
Register_Error({Key? key}) : super(key: key);
class RegisterError extends StatefulWidget {
const RegisterError({Key? key}) : super(key: key);
@override
State<Register_Error> createState() => _Register_ErrorState();
State<RegisterError> createState() => RegisterErrorState();
}
class _Register_ErrorState extends State<Register_Error> {
class RegisterErrorState extends State<RegisterError> {
@override
Widget build(BuildContext context) {
return SafeArea(

View file

@ -5,16 +5,16 @@ import 'package:nekoya_flutter/api/api.dart';
import 'package:nekoya_flutter/components/register_error.dart';
import 'package:nekoya_flutter/components/register_verify.dart';
class Register_Form extends StatefulWidget {
Register_Form({Key? key}) : super(key: key);
class RegisterForm extends StatefulWidget {
const RegisterForm({Key? key}) : super(key: key);
@override
State<Register_Form> createState() => _Register_FormState();
State<RegisterForm> createState() => RegisterFormState();
}
final _formKey = GlobalKey<FormBuilderState>();
class _Register_FormState extends State<Register_Form> {
class RegisterFormState extends State<RegisterForm> {
@override
Widget build(BuildContext context) {
return SafeArea(
@ -84,10 +84,10 @@ class _Register_FormState extends State<Register_Form> {
'') {
showAlertDialog(context);
} else {
var statusCode = await RegisterPost(
first_name: _formKey.currentState!
var statusCode = await registerPost(
firstName: _formKey.currentState!
.fields["First Name"]!.value,
last_name: _formKey.currentState!
lastName: _formKey.currentState!
.fields["Last Name"]!.value,
email: _formKey.currentState!
.fields["Email Address"]!.value,
@ -99,13 +99,13 @@ class _Register_FormState extends State<Register_Form> {
context,
MaterialPageRoute(
builder: (context) =>
Register_Verify()));
const RegisterVerify()));
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
Register_Error()));
const RegisterError()));
}
}
},
@ -209,7 +209,7 @@ showAlertDialog(BuildContext context) {
),
content: const Text(
"Make sure to fill all text fields",
style: const TextStyle(color: Colors.white70),
style: TextStyle(color: Colors.white70),
),
actions: [
okButton,

View file

@ -1,14 +1,14 @@
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
class Register_Verify extends StatefulWidget {
Register_Verify({Key? key}) : super(key: key);
class RegisterVerify extends StatefulWidget {
const RegisterVerify({Key? key}) : super(key: key);
@override
State<Register_Verify> createState() => _Register_VerifyState();
State<RegisterVerify> createState() => RegisterVerifyState();
}
class _Register_VerifyState extends State<Register_Verify> {
class RegisterVerifyState extends State<RegisterVerify> {
@override
Widget build(BuildContext context) {
return SafeArea(

View file

@ -20,7 +20,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSwatch(accentColor: Color(0xff8B0000))),
colorScheme: ColorScheme.fromSwatch(accentColor: const Color(0xff8B0000))),
home: AnimatedSplashScreen(
splash: 'assets/logo_transparent.webp',
pageTransitionType: PageTransitionType.fade,

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class Checkout extends StatefulWidget {
Checkout({Key? key}) : super(key: key);
const Checkout({Key? key}) : super(key: key);
@override
State<Checkout> createState() => _CheckoutState();
@ -17,7 +17,7 @@ class _CheckoutState extends State<Checkout> {
centerTitle: true,
backgroundColor: const Color(0xff212226),
),
body: Text('Checkout'),
body: const Text('Checkout'),
);
}
}

View file

@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:nekoya_flutter/components/register_form.dart';
import 'package:nekoya_flutter/components/register_verify.dart';
import 'package:nekoya_flutter/components/register_error.dart';
class Register extends StatefulWidget {
Register({Key? key}) : super(key: key);
const Register({Key? key}) : super(key: key);
@override
State<Register> createState() => _RegisterState();
@ -20,6 +18,6 @@ class _RegisterState extends State<Register> {
centerTitle: true,
backgroundColor: const Color(0xff212226),
),
body: Register_Form());
body: const RegisterForm());
}
}