Meu app novo#2391
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request bootstraps a new Flutter project named app_novo with platform-specific runner configurations, a GitHub Actions build workflow, and initial business logic for user authentication and clock-in processing. However, several critical compilation and test issues were identified in the Dart code. These include incorrect import schemes (using app_novo: instead of package:), incorrect relative paths for auth_repository.dart, a duplicate class definition of AuthRepository in auth_repository.dart, a missing views/login_view.dart file, and a widget test that incorrectly attempts to instantiate MyApp instead of the newly defined Gestor360App.
| import 'app_novo:flutter/material.dart'; | ||
| import 'app_novo:geolocator/geolocator.dart'; | ||
| import 'app_novo:device_info_plus/device_info_plus.dart'; |
There was a problem hiding this comment.
The import package name is incorrectly specified with the package prefix as the package scheme. It should be using the package: scheme instead of app_novo: to refer to external dependencies.
| import 'app_novo:flutter/material.dart'; | |
| import 'app_novo:geolocator/geolocator.dart'; | |
| import 'app_novo:device_info_plus/device_info_plus.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:geolocator/geolocator.dart'; | |
| import 'package:device_info_plus/device_info_plus.dart'; |
| import 'app_novo:geolocator/geolocator.dart'; | ||
| import 'app_novo:device_info_plus/device_info_plus.dart'; | ||
| import 'dart:io'; | ||
| import '../repositories/auth_repository.dart'; |
There was a problem hiding this comment.
| import 'app_novo:flutter/material.dart'; | ||
| import 'app_novo:device_info_plus/device_info_plus.dart'; | ||
| import '../repositories/auth_repository.dart'; // Ajuste o caminho se necessário |
There was a problem hiding this comment.
The import package names are incorrectly specified with the package prefix as the package scheme. It should be using the package: scheme instead of app_novo:. Also, the relative path to auth_repository.dart is incorrect because it is located in lib/data/auth_repository.dart.
| import 'app_novo:flutter/material.dart'; | |
| import 'app_novo:device_info_plus/device_info_plus.dart'; | |
| import '../repositories/auth_repository.dart'; // Ajuste o caminho se necessário | |
| import 'package:flutter/material.dart'; | |
| import 'package:device_info_plus/device_info_plus.dart'; | |
| import '../data/auth_repository.dart'; |
| @@ -0,0 +1,179 @@ | |||
| import 'app_novo:dio/dio.dart'; | |||
| class AuthRepository { | ||
| final Dio _dio = Dio(); | ||
|
|
||
| // 1. CONFIGURE SUA URL AQUI (Centralizado) | ||
| static const String _baseUrl = 'https://api.meusite.com/v1'; | ||
|
|
||
| // 1. Endpoint de Login | ||
| Future<LoginResponse> tentarAutenticacao(String identificacao, String senha, String deviceId) async { | ||
| try { | ||
| // CHAMADA HTTP REAL: Substituindo a simulação pelo Dio | ||
| final response = await _dio.post( | ||
| '$_baseUrl/login', // Monta: https://api.meusite.com/v1/login | ||
| data: { | ||
| 'identificacao': identificacao, | ||
| 'senha': senha, | ||
| 'device_id': deviceId, | ||
| }, | ||
| ); | ||
|
|
||
| if (response.statusCode == 200) { | ||
| final dados = response.data; // Resposta que veio do seu servidor | ||
|
|
||
| // Aqui você trata as regras que a IA simulou, mas usando os dados da sua API: | ||
| return LoginResponse( | ||
| sucesso: dados['sucesso'] ?? false, | ||
| dispositivoAutorizado: dados['dispositivo_autorizado'] ?? false, | ||
| deviceId: dados['device_id'], | ||
| dadosUsuario: dados['dados_usuario'], | ||
| ); | ||
| } | ||
|
|
||
| return LoginResponse(sucesso: false, dispositivoAutorizado: false); | ||
| } catch (e) { | ||
| print("Erro no login: $e"); | ||
| return LoginResponse(sucesso: false, dispositivoAutorizado: false); | ||
| } | ||
| } | ||
|
|
||
| // 2. Endpoint de Envio de Ponto (Multipart / Blob Binário) | ||
| Future<bool> registrarPontoComBlob({ | ||
| required int idBanco, | ||
| required String matricula, | ||
| required String deviceId, | ||
| required double latitude, | ||
| required double longitude, | ||
| required String timestamp, | ||
| String? caminhoFotoLocal, | ||
| }) async { | ||
| try { | ||
| Map<String, dynamic> mapaFormulario = { | ||
| "id_banco": idBanco, | ||
| "matricula": matricula, | ||
| "device_id": deviceId, | ||
| "latitude": latitude, | ||
| "longitude": longitude, | ||
| "timestamp": timestamp, | ||
| }; | ||
|
|
||
| if (caminhoFotoLocal != null) { | ||
| mapaFormulario["foto"] = await MultipartFile.fromFile( | ||
| caminhoFotoLocal, | ||
| filename: "ponto_${idBanco}_$timestamp.jpg", | ||
| ); | ||
| } | ||
|
|
||
| FormData formData = FormData.fromMap(mapaFormulario); | ||
|
|
||
| // CHAMADA HTTP REAL ATIVADA AQUI: | ||
| final response = await _dio.post( | ||
| "$_baseUrl/bater-ponto", // Usa a nossa variável lá de cima | ||
| data: formData, | ||
| ); | ||
|
|
||
| return response.statusCode == 200; | ||
| } catch (e) { | ||
| print("Erro ao transmitir ponto via Multipart: $e"); | ||
| return false; | ||
| } | ||
| } | ||
| } No newline at end of file |
| @@ -0,0 +1,25 @@ | |||
| import 'package:flutter/material.dart'; | |||
| import 'views/login_view.dart'; | |||
| void main() { | ||
| testWidgets('Counter increments smoke test', (WidgetTester tester) async { | ||
| // Build our app and trigger a frame. | ||
| await tester.pumpWidget(const MyApp()); |
There was a problem hiding this comment.
Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. For larger changes, raising an issue first helps
reduce redundant work.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-devrel channel on Discord.