diff --git a/lib/telas/tela_cadastro.dart b/lib/telas/tela_cadastro.dart index 06c0231..a48c5f8 100644 --- a/lib/telas/tela_cadastro.dart +++ b/lib/telas/tela_cadastro.dart @@ -86,17 +86,19 @@ class _TelaCadastroState extends State { buscarCPF()async{ final url = '${widget.api}/buscarCPFMae?CPF=${inputCPF.text}&CIDADE=${cidadeQuery.toUpperCase()}'; print(url); - final response = await http.get(Uri.parse(url)); - if(response.body == 'false'){ + final response1 = await http.get(Uri.parse(url)); + mapAluno = response1.body == 'false'?{}:json.decode(response1.body); + String celularMae = mapAluno!['CELULAR_MAE']??''; + if(response1.body == 'false' || celularMae==''){ final url = '${widget.api}/buscarCPFPai?CPF=${inputCPF.text}&CIDADE=${cidadeQuery.toUpperCase()}'; print(url); final response = await http.get(Uri.parse(url)); - mapAluno = json.decode(response.body); + mapAluno = response.body == 'false'?{}:json.decode(response.body); print(mapAluno); print(mapAluno!['CD_ALUNO']); // inserirDB(map); + tentativas = tentativas + 1; if(tentativas <=3){ - tentativas = tentativas + 1; criarNumero(mapAluno!['DDD_CELULAR_PAI'].toString(),mapAluno!['CELULAR_PAI'].toString()); }else{ showSnackBar(context, 'Excedeu suas tentativas, entre em contato com a escola', Colors.red); @@ -110,12 +112,12 @@ class _TelaCadastroState extends State { setState(() {}); } }else{ - mapAluno = json.decode(response.body); + mapAluno = json.decode(response1.body); print(mapAluno); print(mapAluno!['CD_ALUNO']); // inserirDB(map); + tentativas = tentativas + 1; if(tentativas <=3){ - tentativas = tentativas + 1; criarNumero(mapAluno!['DDD_CELULAR_MAE'].toString(),mapAluno!['CELULAR_MAE'].toString()); }else{ showSnackBar(context, 'Excedeu suas tentativas, entre em contato com a escola', Colors.red); @@ -218,6 +220,16 @@ class _TelaCadastroState extends State { } } + Futureback()async{ + if(smsEnviado){ + smsEnviado = false; + setState((){}); + return false; + }else{ + return true; + } + } + @override Widget build(BuildContext context) { List cidades= []; @@ -225,123 +237,131 @@ class _TelaCadastroState extends State { cidades.add(Fixos().listCidades[i].cidade); } - return Scaffold( - appBar: AppBarCustom().appbar(context, 'CADASTRO'), - body: Container( - padding: EdgeInsets.all(Dimensoes.width*0.15), - width: Dimensoes.width, - height: Dimensoes.height, - alignment: Alignment.center, - child: carregando?Center( - child: Column( - mainAxisSize: MainAxisSize.min, + return WillPopScope( + onWillPop:()async=>await back(), + child: Scaffold( + appBar: AppBarCustom().appbar(context, 'CADASTRO'), + body: Container( + padding: EdgeInsets.all(Dimensoes.width*0.15), + width: Dimensoes.width, + height: Dimensoes.height, + alignment: Alignment.center, + child: carregando?Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextCustom(text: 'VALIDANDO DADOS ...\n AGUARDE ALGUNS SEGUNDOS !',maxLines: 2,textAlign: TextAlign.center,), + SizedBox(height: 30,), + CircularProgressIndicator(color: PaletaCores.corPrimaria,) + ], + ), + ):ListView( children: [ - TextCustom(text: 'VALIDANDO DADOS ...\n AGUARDE ALGUNS SEGUNDOS !',maxLines: 2,textAlign: TextAlign.center,), - SizedBox(height: 30,), - CircularProgressIndicator(color: PaletaCores.corPrimaria,) - ], - ), - ):ListView( - children: [ - Container( - child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.12) - ), - smsEnviado?Container():Container( - width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - child: InputText( - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - CpfInputFormatter(), - ], - textInputType: TextInputType.number, - controller: inputCPF, - title: 'CPF', - width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - colorBorder: PaletaCores.branco, + Container( + child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.12) ), - ), - smsEnviado?Container():Container( - width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - child: InputText( - inputFormatters: [], - obscure: true, - controller: inputSenha, - title: 'Senha', + smsEnviado?Container():Container( width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - colorBorder: PaletaCores.branco, - ), - ), - smsEnviado?Container():Container( - width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - child: InputText( - inputFormatters: [], - obscure: true, - controller: inputRepita, - title: 'Repetir Senha', - width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - colorBorder: PaletaCores.branco, - ), - ), - smsEnviado?Container():Container( - width: Dimensoes.width*0.6, - child: DropdownButtonHideUnderline( - child: DropdownButton( - hint: TextCustom(text: 'Cidade'), - value: cidade, - items: Fixos().listCidades.map((value) => DropdownMenuItem( - value: value.cidade, - child: TextCustom( - text: value.cidade, - color: Colors.black54, - ), - ) - ).toList(), - onChanged: (value){ - setState(() { - cidade = value!; - print(cidades.indexOf(cidade!)); - cidadeQuery = Fixos().listCidades[cidades.indexOf(cidade!)].cidadeQuery; - print(cidadeQuery); - }); - }, + child: InputText( + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + CpfInputFormatter(), + ], + textInputType: TextInputType.number, + controller: inputCPF, + title: 'CPF', + width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, + colorBorder: PaletaCores.branco, ), ), - ), - SizedBox(height: 20,), - smsEnviado?Container():ButtonCustom( - widthCustom: 0.7, - heightCustom: 0.07, - text: "Cadastrar", - fontsize: 14.0, - colorText: PaletaCores.branco, - colorButton: PaletaCores.corPrimaria, - colorBorder: PaletaCores.corPrimaria, - onPressed: ()=>verificacao(), - ), - smsEnviado?Container( - width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - child: InputText( - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - textInputType: TextInputType.number, - controller: inputCodigo, - title: 'Código SMS', + smsEnviado?Container():Container( width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, - colorBorder: PaletaCores.branco, + child: InputText( + inputFormatters: [], + obscure: true, + controller: inputSenha, + title: 'Senha', + width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, + colorBorder: PaletaCores.branco, + ), ), - ):Container(), - smsEnviado?ButtonCustom( - widthCustom: 0.7, - heightCustom: 0.07, - text: "Enviar", - fontsize: 14.0, - colorText: PaletaCores.branco, - colorButton: PaletaCores.corPrimaria, - colorBorder: PaletaCores.corPrimaria, - onPressed: ()=>verificacaoSMS(), - ):Container(), - ], + smsEnviado?Container():Container( + width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, + child: InputText( + inputFormatters: [], + obscure: true, + controller: inputRepita, + title: 'Repetir Senha', + width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, + colorBorder: PaletaCores.branco, + ), + ), + smsEnviado?Container():Container( + width: Dimensoes.width*0.6, + child: DropdownButtonHideUnderline( + child: DropdownButton( + hint: TextCustom(text: 'Cidade'), + value: cidade, + items: Fixos().listCidades.map((value) => DropdownMenuItem( + value: value.cidade, + child: TextCustom( + text: value.cidade, + color: Colors.black54, + ), + ) + ).toList(), + onChanged: (value){ + setState(() { + cidade = value!; + print(cidades.indexOf(cidade!)); + cidadeQuery = Fixos().listCidades[cidades.indexOf(cidade!)].cidadeQuery; + print(cidadeQuery); + }); + }, + ), + ), + ), + SizedBox(height: 20,), + smsEnviado?Container():ButtonCustom( + widthCustom: 0.7, + heightCustom: 0.07, + text: "Cadastrar", + fontsize: 14.0, + colorText: PaletaCores.branco, + colorButton: PaletaCores.corPrimaria, + colorBorder: PaletaCores.corPrimaria, + onPressed: ()=>verificacao(), + ), + smsEnviado?Container( + width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, + child: InputText( + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + textInputType: TextInputType.number, + controller: inputCodigo, + title: 'Código SMS', + width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7, + colorBorder: PaletaCores.branco, + ), + ):Container(), + smsEnviado?ButtonCustom( + widthCustom: 0.7, + heightCustom: 0.07, + text: "Enviar", + fontsize: 14.0, + colorText: PaletaCores.branco, + colorButton: PaletaCores.corPrimaria, + colorBorder: PaletaCores.corPrimaria, + onPressed: ()=>verificacaoSMS(), + ):Container(), + smsEnviado?SizedBox(height: 10):Container(), + smsEnviado?GestureDetector( + onTap: ()=>verificacao(), + child: TextCustom(text: "Não recebeu o SMS?\n Enviar novamente",maxLines: 2,textAlign: TextAlign.center,)) + :Container() + ], + ), ), ), );