96 lines
3.0 KiB
Dart
96 lines
3.0 KiB
Dart
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],);
|
|
}
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|