criada alguns widgets padrões e ajustada a tela de login
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/screens/login_screen.dart';
|
||||
import 'package:rkm/utils/color_palette.dart';
|
||||
import 'package:rkm/utils/routes.dart';
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
@@ -10,8 +10,13 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
primaryColor: ColorPalette.primary,
|
||||
appBarTheme: AppBarTheme(
|
||||
color: ColorPalette.primary
|
||||
)
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: LoginScreen(),
|
||||
initialRoute: '/login',
|
||||
routes: routes,
|
||||
);
|
||||
|
||||
@@ -11,6 +11,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Home')),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: Text('home')
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
|
||||
8
lib/utils/color_palette.dart
Normal file
8
lib/utils/color_palette.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
class ColorPalette{
|
||||
static const Color white = Colors.white;
|
||||
static const Color red = Colors.red;
|
||||
static const Color primary = Color(0xff408CB3);
|
||||
static const Color border = Color(0xff86B6CD);
|
||||
static const Color black54 = Colors.black54;
|
||||
}
|
||||
31
lib/utils/const_variable.dart
Normal file
31
lib/utils/const_variable.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
class ConstVariable{
|
||||
List<String> itensCity = [
|
||||
'Anhembi',
|
||||
'Aparecida',
|
||||
'Batatais',
|
||||
'Cabreúva',
|
||||
'Casa Branca',
|
||||
'Descalvado',
|
||||
'Extrema',
|
||||
'Francisco Morato',
|
||||
'Franco da Rocha',
|
||||
'Igaraçu do Tiete',
|
||||
'Itápolis',
|
||||
'Itirapina',
|
||||
'Ituverava',
|
||||
'Jardinópolis',
|
||||
'Laranjal Paulista',
|
||||
'Macatuba',
|
||||
'Mairiporã',
|
||||
'Mococa',
|
||||
'Morro Agudo',
|
||||
'Pardinho',
|
||||
'Pederneiras',
|
||||
'Piracicaba',
|
||||
'Porto Ferreira',
|
||||
'Santa Rita',
|
||||
'Santo Antonio da Alegria',
|
||||
'Tapiratiba'
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/utils/color_palette.dart';
|
||||
class ButtonDefault extends StatelessWidget {
|
||||
var onPressed;
|
||||
String title;
|
||||
@@ -8,8 +9,8 @@ class ButtonDefault extends StatelessWidget {
|
||||
ButtonDefault({
|
||||
required this.onPressed,
|
||||
required this.title,
|
||||
this.background = Colors.black38,
|
||||
this.textColor = Colors.white
|
||||
this.background = ColorPalette.primary,
|
||||
this.textColor = ColorPalette.white
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
46
lib/widgets/input_text.dart
Normal file
46
lib/widgets/input_text.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/utils/color_palette.dart';
|
||||
|
||||
class InputText extends StatelessWidget {
|
||||
bool obscure;
|
||||
var controller;
|
||||
double fontSize;
|
||||
String hint;
|
||||
double width;
|
||||
|
||||
InputText({
|
||||
required this.controller,
|
||||
required this.width,
|
||||
this.obscure = false,
|
||||
this.fontSize = 20.0,
|
||||
this.hint = '',
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: ColorPalette.border
|
||||
),
|
||||
width: width,
|
||||
child: TextFormField(
|
||||
obscureText: this.obscure,
|
||||
controller: this.controller,
|
||||
style: TextStyle(
|
||||
color: ColorPalette.white,
|
||||
fontSize: this.fontSize,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: this.hint,
|
||||
hintStyle: TextStyle(
|
||||
color: ColorPalette.white,
|
||||
fontSize: this.fontSize,
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
26
lib/widgets/text_default.dart
Normal file
26
lib/widgets/text_default.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/utils/color_palette.dart';
|
||||
|
||||
class TextDefault extends StatelessWidget {
|
||||
|
||||
String text;
|
||||
double fontSize;
|
||||
Color color;
|
||||
|
||||
TextDefault({
|
||||
required this.text,
|
||||
this.fontSize = 20.0,
|
||||
this.color = ColorPalette.border
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
color: color
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user