diff --git a/lib/componentes/drawer_custom.dart b/lib/componentes/drawer_custom.dart index 6bb11b4..c2c48a5 100644 --- a/lib/componentes/drawer_custom.dart +++ b/lib/componentes/drawer_custom.dart @@ -32,9 +32,11 @@ class DrawerCustom extends StatelessWidget { children: [ CircleAvatar( radius: 70, - child: ClipRRect( - borderRadius:BorderRadius.circular(70), - child: Image.asset(estudanteModelo.foto), + backgroundColor: Colors.grey[300], + child:estudanteModelo.foto==''?Container(): + ClipRRect( + child: Image.asset(estudanteModelo.foto), + borderRadius:BorderRadius.circular(70), ) ), Padding( diff --git a/lib/componentes/text_custom.dart b/lib/componentes/text_custom.dart index edfbaa5..7622d7f 100644 --- a/lib/componentes/text_custom.dart +++ b/lib/componentes/text_custom.dart @@ -28,6 +28,7 @@ class TextCustom extends StatelessWidget { overflow: TextOverflow.ellipsis, textAlign: textAlign, style: TextStyle( + overflow: TextOverflow.ellipsis, color: color, fontSize: size, fontWeight: fontWeight, diff --git a/lib/telas/tela_login.dart b/lib/telas/tela_login.dart index 4544ab4..29c7b0c 100644 --- a/lib/telas/tela_login.dart +++ b/lib/telas/tela_login.dart @@ -1,8 +1,11 @@ import 'dart:convert'; +import 'package:brasil_fields/brasil_fields.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:rkm_educa_app/Telas/tela_situacao_escolar.dart'; +import 'package:rkm_educa_app/modelos/estudante_modelo.dart'; import 'package:rkm_educa_app/telas/tela_seleciona_filho.dart'; import 'package:rkm_educa_app/utils/dimensoes.dart'; -import '../controllers/main_controllers.dart'; import '../utils/cores.dart'; import '../componentes/buttom_custom.dart'; import '../componentes/input_text.dart'; @@ -19,9 +22,11 @@ class TelaLogin extends StatefulWidget { class _TelaLoginState extends State { - final inputLogin = TextEditingController(text: 'mmatos'); - final inputSenha = TextEditingController(text: 'mmatos'); + final inputLogin = TextEditingController(text: '402.061.058-43'); + final inputSenha = TextEditingController(text: 'loginapp2023'); bool loading = false; + EstudanteModelo? estudanteModelo; + String status = 'VALIDANDO ACESSO...'; verificacao(){ if(inputLogin.text.isNotEmpty){ @@ -30,6 +35,10 @@ class _TelaLoginState extends State { loading = true; }); conectAPI(); + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => TelaSelecionaFilho()), + // ); }else{ showSnackBar(context, 'Preencha sua senha', Colors.red); } @@ -39,38 +48,50 @@ class _TelaLoginState extends State { } conectAPI()async{ - final url = 'http://192.168.18.2/projeto/api_educa/index.php/?NO_USERNAME=${inputLogin.text.toUpperCase()}'; - print(url); + final url = 'http://192.168.18.2:8000/loginpais?CPF=${inputLogin.text.toUpperCase()}'; + // print(url); final response = await http.get(Uri.parse(url)); var map = json.decode(response.body); - print(map); + // print(map); if(map==false){ + setState(() { + loading = false; + }); showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red); }else{ - if(map['NO_USERNAME']==map['SENHA']){ - if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){ - showSnackBar(context, 'Acesso validado', Colors.green); - Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => TelaSelecionaFilho())); - }else{ - showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red); - } + if(map['CPF']==inputLogin.text.toUpperCase() && map['SENHA'].toString().toUpperCase()==inputSenha.text.toUpperCase()){ + setState(() { + status = 'CARREGANDO ESTUDANTE(S) ...'; + }); + showSnackBar(context, 'Acesso validado', Colors.green); + buscaFilhos(map['NOME']); }else{ - print(MainControllers().encrypt(inputSenha.text,map['SENHA'])); - if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){ - showSnackBar(context, 'Acesso validado', Colors.green); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => TelaSelecionaFilho()), - ); - }else{ - showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red); - } - // MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA'] + setState(() { + loading = false; + }); + showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red); } } + } + + buscaFilhos(String nome)async{ + String q = nome.replaceAll(' ', '%20').toUpperCase(); + final url = 'http://192.168.18.2:8000/buscafilhos?NOME=$q'; + // print(url); + final response = await http.get(Uri.parse(url)); + var map = json.decode(response.body); + + List listAlunos = map; + // print(listAlunos); setState(() { loading = false; }); + if(listAlunos.length==1){ + estudanteModelo = EstudanteModelo(nome: listAlunos[0]['NO_ALUNO'], foto: '', ra: listAlunos[0]['NR_RA'], escola: '', idade: 0, anoEscolar: 2023); + Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => TelaSituacaoEscolar(estudanteModelo: estudanteModelo!))); + }else{ + Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => TelaSelecionaFilho(listAlunos: listAlunos,))); + } } @override @@ -87,7 +108,10 @@ class _TelaLoginState extends State { loading?Container():Container( width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, child: InputText( - inputFormatters: [], + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + CpfInputFormatter(), + ], controller: inputLogin, title: 'Login', width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, @@ -111,7 +135,7 @@ class _TelaLoginState extends State { children: [ CircularProgressIndicator(color: PaletaCores.cinzaClaro,), SizedBox(width: 20,), - TextCustom(text: 'VALIDANDO ACESSO...') + TextCustom(text: status) ], ):ButtonCustom( widthCustom: 0.7, diff --git a/lib/telas/tela_perfil.dart b/lib/telas/tela_perfil.dart index dcec912..9d80f80 100644 --- a/lib/telas/tela_perfil.dart +++ b/lib/telas/tela_perfil.dart @@ -28,7 +28,8 @@ class _TelaPerfilState extends State { children: [ CircleAvatar( radius: 70, - child: ClipRRect( + backgroundColor: Colors.grey[300], + child:widget.estudanteModelo.foto==''?Container(): ClipRRect( borderRadius:BorderRadius.circular(70), child: Image.asset(widget.estudanteModelo.foto), ) diff --git a/lib/telas/tela_seleciona_filho.dart b/lib/telas/tela_seleciona_filho.dart index 968cea6..ca49143 100644 --- a/lib/telas/tela_seleciona_filho.dart +++ b/lib/telas/tela_seleciona_filho.dart @@ -10,7 +10,10 @@ import '../componentes/text_custom.dart'; import '../utils/dimensoes.dart'; class TelaSelecionaFilho extends StatefulWidget { - const TelaSelecionaFilho({Key? key}) : super(key: key); + List listAlunos; + TelaSelecionaFilho({ + required this.listAlunos +}); @override State createState() => _TelaSelecionaFilhoState(); @@ -20,12 +23,21 @@ class _TelaSelecionaFilhoState extends State { EstudanteModelo? estudanteModelo; - List list = []; + List listAlunos = []; + + carregarAlunos(){ + print(widget.listAlunos); + + for(int i=0; widget.listAlunos.length>i;i++){ + print(widget.listAlunos[i]['NO_ALUNO']); + listAlunos.add(EstudanteModelo(nome: widget.listAlunos[i]['NO_ALUNO'], foto: '', ra: widget.listAlunos[i]['NR_RA'], escola: '', idade: 0, anoEscolar: 2023)); + } + setState(() {}); + } @override void initState() { - list = DadosEstaticos().alunos; - setState(() {}); + carregarAlunos(); } @override @@ -47,7 +59,7 @@ class _TelaSelecionaFilhoState extends State { children: [ TextCustom(text: 'Estudantes',fontWeight: FontWeight.bold,size: 14.0,), Container( - width: Dimensoes.width*0.8, + width: Dimensoes.width*0.85, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), border: Border.all( @@ -62,13 +74,15 @@ class _TelaSelecionaFilhoState extends State { child: TextCustom(text: 'Selecione'), ), value: estudanteModelo, - items: list.map((value) => DropdownMenuItem( + items: listAlunos.map((value) => DropdownMenuItem( value: value, - child: Padding( + child: Container( + width: Dimensoes.width*0.75, padding: const EdgeInsets.all(8.0), child: TextCustom( text: value.nome, color: Colors.black54, + size: 14.0, ), ), ) diff --git a/pubspec.lock b/pubspec.lock index 5c55cad..c9c32cc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -33,6 +33,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + brasil_fields: + dependency: "direct main" + description: + name: brasil_fields + sha256: "3c8e580c31657402a4e41c5d46325dc91db6be968063e0f68475c233b906281c" + url: "https://pub.dev" + source: hosted + version: "1.13.1" characters: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8b26dba..b2c0a9f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: http: intl: syncfusion_flutter_charts: ^21.2.9 + brasil_fields: flutter_localizations: sdk: flutter