Primeiro commit no ramo main
This commit is contained in:
44
lib/componentes/buttom_custom.dart
Normal file
44
lib/componentes/buttom_custom.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
|
||||
class ButtonCustom extends StatelessWidget{
|
||||
final VoidCallback onPressed;
|
||||
final String text;
|
||||
final double fontsize;
|
||||
final Color colorButton;
|
||||
final Color colorText;
|
||||
final Color colorBorder;
|
||||
final widthCustom;
|
||||
final heightCustom;
|
||||
|
||||
ButtonCustom({
|
||||
required this.onPressed,
|
||||
required this.text,
|
||||
required this.fontsize,
|
||||
required this.colorButton,
|
||||
required this.colorText,
|
||||
required this.colorBorder,
|
||||
this.widthCustom = 1.0,
|
||||
this.heightCustom = 1.0
|
||||
});
|
||||
@override
|
||||
Widget build (BuildContext context) {
|
||||
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: colorButton,
|
||||
minimumSize: Size(Dimensoes.width*widthCustom! , Dimensoes.height*heightCustom!),
|
||||
side: BorderSide(width: 2,color : colorBorder,),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(text,
|
||||
style: TextStyle(
|
||||
color: colorText,
|
||||
fontSize: fontsize,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
) ,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
104
lib/componentes/drawer_custom.dart
Normal file
104
lib/componentes/drawer_custom.dart
Normal file
@@ -0,0 +1,104 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:line_icons/line_icons.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
import '../servicos/shared_preferences/shared.dart';
|
||||
import '../telas/tela_login.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
import 'item_drawer.dart';
|
||||
|
||||
class DrawerCustom extends StatelessWidget {
|
||||
|
||||
String usuario;
|
||||
|
||||
DrawerCustom({
|
||||
required this.usuario
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
width: Dimensoes.width*0.8,
|
||||
height: Dimensoes.height,
|
||||
color: Colors.white,
|
||||
child: ListView(
|
||||
children: [
|
||||
// CircleAvatar(
|
||||
// radius: 70,
|
||||
// backgroundColor: Colors.grey[300],
|
||||
// child:estudanteModelo.foto==''?Container():
|
||||
// ClipRRect(
|
||||
// child: Image.asset(estudanteModelo.foto),
|
||||
// borderRadius:BorderRadius.circular(70),
|
||||
// )
|
||||
// ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0,horizontal: 40),
|
||||
child: TextCustom(text: usuario.split(" ").first,fontWeight: FontWeight.bold,size: 16.0,textAlign: TextAlign.start),
|
||||
),
|
||||
Container(
|
||||
height: Dimensoes.height*0.5,
|
||||
child: ListView(
|
||||
children: [
|
||||
ItemDrawer(
|
||||
icone: LineIcons.home,
|
||||
texto: 'HOME',
|
||||
onPressed: (){},
|
||||
// onPressed: ()=> Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => TelaSituacaoEscolar(alunos: alunos,indiceAluno: indiceFilhos)),
|
||||
// ),
|
||||
),
|
||||
Container(height: 1,color: Colors.grey,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
ItemDrawer(
|
||||
icone: LineIcons.clipboardList,
|
||||
texto: 'LANÇAMENTO DE NOTAS',
|
||||
onPressed: (){},
|
||||
// onPressed: ()=> Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => TelaPerfil(alunos: alunos,indiceAluno: indiceFilhos)),
|
||||
// ),
|
||||
),
|
||||
Container(height: 1,color: Colors.grey,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
ItemDrawer(
|
||||
icone: LineIcons.checkSquareAlt,
|
||||
texto: 'LANÇAMENTO DE FALTAS/PRESENÇAS',
|
||||
onPressed: (){},
|
||||
),
|
||||
Container(height: 1,color: Colors.grey,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
ItemDrawer(
|
||||
icone: LineIcons.calendar,
|
||||
texto: 'CALENDÁRIO ESCOLAR',
|
||||
onPressed: (){},
|
||||
// onPressed: ()=>Navigator.push(context, MaterialPageRoute(builder: (context)=>TelaChamada(alunos: alunos,indiceAluno: indiceFilhos))),
|
||||
),
|
||||
Container(height: 1,color: Colors.grey,margin: EdgeInsets.symmetric(horizontal: 20),),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: Dimensoes.height*0.3,),
|
||||
SafeArea(
|
||||
child: Container(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: IconButton(
|
||||
icon: Icon(LineIcons.alternateSignOut,size: 30),
|
||||
onPressed: (){
|
||||
final PrefService _prefService = PrefService();
|
||||
_prefService.removeCacheLogin().then((value){
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context, MaterialPageRoute(
|
||||
builder: (context) => TelaLogin()
|
||||
),
|
||||
(Route<dynamic> route) => false
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
57
lib/componentes/dropdown_button_city.dart
Normal file
57
lib/componentes/dropdown_button_city.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
import 'package:rkm_educa_prof_app/utils/cidades_db.dart';
|
||||
|
||||
import '../utils/cores.dart';
|
||||
|
||||
class DropDownButtonCity extends StatelessWidget {
|
||||
var onChanged;
|
||||
String? select;
|
||||
bool validator;
|
||||
String error;
|
||||
|
||||
DropDownButtonCity({
|
||||
required this.onChanged,
|
||||
required this.select,
|
||||
required this.error,
|
||||
required this.validator
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: width,
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
color:PaletaCores.cinzaInput,
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
hint: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: TextCustom(text: 'Cidade',size: 15.0),
|
||||
),
|
||||
value: select,
|
||||
items: Cidades().listCidades.map((value) => DropdownMenuItem(
|
||||
value: value.cidadeFront,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: TextCustom(
|
||||
text: value.cidadeFront,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
)
|
||||
).toList(),
|
||||
onChanged:onChanged
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
84
lib/componentes/input_text.dart
Normal file
84
lib/componentes/input_text.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../utils/cores.dart';
|
||||
|
||||
class InputText extends StatelessWidget {
|
||||
bool obscure;
|
||||
var controller;
|
||||
double fontSize;
|
||||
String title;
|
||||
double width;
|
||||
TextInputType textInputType;
|
||||
int maxLines;
|
||||
Color colorBorder;
|
||||
var onChanged;
|
||||
bool enable;
|
||||
List<TextInputFormatter> inputFormatters;
|
||||
|
||||
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 = PaletaCores.cinza,
|
||||
this.onChanged = null,
|
||||
this.enable = true,
|
||||
required this.inputFormatters
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: width,
|
||||
child: Text(title,style: TextStyle(fontWeight: FontWeight.bold,fontFamily: 'Nunito'),)
|
||||
),
|
||||
Container(
|
||||
color:PaletaCores.cinzaInput,
|
||||
width: width,
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: TextFormField(
|
||||
inputFormatters: inputFormatters,
|
||||
keyboardType: textInputType,
|
||||
maxLines: maxLines,
|
||||
onChanged: onChanged,
|
||||
obscureText: this.obscure,
|
||||
controller: this.controller,
|
||||
enabled: enable,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: this.fontSize,
|
||||
fontFamily: 'Nunito'
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
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,
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
29
lib/componentes/item_drawer.dart
Normal file
29
lib/componentes/item_drawer.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_prof_app/componentes/text_custom.dart';
|
||||
import '../utils/cores.dart';
|
||||
|
||||
class ItemDrawer extends StatelessWidget {
|
||||
IconData icone;
|
||||
String texto;
|
||||
var onPressed;
|
||||
|
||||
ItemDrawer({
|
||||
required this.texto,
|
||||
required this.icone,
|
||||
required this.onPressed
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: width*0.07),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: Icon(icone,color: PaletaCores.cinza,),
|
||||
label: TextCustom(text: texto,size: 12.0,)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
20
lib/componentes/snackBars.dart
Normal file
20
lib/componentes/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);
|
||||
}
|
||||
39
lib/componentes/text_custom.dart
Normal file
39
lib/componentes/text_custom.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/cores.dart';
|
||||
|
||||
class TextCustom extends StatelessWidget {
|
||||
final text;
|
||||
final size;
|
||||
final color;
|
||||
final fontWeight;
|
||||
final textAlign;
|
||||
final maxLines;
|
||||
|
||||
TextCustom({
|
||||
required this.text,
|
||||
this.size = 16.0,
|
||||
this.color = PaletaCores.cinza,
|
||||
this.fontWeight = FontWeight.normal,
|
||||
this.textAlign = TextAlign.start,
|
||||
this.maxLines = 1,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: textAlign,
|
||||
style: TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: color,
|
||||
fontSize: size,
|
||||
fontWeight: fontWeight,
|
||||
decorationThickness: 4,
|
||||
fontFamily: 'Nunito',
|
||||
decoration: TextDecoration.none
|
||||
),
|
||||
maxLines: maxLines,
|
||||
);
|
||||
}
|
||||
}
|
||||
81
lib/controllers/main_controllers.dart
Normal file
81
lib/controllers/main_controllers.dart
Normal file
@@ -0,0 +1,81 @@
|
||||
import 'dart:convert';
|
||||
import 'package:gainer_crypto/crypto.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class MainControllers{
|
||||
encrypt(String senhaDigitada,String senhaUsuario) {
|
||||
// Deixa e senha digitada em maiuscula
|
||||
var senha = senhaDigitada.toUpperCase();
|
||||
// Faz a criptografia da senha inserida
|
||||
String senhaMD5 = grHashString(GRCryptoType.md5, senha);
|
||||
// Retira o tipo (1, 2 ou 3) da senha do Usuário
|
||||
int tipo = int.parse(senhaUsuario.substring(0, 1));
|
||||
// Define a possição inicial da quebra da senha
|
||||
int posicaoInicialMin = 0;
|
||||
int posicaoInicialMax= 0;
|
||||
int posicaoFinalMin = 0;
|
||||
int posicaoFinalMax = 0;
|
||||
// Pra cada tipo (1, 2 ou 3) define a posição inicial da quebra da senha
|
||||
if(tipo == 1){
|
||||
posicaoInicialMin = 0;
|
||||
posicaoInicialMax = 16;
|
||||
posicaoFinalMin = 16;
|
||||
posicaoFinalMax = 32;
|
||||
} else if(tipo == 2){
|
||||
posicaoInicialMin = 16;
|
||||
posicaoInicialMax = 32;
|
||||
posicaoFinalMin = 0;
|
||||
posicaoFinalMax = 16;
|
||||
} else if(tipo == 3){
|
||||
posicaoInicialMin = 0;
|
||||
posicaoInicialMax = 1;
|
||||
posicaoFinalMin = 31;
|
||||
posicaoFinalMax = 32;
|
||||
}
|
||||
|
||||
String inicio = senhaMD5.substring(posicaoInicialMin, posicaoInicialMax);
|
||||
String fim = senhaMD5.substring(posicaoFinalMin, posicaoFinalMax);
|
||||
|
||||
// Faz a criptografia e concatena ela com sha1 e md5
|
||||
String senhaCriptogradafa = tipo.toString() + '\$'+ grHashString(GRCryptoType.sha1, inicio + senha + fim);
|
||||
// Retorna a senha criptografada
|
||||
return senhaCriptogradafa;
|
||||
}
|
||||
// salvarLog(EstudanteModelo estudanteModelo,String TELA)async{
|
||||
// final url = '${estudanteModelo.URL}/log';
|
||||
// // print('dados');
|
||||
// // print(widget.estudanteModelo.dados);
|
||||
// final response = await http.post(
|
||||
// Uri.parse(url),
|
||||
// body:{
|
||||
// 'DATA' : DateFormat('dd/MM/yyyy HH:mm').format(DateTime.now()),
|
||||
// 'TELA' : TELA,
|
||||
// 'CD_USUARIO' : estudanteModelo.CD_USUARIO,
|
||||
// 'NO_USUARIO': estudanteModelo.NO_USUARIO,
|
||||
// 'CD_ALUNO': estudanteModelo.dados[estudanteModelo.nroAluno]['CD_ALUNO'],
|
||||
// 'NO_ALUNO': estudanteModelo.dados[estudanteModelo.nroAluno]['NO_ALUNO'],
|
||||
// 'CIDADE' : estudanteModelo.cidade
|
||||
// }
|
||||
// );
|
||||
//
|
||||
// print('response : ${response.body}');
|
||||
// }
|
||||
Future<int> pegarAno(String urlAPI,String cidade)async{
|
||||
final url = '$urlAPI/mostrar_boletim?ANO=${DateTime.now().year}&CIDADE=$cidade';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
String data = map[0]['DT_INICIAL'];
|
||||
DateTime dataInicial = DateTime.parse(data);
|
||||
// print(dataInicial);
|
||||
// print(DateTime.now());
|
||||
// print((DateTime.now().difference(dataInicial).inDays).toInt());
|
||||
if(DateTime.now().difference(dataInicial).inDays>=0){
|
||||
print('exibir ano atual');
|
||||
return DateTime.now().year;
|
||||
}else{
|
||||
print('exibir ano anterior');
|
||||
return DateTime.now().year-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
5
lib/controllers/routes.dart
Normal file
5
lib/controllers/routes.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
import 'package:rkm_educa_prof_app/telas/tela_splash.dart';
|
||||
|
||||
var routes = {
|
||||
'/splash': (context) => TelaSplash(),
|
||||
};
|
||||
44
lib/main.dart
Normal file
44
lib/main.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:rkm_educa_prof_app/telas/tela_splash.dart';
|
||||
|
||||
import 'controllers/routes.dart';
|
||||
|
||||
class PostHttpOverrides extends HttpOverrides{
|
||||
@override
|
||||
HttpClient createHttpClient( context){
|
||||
return super.createHttpClient(context)
|
||||
..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
HttpOverrides.global = new PostHttpOverrides();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
localizationsDelegates: [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: [
|
||||
const Locale('pt','BR')
|
||||
],
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: const Locale('pt'),
|
||||
initialRoute: '/splash',
|
||||
routes: routes,
|
||||
);
|
||||
}
|
||||
}
|
||||
11
lib/modelos/cidade_model.dart
Normal file
11
lib/modelos/cidade_model.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
class CidadeModel{
|
||||
String codigo;
|
||||
String cidadeQuery;
|
||||
String cidadeFront;
|
||||
|
||||
CidadeModel({
|
||||
required this.codigo,
|
||||
required this.cidadeQuery,
|
||||
required this.cidadeFront
|
||||
});
|
||||
}
|
||||
17
lib/servicos/shared_preferences/shared.dart
Normal file
17
lib/servicos/shared_preferences/shared.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class PrefService{
|
||||
Future createCacheLogin(String cpf, String senha,String cidade)async{
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
preferences.setStringList('login', [cpf,senha,cidade]);
|
||||
}
|
||||
Future readCacheLogin()async{
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
final List<String>? login = preferences.getStringList('login');
|
||||
return login;
|
||||
}
|
||||
Future removeCacheLogin()async{
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
preferences.remove('login');
|
||||
}
|
||||
}
|
||||
30
lib/telas/tela_home.dart
Normal file
30
lib/telas/tela_home.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../componentes/drawer_custom.dart';
|
||||
|
||||
class TelaHome extends StatefulWidget {
|
||||
List list;
|
||||
|
||||
TelaHome({
|
||||
required this.list
|
||||
});
|
||||
|
||||
@override
|
||||
State<TelaHome> createState() => _TelaHomeState();
|
||||
}
|
||||
|
||||
class _TelaHomeState extends State<TelaHome> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
iconTheme: IconThemeData(color: Colors.black),
|
||||
),
|
||||
drawer: DrawerCustom(usuario: widget.list[1]),
|
||||
body: Center(
|
||||
child: Text('home'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
252
lib/telas/tela_login.dart
Normal file
252
lib/telas/tela_login.dart
Normal file
@@ -0,0 +1,252 @@
|
||||
import 'dart:convert';
|
||||
import 'package:brasil_fields/brasil_fields.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rkm_educa_prof_app/telas/tela_home.dart';
|
||||
import '../componentes/buttom_custom.dart';
|
||||
import '../componentes/dropdown_button_city.dart';
|
||||
import '../componentes/input_text.dart';
|
||||
import '../componentes/snackBars.dart';
|
||||
import '../controllers/main_controllers.dart';
|
||||
import '../servicos/shared_preferences/shared.dart';
|
||||
import '../utils/cidades_db.dart';
|
||||
import '../utils/cores.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../componentes/text_custom.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
import '../utils/fixos.dart';
|
||||
|
||||
class TelaLogin extends StatefulWidget {
|
||||
const TelaLogin({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<TelaLogin> createState() => _TelaLoginState();
|
||||
}
|
||||
|
||||
class _TelaLoginState extends State<TelaLogin> {
|
||||
|
||||
// final inputLogin = TextEditingController(text: '402.061.058-43');
|
||||
final inputLogin = TextEditingController();
|
||||
final inputSenha = TextEditingController();
|
||||
final inputRepetirSenha = TextEditingController();
|
||||
bool carregando = false;
|
||||
String tituloSenha = 'Senha';
|
||||
String status = 'VALIDANDO ACESSO...';
|
||||
var map;
|
||||
int contLogo = 0;
|
||||
String urlAPI = 'https://homol-controle-educa-api.rkmsistemas.com.br';
|
||||
List listCidades = [];
|
||||
String? selectCity;
|
||||
final PrefService _prefService = PrefService();
|
||||
|
||||
verificacao(){
|
||||
String cidade = '';
|
||||
if(inputLogin.text.isNotEmpty){
|
||||
if(inputSenha.text.isNotEmpty){
|
||||
if(selectCity!=null){
|
||||
for(int i =0; listCidades.length > i; i ++){
|
||||
if(selectCity == Cidades().listCidades[i].cidadeFront){
|
||||
cidade = Cidades().listCidades[i].cidadeQuery;
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
carregando = true;
|
||||
});
|
||||
if(inputLogin.text.toUpperCase() == 'ADMIN'){
|
||||
conectAPI(cidade);
|
||||
}else{
|
||||
getAcessosMariaDB(cidade);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Selecione sua cidade', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha sua senha', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha seu Login', Colors.red);
|
||||
}
|
||||
}
|
||||
|
||||
conectAPI(String cidade)async{
|
||||
|
||||
final url = '$urlAPI/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}&CIDADE=${cidade.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
print(map);
|
||||
if(map==false){
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', 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);
|
||||
List dados = [cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'',map['CD_UNIDADE']??0];
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => TelaHome(list: dados) ));
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}else{
|
||||
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
||||
print(map);
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
List dados = [cidade.toUpperCase(),map['NO_USUARIO_SISTEMA']??'',urlAPI,map['NO_FANTASIA']??'',map['CD_UNIDADE']??0];
|
||||
_prefService.createCacheLogin(inputLogin.text, inputSenha.text,cidade).then((value) =>
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => TelaHome(list: dados) )));
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
carregarLista(){
|
||||
for(int i=0;Cidades().listCidades.length>i;i++){
|
||||
listCidades.add(Cidades().listCidades[i].cidadeQuery);
|
||||
}
|
||||
}
|
||||
|
||||
getAcessosMariaDB(String cidade)async{
|
||||
final url = '$urlAPI/acesso_maria?LOGIN=${inputLogin.text.toUpperCase()}&CIDADE=${cidade.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
print(map);
|
||||
List list = map;
|
||||
if(list.length != 0 ){
|
||||
for(int i=0;list.length>i;i++){
|
||||
if(list[i]['ID_USUARIO']==inputLogin.text.toUpperCase() &&list[i]['CONDICAO']=='1'){
|
||||
conectAPI(cidade);
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login seu acesso não está liberado!', Colors.red);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
carregarLista();
|
||||
_prefService.readCacheLogin().then((login){
|
||||
if(login!=null){
|
||||
setState(() {
|
||||
carregando = true;
|
||||
});
|
||||
print(login);
|
||||
inputLogin.text = login[0];
|
||||
inputSenha.text = login[1];
|
||||
conectAPI(login[2]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: PaletaCores.branco,
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(Dimensoes.width*0.15),
|
||||
width: Dimensoes.width,
|
||||
height: Dimensoes.height,
|
||||
alignment: Alignment.center,
|
||||
child: ListView(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: carregando?null:()=>setState((){
|
||||
contLogo++;
|
||||
if(contLogo<5){
|
||||
urlAPI = Fixos.LINK_API_HOMOL;
|
||||
}else{
|
||||
contLogo=0;
|
||||
urlAPI = Fixos.LINK_API_LOCAL;
|
||||
}
|
||||
// if(contLogo>=5 && contLogo<=10){
|
||||
// urlAPI = Fixos.AMB_HOMO;
|
||||
// }
|
||||
// if(contLogo>10){
|
||||
// urlAPI = Fixos.AMB_DEV;
|
||||
// if(contLogo==15){
|
||||
// contLogo=0;
|
||||
// urlAPI = Fixos.AMB_PROD;
|
||||
// }
|
||||
// }
|
||||
// print(contLogo);
|
||||
// print(urlAPI);
|
||||
}),
|
||||
child: Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.12)
|
||||
),
|
||||
),
|
||||
urlAPI==Fixos.LINK_API_LOCAL?Container(
|
||||
child: Image.asset("assets/images/desenvolvimento.png",width:Dimensoes.width * 0.5,height: Dimensoes.height * 0.12)
|
||||
):Container(),
|
||||
urlAPI==Fixos.LINK_API_HOMOL?Container(
|
||||
child: Image.asset("assets/images/homologacao.png",width:Dimensoes.width * 0.5,height: Dimensoes.height * 0.12)
|
||||
):Container(),
|
||||
carregando?Container():Container(
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
textInputType: TextInputType.text,
|
||||
controller: inputLogin,
|
||||
title: 'Login',
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
colorBorder: PaletaCores.branco,
|
||||
),
|
||||
),
|
||||
carregando?Container():Container(
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputSenha,
|
||||
title: tituloSenha,
|
||||
obscure: true,
|
||||
width: Dimensoes.width>900? Dimensoes.width * 0.18:Dimensoes.width*0.7,
|
||||
colorBorder: PaletaCores.branco,
|
||||
),
|
||||
),
|
||||
SizedBox(height: Dimensoes.height * 0.02),
|
||||
carregando?Container():DropDownButtonCity(
|
||||
error: 'Campo obrigatório',
|
||||
validator: true,
|
||||
select: selectCity,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
selectCity = value!;
|
||||
print(selectCity);
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(height: Dimensoes.height * 0.02),
|
||||
carregando?Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(color: PaletaCores.cinzaClaro,),
|
||||
SizedBox(width: 20,),
|
||||
TextCustom(text: status,maxLines: 1,size: 12.0,)
|
||||
],
|
||||
):ButtonCustom(
|
||||
widthCustom: 0.7,
|
||||
heightCustom: 0.07,
|
||||
text: "Entrar",
|
||||
fontsize: 14.0,
|
||||
colorText: PaletaCores.branco,
|
||||
colorButton: PaletaCores.corPrimaria,
|
||||
colorBorder: PaletaCores.corPrimaria,
|
||||
onPressed: ()=>verificacao(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
44
lib/telas/tela_splash.dart
Normal file
44
lib/telas/tela_splash.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm_educa_prof_app/telas/tela_login.dart';
|
||||
import '../utils/cores.dart';
|
||||
import '../utils/dimensoes.dart';
|
||||
|
||||
class TelaSplash extends StatefulWidget {
|
||||
const TelaSplash({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<TelaSplash> createState() => _TelaSplashState();
|
||||
}
|
||||
|
||||
class _TelaSplashState extends State<TelaSplash> {
|
||||
|
||||
carregar()async{
|
||||
Future.delayed(Duration(seconds: 3),(){
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)=>TelaLogin()));
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
carregar();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Dimensoes().init(context);
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:Dimensoes.width * 0.4,height: Dimensoes.height * 0.15)
|
||||
),
|
||||
CircularProgressIndicator(color: PaletaCores.cinzaClaro,)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
9
lib/utils/cidades_db.dart
Normal file
9
lib/utils/cidades_db.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import '../modelos/cidade_model.dart';
|
||||
|
||||
class Cidades{
|
||||
List <CidadeModel> listCidades =[
|
||||
CidadeModel(codigo: 'E001', cidadeQuery: 'aguasdelindoia',cidadeFront: 'Águas de Lindóia'),
|
||||
CidadeModel(codigo: 'E002', cidadeQuery: 'corumbatai', cidadeFront: 'Corumbataí'),
|
||||
CidadeModel(codigo: 'E003',cidadeQuery: 'iracemapolis', cidadeFront: 'Iracemápolis'),
|
||||
];
|
||||
}
|
||||
16
lib/utils/cores.dart
Normal file
16
lib/utils/cores.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PaletaCores{
|
||||
static const Color branco = Colors.white;
|
||||
static const Color corPrimaria = Color(0xffBB0202);
|
||||
static const Color fundoTela = Color(0xffdfdfdf);
|
||||
static const Color cinza = Color (0xff757575);
|
||||
static const Color cinzaEscuro = Color (0xff545050);
|
||||
static const Color cinzaClaro = Color (0xff7A7A7A);
|
||||
static const Color divider = Color (0xffc9c9c9);
|
||||
static const Color cinzaInput = Color (0xffE1E1E1);
|
||||
static const Color calendario = Color (0xffB1B1B1);
|
||||
static const Color verdeCalendario = Color (0xff4d7f49);
|
||||
static const Color notificacao = Color (0xffBB0202);
|
||||
static const Color appBar = Color(0xff3A3A3A);
|
||||
}
|
||||
13
lib/utils/dimensoes.dart
Normal file
13
lib/utils/dimensoes.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Dimensoes {
|
||||
static MediaQueryData media = MediaQueryData();
|
||||
static double width = 0.0;
|
||||
static double height = 0.0;
|
||||
|
||||
void init(BuildContext context) {
|
||||
media = MediaQuery.of(context);
|
||||
width = media.size.width;
|
||||
height = media.size.height;
|
||||
}
|
||||
}
|
||||
7
lib/utils/fixos.dart
Normal file
7
lib/utils/fixos.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import '../modelos/cidade_model.dart';
|
||||
|
||||
class Fixos{
|
||||
static const String LINK_API_LOCAL = 'http://192.168.18.2:8000';
|
||||
static const String LINK_API_CONTAINER = 'http://192.168.0.42:8013';
|
||||
static const String LINK_API_HOMOL = 'https://homol-controle-educa-api.rkmsistemas.com.br';
|
||||
}
|
||||
Reference in New Issue
Block a user