novo projeto
This commit is contained in:
20
lib/main.dart
Normal file
20
lib/main.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:educa_controle_acesso/screens/home_screen.dart';
|
||||
import 'package:educa_controle_acesso/screens/login_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Controle de Acesso',
|
||||
home: HomeScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
17
lib/models/aluno_model.dart
Normal file
17
lib/models/aluno_model.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class AlunoModel{
|
||||
String nome;
|
||||
String data_nasc;
|
||||
String ra;
|
||||
String escola;
|
||||
String serie;
|
||||
String turma;
|
||||
|
||||
AlunoModel({
|
||||
required this.nome,
|
||||
required this.data_nasc,
|
||||
required this.ra,
|
||||
required this.escola,
|
||||
required this.serie,
|
||||
required this.turma,
|
||||
});
|
||||
}
|
||||
95
lib/screens/home_screen.dart
Normal file
95
lib/screens/home_screen.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
import 'package:educa_controle_acesso/utils/colors.dart';
|
||||
import 'package:educa_controle_acesso/widgets/input_text.dart';
|
||||
import 'package:educa_controle_acesso/widgets/text_custom.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../models/aluno_model.dart';
|
||||
import '../widgets/dados_alunos_container.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<HomeScreen> createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
var controllerPesquisa = TextEditingController();
|
||||
List<AlunoModel> alunos = [];
|
||||
List resultadoPesquisa = [];
|
||||
|
||||
carregarAlunos(){
|
||||
alunos.add(AlunoModel(nome: 'Maria da Silva', data_nasc: '01/01/2010', ra: '000.000.000-8', escola: 'EMEI Profª Therezinha de Jesus Alguz', serie: '8', turma: 'A'));
|
||||
alunos.add(AlunoModel(nome: 'Pedro Costa Almeida', data_nasc: '01/01/2015', ra: '111.111.111-5', escola: 'EMEI Profª Enestina Loureiro Miranda', serie: '7', turma: 'C'));
|
||||
pesquisarAluno();
|
||||
}
|
||||
|
||||
pesquisa(){
|
||||
pesquisarAluno();
|
||||
|
||||
}
|
||||
|
||||
pesquisarAluno()async{
|
||||
resultadoPesquisa =[];
|
||||
if(controllerPesquisa.text.isNotEmpty){
|
||||
for (int i =0;alunos.length>i;i++) {
|
||||
String nome = alunos[i].nome.toUpperCase();
|
||||
if(nome.contains(controllerPesquisa.text.toUpperCase())){
|
||||
if(resultadoPesquisa.length<10){
|
||||
resultadoPesquisa.add(alunos[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(int i = 0;i<10;i++){
|
||||
resultadoPesquisa.add(alunos[i]);
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
carregarAlunos();
|
||||
controllerPesquisa.addListener(pesquisa);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: TextCustom(text: 'Cadastrar responsável',color: Colors.white,),backgroundColor: PaletteColors.grey),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: height*0.05),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width>900?width*0.3:width*0.05),
|
||||
child: InputText(controller: controllerPesquisa, width: width*0.2,title: 'Pesquisar Aluno(a)',)
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: width>900?width*0.3:width*0.05),
|
||||
width: width*0.5,
|
||||
height: height*0.5,
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (context,index){
|
||||
return Divider();
|
||||
},
|
||||
itemCount: resultadoPesquisa.length,
|
||||
itemBuilder:(context,index){
|
||||
return DadosAlunosContainer(alunoModel: resultadoPesquisa[index],);
|
||||
}
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
98
lib/screens/login_screen.dart
Normal file
98
lib/screens/login_screen.dart
Normal file
@@ -0,0 +1,98 @@
|
||||
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',
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
lib/utils/colors.dart
Normal file
14
lib/utils/colors.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PaletteColors{
|
||||
static const Color white = Colors.white;
|
||||
static const Color primaryColor = Color(0xffBB0202);
|
||||
static const Color secundColor = Color(0xffFF9E75);
|
||||
static const Color bgColor = Color(0xff3A3A3A);
|
||||
static const Color grey = Color (0xff757575);
|
||||
static const Color greyInput = Color (0xffE1E1E1);
|
||||
static const Color lightGrey = Color(0xffD0D0D0);
|
||||
static const Color midGrey = Color(0xffC4C4C4);
|
||||
static const Color backGrey = Color(0xffE9E9E9);
|
||||
static const Color greenAcent = Color(0xff1DBF24);
|
||||
}
|
||||
50
lib/widgets/buttom_custom.dart
Normal file
50
lib/widgets/buttom_custom.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ButtonCustom extends StatelessWidget{
|
||||
final VoidCallback onPressed;
|
||||
final String text;
|
||||
final double size;
|
||||
final Color colorButton;
|
||||
final Color colorText;
|
||||
final Color colorBorder;
|
||||
final widthCustom;
|
||||
final heightCustom;
|
||||
final font;
|
||||
|
||||
const ButtonCustom(
|
||||
{Key? key,
|
||||
required this.font,
|
||||
required this.onPressed,
|
||||
required this.text,
|
||||
required this.size,
|
||||
required this.colorButton,
|
||||
required this.colorText,
|
||||
required this.colorBorder,
|
||||
this.widthCustom = 1.0,
|
||||
this.heightCustom = 1.0
|
||||
}) : super(key: key);
|
||||
@override
|
||||
Widget build (BuildContext context) {
|
||||
double width =MediaQuery.of(context).size.width;
|
||||
double height =MediaQuery.of(context).size.height;
|
||||
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: colorButton,
|
||||
minimumSize: Size(width*widthCustom! , height*heightCustom!),
|
||||
side: BorderSide(width: 2,color : colorBorder,),
|
||||
|
||||
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(text,
|
||||
style: TextStyle(fontFamily: font, color: colorText,
|
||||
fontSize: size,fontWeight: FontWeight.bold
|
||||
),
|
||||
|
||||
|
||||
) ,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
50
lib/widgets/dados_alunos_container.dart
Normal file
50
lib/widgets/dados_alunos_container.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:educa_controle_acesso/models/aluno_model.dart';
|
||||
import 'package:educa_controle_acesso/widgets/text_custom.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/colors.dart';
|
||||
|
||||
class DadosAlunosContainer extends StatelessWidget {
|
||||
|
||||
AlunoModel alunoModel;
|
||||
|
||||
DadosAlunosContainer({
|
||||
required this.alunoModel
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 10,horizontal: 5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextCustom(
|
||||
text: 'Nome: '+alunoModel.nome,
|
||||
color: PaletteColors.grey,
|
||||
size: 20,
|
||||
),
|
||||
TextCustom(
|
||||
text: 'Data de Nascimento: '+alunoModel.data_nasc,
|
||||
color: PaletteColors.grey,
|
||||
size: 15,
|
||||
),
|
||||
TextCustom(
|
||||
text: 'RA: '+alunoModel.ra,
|
||||
color: PaletteColors.grey,
|
||||
size: 15,
|
||||
),
|
||||
TextCustom(
|
||||
text: 'Turma: '+alunoModel.serie+'° ANO '+alunoModel.turma,
|
||||
color: PaletteColors.grey,
|
||||
size: 15,
|
||||
),
|
||||
TextCustom(
|
||||
text: 'Escola: '+alunoModel.escola,
|
||||
color: PaletteColors.grey,
|
||||
size: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
70
lib/widgets/input_text.dart
Normal file
70
lib/widgets/input_text.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:educa_controle_acesso/utils/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class InputText extends StatelessWidget {
|
||||
bool obscure;
|
||||
var controller;
|
||||
double fontSize;
|
||||
String title;
|
||||
double width;
|
||||
TextInputType textInputType;
|
||||
int maxLines;
|
||||
Color colorBorder;
|
||||
var onChanged;
|
||||
|
||||
InputText({
|
||||
required this.controller,
|
||||
required this.width,
|
||||
this.obscure = false,
|
||||
this.fontSize = 15.0,
|
||||
this.title = '',
|
||||
this.textInputType = TextInputType.text,
|
||||
this.maxLines = 1,
|
||||
this.colorBorder = PaletteColors.grey,
|
||||
this.onChanged = null,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color:PaletteColors.greyInput,
|
||||
width: width,
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: TextFormField(
|
||||
keyboardType: textInputType,
|
||||
maxLines: maxLines,
|
||||
onChanged: onChanged,
|
||||
obscureText: this.obscure,
|
||||
controller: this.controller,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: this.fontSize,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
// fillColor: PaletteColors.primaryColor,
|
||||
labelText: title,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1,color: colorBorder)
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1, color: colorBorder),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1, color: colorBorder),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(width: 1, color: colorBorder),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: this.fontSize,
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
20
lib/widgets/snackBars.dart
Normal file
20
lib/widgets/snackBars.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void showSnackBar(BuildContext context, String text,Color colors){
|
||||
|
||||
final snackbar = SnackBar(
|
||||
backgroundColor: colors,
|
||||
content: Row(
|
||||
children: [
|
||||
Icon(Icons.info_outline,color: Colors.white),
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Text(text,
|
||||
style: TextStyle(fontSize: 16),),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackbar);
|
||||
}
|
||||
41
lib/widgets/text_custom.dart
Normal file
41
lib/widgets/text_custom.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils/colors.dart';
|
||||
|
||||
class TextCustom extends StatelessWidget {
|
||||
final text;
|
||||
final size;
|
||||
final color;
|
||||
final fontWeight;
|
||||
final textAlign;
|
||||
final maxLines;
|
||||
final underscore;
|
||||
|
||||
TextCustom({
|
||||
required this.text,
|
||||
this.size = 16.0,
|
||||
this.color = PaletteColors.primaryColor,
|
||||
this.fontWeight = FontWeight.normal,
|
||||
this.textAlign = TextAlign.start,
|
||||
this.maxLines = 1,
|
||||
this.underscore,
|
||||
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: textAlign,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: size,
|
||||
fontWeight: fontWeight,
|
||||
decoration: underscore,
|
||||
decorationThickness: 4
|
||||
),
|
||||
maxLines: maxLines,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user