Files
controle_acesso_educa/lib/screens/login_screen.dart
2023-05-24 18:43:37 -03:00

99 lines
3.2 KiB
Dart

import 'package:educa_controle_acesso/screens/home_screen.dart';
import 'package:educa_controle_acesso/widgets/input_text.dart';
import 'package:flutter/material.dart';
import '../utils/colors.dart';
import '../widgets/buttom_custom.dart';
import '../widgets/snackBars.dart';
import '../widgets/text_custom.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final inputEmail = TextEditingController(text: 'teste@gmail.com');
final inputSenha = TextEditingController(text: 'senha123');
verificacao(){
if(inputEmail.text.isNotEmpty){
if(inputSenha.text.isNotEmpty){
if(inputEmail.text == 'teste@gmail.com'){
if(inputSenha.text == 'senha123'){
showSnackBar(context, 'Acesso validado', Colors.green);
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => HomeScreen()),
);
}else{
showSnackBar(context, 'E-mail não cadastrado e/ou senha incorreta', Colors.red);
}
}else{
showSnackBar(context, 'E-mail não cadastrado e/ou senha incorreta', Colors.red);
}
}else{
showSnackBar(context, 'Preencha sua senha', Colors.red);
}
}else{
showSnackBar(context, 'Preencha seu e-mail', Colors.red);
}
}
@override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: PaletteColors.white,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: Image.asset("assets/image/logo.PNG",width:width * 0.2 ,height: height * 0.12)
),
Container(
width: width>900? width * 0.18:width*0.5,
child: InputText(
controller: inputEmail,
title: 'E-mail',
width: width>900? width * 0.18:width*0.5,
colorBorder: PaletteColors.white,
),
),
SizedBox(height: height * 0.02),
Container(
width: width>900? width * 0.18:width*0.5,
child: InputText(
controller: inputSenha,
title: 'Senha',
obscure: true,
width: width * 0.18,
colorBorder: PaletteColors.white,
),
),
SizedBox(height: height * 0.02),
ButtonCustom(
widthCustom: 0.1,
heightCustom: 0.07,
text: "Entrar",
size: 14.0,
colorText: PaletteColors.white,
colorButton: PaletteColors.primaryColor,
colorBorder: PaletteColors.primaryColor,
onPressed: ()=>verificacao(),
font: 'Nunito',
),
],
),
)
);
}
}