From 230a9fbbe59f71386ac2c0c582ecaa611e6e1edc Mon Sep 17 00:00:00 2001 From: ramires Date: Wed, 3 Apr 2024 12:26:49 -0300 Subject: [PATCH] Corrigir branch --- frontend/sige_ie/lib/screens/facilities.dart | 0 frontend/sige_ie/lib/screens/home.dart | 0 frontend/sige_ie/lib/screens/login.dart | 264 ------------- frontend/sige_ie/lib/screens/maps.dart | 0 frontend/sige_ie/lib/screens/register.dart | 359 ------------------ .../lib/screens/\341\271\225roflile.dart" | 0 6 files changed, 623 deletions(-) delete mode 100644 frontend/sige_ie/lib/screens/facilities.dart delete mode 100644 frontend/sige_ie/lib/screens/home.dart delete mode 100644 frontend/sige_ie/lib/screens/login.dart delete mode 100644 frontend/sige_ie/lib/screens/maps.dart delete mode 100644 frontend/sige_ie/lib/screens/register.dart delete mode 100644 "frontend/sige_ie/lib/screens/\341\271\225roflile.dart" diff --git a/frontend/sige_ie/lib/screens/facilities.dart b/frontend/sige_ie/lib/screens/facilities.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/sige_ie/lib/screens/home.dart b/frontend/sige_ie/lib/screens/home.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/sige_ie/lib/screens/login.dart b/frontend/sige_ie/lib/screens/login.dart deleted file mode 100644 index 1b3dc404..00000000 --- a/frontend/sige_ie/lib/screens/login.dart +++ /dev/null @@ -1,264 +0,0 @@ -import 'dart:convert'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -class LoginScreen extends StatefulWidget { - const LoginScreen({Key? key}) : super(key: key); - @override - State createState() => _LoginScreenState(); -} - -class _LoginScreenState extends State { - bool rememberMe = false; - final _loginScreen = GlobalKey(); - final TextEditingController usernameController = TextEditingController(); - final TextEditingController passwordController = TextEditingController(); - - Future login(String username, String password) async { - var url = Uri.parse('http://10.0.2.2:8000/api/login/'); - try { - var response = await http.post(url, - headers: { - 'Content-Type': 'application/json', - }, - body: jsonEncode({ - 'username': username, - 'password': password, - })); - if (response.statusCode == 200) { - var data = jsonDecode(response.body); - print("Login bem-sucedido: $data"); - return true; - } else { - print("Falha no login: ${response.body}"); - return false; - } - } catch (e) { - print("Erro ao tentar fazer login: $e"); - return false; - } - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xff123c75), - appBar: AppBar( - iconTheme: IconThemeData(color: Colors.white), - backgroundColor: const Color(0xff123c75), - ), - body: Center( - child: Column( - children: [ - Expanded( - flex: 2, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/1000x1000.png'), - fit: BoxFit.cover, - ), - ), - ), - ), - Expanded( - flex: 6, - child: Container( - padding: const EdgeInsets.fromLTRB(25.0, 50.0, 25.0, 20.0), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.only(topLeft: Radius.circular(50.0))), - child: SingleChildScrollView( - child: Form( - key: _loginScreen, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - 'Login', - style: TextStyle( - fontSize: 30.0, - fontWeight: FontWeight.w900, - color: Colors.black), - ), - const SizedBox(height: 35), - TextFormField( - controller: usernameController, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira um username válido'; - } - return null; - }, - decoration: InputDecoration( - label: const Text('Username'), - labelStyle: const TextStyle(color: Colors.black), - hintText: 'Insira o seu username', - hintStyle: const TextStyle( - color: Colors.black, - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 39, 38, 38), - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 0, 0, 0), - ), - borderRadius: BorderRadius.circular(10), - ), - )), - const SizedBox(height: 20), - TextFormField( - controller: passwordController, - obscureText: true, - obscuringCharacter: '*', - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira uma senha válida'; - } - return null; - }, - decoration: InputDecoration( - label: const Text('Senha'), - labelStyle: const TextStyle(color: Colors.black), - hintText: 'Insira a senha', - hintStyle: const TextStyle( - color: Color.fromARGB(255, 0, 0, 0), - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(31, 255, 3, 3), - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 0, 0, 0), - ), - borderRadius: BorderRadius.circular(10), - ), - ), - ), - const SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Checkbox( - value: rememberMe, - onChanged: (bool? value) { - setState(() { - rememberMe = value!; - }); - }, - activeColor: - Color.fromARGB(255, 12, 78, 170)), - const Text( - 'Manter conectado', - style: TextStyle( - color: Color.fromARGB(255, 0, 0, 0), - ), - ), - ], - ), - GestureDetector( - child: Text( - 'Esqueceu a senha?', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Color(0xff123c75), - ), - ), - ), - ], - ), - const SizedBox(height: 20), - SizedBox( - width: 200, - height: 50, - child: ElevatedButton( - onPressed: () async { - if (_loginScreen.currentState!.validate()) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Processando dados')), - ); - - bool success = await login( - usernameController.text, - passwordController.text); - - ScaffoldMessenger.of(context) - .hideCurrentSnackBar(); - - if (success) { - Navigator.of(context) - .pushReplacementNamed('/?'); - } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text( - 'Login falhou, verifique suas credenciais')), - ); - } - } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text( - 'Por favor, preencha todos os campos')), - ); - } - }, - child: const Text( - 'Login', - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - style: ElevatedButton.styleFrom( - elevation: 6, - backgroundColor: - Color.fromARGB(255, 244, 248, 0), - foregroundColor: Color(0xff123c75), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - )), - ), - ), - const SizedBox(height: 30), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'Não tem uma conta? ', - style: TextStyle( - color: Color.fromARGB(255, 0, 0, 0)), - ), - GestureDetector( - onTap: () { - Navigator.pushNamed( - context, '/registerScreen'); - }, - child: Text( - 'Registre-se', - style: TextStyle( - fontWeight: FontWeight.bold, - color: const Color(0xff123c75), - ), - ), - ), - ]) - ], - ), - )), - )) - ], - ), - ), - ); - } -} diff --git a/frontend/sige_ie/lib/screens/maps.dart b/frontend/sige_ie/lib/screens/maps.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/sige_ie/lib/screens/register.dart b/frontend/sige_ie/lib/screens/register.dart deleted file mode 100644 index 7d64fb70..00000000 --- a/frontend/sige_ie/lib/screens/register.dart +++ /dev/null @@ -1,359 +0,0 @@ -import 'dart:convert'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'package:http/http.dart' as http; - -class RegisterScreen extends StatefulWidget { - const RegisterScreen({super.key}); - @override - State createState() => _RegisterScreenState(); -} - -// Definição da classe da tela de Registro -class _RegisterScreenState extends State { - bool terms = true; - final _registerScreen = GlobalKey(); - final TextEditingController usernameController = TextEditingController(); - final TextEditingController nameController = TextEditingController(); - final TextEditingController passwordController = TextEditingController(); - final TextEditingController emailController = TextEditingController(); - - Future register( - String username, String firstName, String password, String email) async { - var url = Uri.parse('http://10.0.2.2:8000/api/users/'); - try { - var response = await http.post(url, - headers: { - 'Content-Type': 'application/json', - }, - body: jsonEncode({ - 'username': username, - 'first_name': firstName, - 'password': password, - 'email': email, - })); - if (response.statusCode == 200 || response.statusCode == 201) { - var data = jsonDecode(response.body); - print("Registro bem-sucedido: $data"); - return true; - } else { - print("Falha no registro: ${response.body}"); - return false; - } - } catch (e) { - print("Erro ao tentar registrar: $e"); - return false; - } - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xff123c75), - appBar: AppBar( - iconTheme: IconThemeData(color: Colors.white), - backgroundColor: const Color(0xff123c75), - ), - body: Center( - // Logo da Página e Seu Formato - child: Column( - children: [ - Expanded( - flex: 2, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/1000x1000.png'), - fit: BoxFit.cover, - ), - ), - ), - ), - Expanded( - flex: 6, // Configuração da página - child: Container( - padding: const EdgeInsets.fromLTRB(25.0, 50.0, 25.0, 20.0), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.only(topLeft: Radius.circular(50.0))), - child: SingleChildScrollView( - child: Form( - key: _registerScreen, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text('Registro', // Nome da Página de Registro - style: TextStyle( - fontSize: 30.0, - fontWeight: FontWeight.w900, - color: Colors.black)), - const SizedBox(height: 35), - TextFormField( - controller: usernameController, - decoration: InputDecoration( - label: const Text('Username'), - labelStyle: const TextStyle(color: Colors.black), - hintText: 'Insira o seu username', - hintStyle: const TextStyle( - color: Colors.black, - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 39, 38, 38), - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 0, 0, 0), - ), - borderRadius: BorderRadius.circular(10), - ), - // Outras propriedades... - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira um username válido'; - } - return null; - }, - ), - const SizedBox(height: 20), - - // Campo de nome e decoração da borda de inserção dos dados - TextFormField( - controller: nameController, - decoration: InputDecoration( - label: const Text('Nome'), - labelStyle: const TextStyle(color: Colors.black), - hintText: 'Insira seu Nome', - hintStyle: const TextStyle( - color: Colors.black, - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 39, 38, 38), - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 0, 0, 0), - ), - borderRadius: BorderRadius.circular(10), - ), - // Outras propriedades... - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por Favor Insira seu Nome'; - } - return null; - }, - ), - const SizedBox(height: 20), - TextFormField( - controller: emailController, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Insira um email valido'; - } - return null; - }, - decoration: InputDecoration( - label: const Text('Email'), - labelStyle: - const TextStyle(color: Colors.black), - hintText: 'Insira o Email', - hintStyle: const TextStyle( - color: Colors.black, - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 39, 38, 38), - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 0, 0, 0), - ), - borderRadius: BorderRadius.circular(10), - ), - )), - const SizedBox(height: 20), - TextFormField( - controller: passwordController, - obscureText: true, - obscuringCharacter: '*', - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por Favor, insira uma senha valida'; - } - return null; - }, - decoration: InputDecoration( - label: const Text('Senha'), - labelStyle: const TextStyle(color: Colors.black), - hintText: 'Insira a senha', - hintStyle: const TextStyle( - color: Color.fromARGB(255, 0, 0, 0), - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(31, 255, 3, 3), - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(255, 0, 0, 0), - ), - borderRadius: BorderRadius.circular(10)), - ), - ), - const SizedBox(height: 20), - TextFormField( - obscureText: true, - obscuringCharacter: '*', - validator: (value) { - if (value == null || - value.isEmpty || - value != passwordController.text) { - return 'As senhas não coincidem'; - } - return null; - }, - decoration: InputDecoration( - label: const Text('Confirmar Senha'), - labelStyle: const TextStyle(color: Colors.black), - hintText: 'Confirme sua senha', - hintStyle: const TextStyle( - color: Color.fromARGB(255, 0, 0, 0), - ), - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Color.fromARGB(31, 255, 3, 3), - ), - borderRadius: BorderRadius.circular(10), - ), - ), - ), - const SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Checkbox( - value: terms, - onChanged: (bool? value) { - setState(() { - terms = value!; - }); - }, - activeColor: - Color.fromARGB(255, 12, 78, 170)), - const Text( - 'Aceite os Termos', - style: TextStyle( - color: const Color(0xff123c75), - ), - ), - ], - ), - ], - ), - const SizedBox(height: 20), - SizedBox( - width: 200, - height: 50, - child: ElevatedButton( - onPressed: () async { - if (_registerScreen.currentState!.validate()) { - if (terms) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Processando Dados'), - ), - ); - bool success = await register( - usernameController.text, - nameController.text, - passwordController.text, - emailController.text); - ScaffoldMessenger.of(context) - .hideCurrentSnackBar(); - - if (success) { - FocusScope.of(context).unfocus(); - Navigator.of(context) - .pushReplacementNamed('/loginScreen'); - } else { - ScaffoldMessenger.of(context) - .showSnackBar( - const SnackBar( - content: Text( - 'Registro falhou, por favor tente novamente.'), - ), - ); - } - } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text( - 'Por Favor, concorde com o processamento de dados pessoais'), - ), - ); - } - } - }, - child: const Text( - 'Registro', - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - style: ElevatedButton.styleFrom( - elevation: 6, - backgroundColor: - Color.fromARGB(255, 244, 248, 0), - foregroundColor: Color(0xff123c75), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - )), - ), - ), - const SizedBox(height: 30), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'Já tem uma conta? ', - style: TextStyle( - color: Color.fromARGB(255, 0, 0, 0)), - ), - GestureDetector( - onTap: () { - Navigator.pushNamed(context, '/loginScreen'); - }, - child: Text( - 'Fazer login', - style: TextStyle( - fontWeight: FontWeight.bold, - color: const Color(0xff123c75), - ), - ), - ), - ], - ), - const SizedBox(height: 10), - ], - ), - )), - )) - ], - ), - )); - } -} diff --git "a/frontend/sige_ie/lib/screens/\341\271\225roflile.dart" "b/frontend/sige_ie/lib/screens/\341\271\225roflile.dart" deleted file mode 100644 index e69de29b..00000000