136 lines
4.2 KiB
Dart
136 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:rkm/utils/color_palette.dart';
|
|
import 'package:rkm/utils/const_variable.dart';
|
|
import 'package:rkm/widgets/button_default.dart';
|
|
import 'package:rkm/widgets/dropdown_button_city.dart';
|
|
import 'package:rkm/widgets/input_text.dart';
|
|
import 'package:rkm/widgets/text_default.dart';
|
|
|
|
class LoginScreen extends StatefulWidget {
|
|
const LoginScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<LoginScreen> createState() => _LoginScreenState();
|
|
}
|
|
|
|
class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
var inputUser = TextEditingController();
|
|
var inputPassword = TextEditingController();
|
|
String error = '';
|
|
String? now;
|
|
String? selectCity;
|
|
bool validatorDropDown= false;
|
|
|
|
checkLogin(){
|
|
if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text == 'teste' && inputPassword.text == '123'){
|
|
if(selectCity!=null){
|
|
setState(() {
|
|
error = '';
|
|
});
|
|
Navigator.pushNamed(context, '/home');
|
|
}else{
|
|
setState(() {
|
|
error = 'Selecione sua cidade';
|
|
});
|
|
}
|
|
}else{
|
|
setState(() {
|
|
error = 'Usuário/senha inválido(s)';
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
setState(() {
|
|
now = DateFormat('dd/MM/yyyy kk:mm:ss').format(DateTime.now());
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
double width = MediaQuery.of(context).size.width;
|
|
double height = MediaQuery.of(context).size.height;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
title: TextDefault(text: 'RKM AB - Carga Inicial',fontSize: ConstVariable().fontSizeTitleAppBar,color: ColorPalette.white),
|
|
),
|
|
bottomSheet: Container(
|
|
color: ColorPalette.secundary,
|
|
padding: EdgeInsets.all(8.0),
|
|
child: TextDefault(
|
|
text: 'Última sincronização $now',
|
|
fontSize: 15,
|
|
color: ColorPalette.gray,
|
|
),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
padding: EdgeInsets.only(top: height*0.2),
|
|
width: width,
|
|
height: height,
|
|
decoration: ConstVariable().backgroundGradient,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Image.asset('assets/images/logo.PNG',width: width*0.4),
|
|
SizedBox(height: 10),
|
|
Form(
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
child: Container(
|
|
width: width*0.6,
|
|
height: height*0.3,
|
|
child: ListView(
|
|
children: [
|
|
InputText(
|
|
hint: 'Usuário',
|
|
label: 'Usuário',
|
|
error: 'Campo obrigatório',
|
|
controller: inputUser,
|
|
width: width*0.6
|
|
),
|
|
InputText(
|
|
hint: 'Senha',
|
|
label: 'Senha',
|
|
error: 'Campo obrigatório',
|
|
obscure: true,
|
|
controller: inputPassword,
|
|
width: width*0.6
|
|
),
|
|
DropDownButtonCity(
|
|
error: 'Campo obrigatório',
|
|
validator: validatorDropDown,
|
|
select: selectCity,
|
|
onChanged: (value){
|
|
setState(() {
|
|
selectCity = value!;
|
|
validatorDropDown = true;
|
|
});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
ButtonDefault(
|
|
onPressed: ()=>checkLogin(),
|
|
title: 'Carga Inicial',
|
|
width: width*0.6,
|
|
),
|
|
SizedBox(height: 10),
|
|
TextDefault(text: error,color: ColorPalette.red),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|