alterado a url da API e ajustado a tela home_screen.dart
This commit is contained in:
@@ -5,6 +5,7 @@ class AlunoModel{
|
||||
String escola;
|
||||
String serie;
|
||||
String turma;
|
||||
var dados;
|
||||
|
||||
AlunoModel({
|
||||
required this.nome,
|
||||
@@ -13,5 +14,6 @@ class AlunoModel{
|
||||
required this.escola,
|
||||
required this.serie,
|
||||
required this.turma,
|
||||
required this.dados
|
||||
});
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
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';
|
||||
@@ -5,6 +7,9 @@ import 'package:flutter/material.dart';
|
||||
import '../models/aluno_model.dart';
|
||||
import '../widgets/buttom_custom.dart';
|
||||
import '../widgets/dados_alunos_container.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../widgets/snackBars.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({Key? key}) : super(key: key);
|
||||
@@ -24,13 +29,38 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
bool filtroSerie = false;
|
||||
bool filtroTurma = false;
|
||||
bool filtroEscola = false;
|
||||
bool buscandoDados = true;
|
||||
|
||||
carregarAlunos(){
|
||||
alunos=[
|
||||
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'),
|
||||
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();
|
||||
carregarAlunos()async{
|
||||
final url = 'http://localhost:8000/aluno?NR_LOGRADOURO=715';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
if(map==null){
|
||||
showSnackBar(context, 'Dados não localizados', Colors.red);
|
||||
setState(() {
|
||||
buscandoDados = false;
|
||||
});
|
||||
}else{
|
||||
List list = map;
|
||||
print(list);
|
||||
for(int i =0; list.length>i;i++){
|
||||
String data = list[i]['DT_NASCIMENTO']??'';
|
||||
String dia = '00';
|
||||
String mes = '00';
|
||||
String ano = '0000';
|
||||
if(data!=''){
|
||||
dia = data.substring(6,8);
|
||||
mes = data.substring(4,6);
|
||||
ano = data.substring(0,4);
|
||||
}
|
||||
alunos.add(AlunoModel(nome: list[i]['NO_ALUNO']??'', data_nasc: '${dia}/${mes}/${ano}', ra: list[i]['NR_RA']??'', escola: 'escola', serie: 'serie', turma: 'turma',dados: list[i]));
|
||||
}
|
||||
setState(() {
|
||||
buscandoDados = false;
|
||||
});
|
||||
pesquisarAluno();
|
||||
}
|
||||
}
|
||||
|
||||
pesquisa(){
|
||||
@@ -93,7 +123,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
backgroundColor: PaletteColors.grey,
|
||||
),
|
||||
body: Padding(
|
||||
body: buscandoDados?Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(width: 20,),
|
||||
TextCustom(text: 'BUSCANDO DADOS...')
|
||||
],
|
||||
),
|
||||
):Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
children: [
|
||||
|
||||
@@ -40,7 +40,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
}
|
||||
|
||||
conectAPI()async{
|
||||
final url = 'http://192.168.18.2/projeto/api_educa/index.php/?NO_USERNAME=${inputLogin.text.toUpperCase()}';
|
||||
final url = 'http://localhost:8000/login?NO_USERNAME=${inputLogin.text.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
|
||||
@@ -19,7 +19,6 @@ class TextCustom extends StatelessWidget {
|
||||
this.textAlign = TextAlign.start,
|
||||
this.maxLines = 1,
|
||||
this.underscore,
|
||||
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user