criada alguns widgets padrões e ajustada a tela de login
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
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/input_text.dart';
|
||||
import 'package:rkm/widgets/text_default.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key}) : super(key: key);
|
||||
@@ -9,19 +14,112 @@ class LoginScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
var inputUser = TextEditingController();
|
||||
var inputPassword = TextEditingController();
|
||||
String error = '';
|
||||
String? now;
|
||||
String? selectCity;
|
||||
|
||||
checkLogin(){
|
||||
if(inputUser.text.isNotEmpty && inputPassword.text.isNotEmpty && inputUser.text == 'teste' && inputPassword.text == '123'){
|
||||
if(selectCity!=null){
|
||||
if(selectCity=='Piracicaba'){
|
||||
setState(() {
|
||||
error = '';
|
||||
inputPassword.clear();
|
||||
inputUser.clear();
|
||||
selectCity = null;
|
||||
});
|
||||
Navigator.pushNamed(context, '/home');
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Unidade Inválida';
|
||||
});
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
error = 'Selecione sua unidade';
|
||||
});
|
||||
}
|
||||
}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;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: TextDefault(text: 'Login',fontSize: 30,color: ColorPalette.white),
|
||||
),
|
||||
bottomSheet: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextDefault(
|
||||
text: 'Última sincronização $now',
|
||||
fontSize: 20,
|
||||
color: ColorPalette.black54,
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text('Login'),
|
||||
TextDefault(text: 'Login',fontSize: 30),
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
width: width*0.6,
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
hint: TextDefault(text: 'Selecione a cidade'),
|
||||
value: selectCity,
|
||||
items: ConstVariable().itensCity.map((value) => DropdownMenuItem(
|
||||
value: value,
|
||||
child: TextDefault(
|
||||
text: value,
|
||||
),
|
||||
)
|
||||
).toList(),
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
selectCity = value!;
|
||||
});
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
InputText(
|
||||
hint: 'Usuário',
|
||||
controller: inputUser,
|
||||
width: width*0.6
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
InputText(
|
||||
hint: 'Senha',
|
||||
obscure: true,
|
||||
controller: inputPassword,
|
||||
width: width*0.6
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
TextDefault(text: error,color: ColorPalette.red),
|
||||
ButtonDefault(
|
||||
onPressed: ()=>Navigator.pushNamed(context, '/home'),
|
||||
onPressed: ()=>checkLogin(),
|
||||
title: 'Entrar'
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user