Skip to content

Commit

Permalink
fix#00: refatoração de todas os arquivos e pastas
Browse files Browse the repository at this point in the history
  • Loading branch information
EngDann committed Dec 28, 2024
1 parent fc4872f commit 39bab3e
Show file tree
Hide file tree
Showing 49 changed files with 110 additions and 144 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/log/log.dart';

class StorageValue {

static const String _authToken = "auth_token";
static const String _refreshToken = "refresh_token";
static const String _email = "email";
Expand All @@ -15,8 +14,7 @@ class StorageValue {
: storage = const FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true));

factory StorageValue.getInstance() =>
_singleton ??= StorageValue._internal();
factory StorageValue.getInstance() => _singleton ??= StorageValue._internal();

Future<void> _setValue(String key, String value) async {
try {
Expand Down
File renamed without changes.
7 changes: 3 additions & 4 deletions lib/core/network/app_interceptors.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:aranduapp/core/data/local/StorageValue.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/data/local/storage_value.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/core/network/token_manager/auth_service.dart';
import 'package:aranduapp/core/network/token_manager/model/refresh_token_response.dart';
import 'package:dio/dio.dart';
Expand Down Expand Up @@ -27,8 +27,7 @@ class AppInterceptors extends Interceptor {
try {
Log.i('Token expirado. Tentando atualizar o token...');

RefreshTokenResponse tokens =
await AuthService().refreshToken();
RefreshTokenResponse tokens = await AuthService().refreshToken();

final requestOptions = err.requestOptions;

Expand Down
2 changes: 1 addition & 1 deletion lib/core/network/base_api.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/core/network/app_interceptors.dart';

import 'package:dio/dio.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/core/network/token_manager/auth_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:aranduapp/core/data/local/StorageValue.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/data/local/storage_value.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/core/network/base_api.dart';
import 'package:aranduapp/core/network/token_manager/model/refresh_token_response.dart';
import 'package:dio/dio.dart';
Expand Down
5 changes: 2 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:aranduapp/config/ThemeApp.dart';
import 'package:aranduapp/ui/login/view/login_view.dart';
import 'package:aranduapp/ui/welcome/view/WelcomeView.dart';
import 'package:aranduapp/config/theme_app.dart';
import 'package:aranduapp/ui/welcome/view/welcome_view.dart';
import 'package:flutter/material.dart';

void main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:aranduapp/ui/edit_profile/model/EditProfileRequest.dart';
import 'package:aranduapp/ui/edit_profile/model/edit_profile_request.dart';
import 'package:dio/dio.dart';

class EditProfileService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:aranduapp/ui/shared/TextName.dart';
import 'package:aranduapp/ui/shared/text_name.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'package:aranduapp/ui/edit_profile/viewModel/EditProfileViewModel.dart';
import 'package:aranduapp/ui/shared/TextEmail.dart';
import 'package:aranduapp/ui/shared/TextPassword.dart';
import 'package:aranduapp/ui/edit_profile/view_model/edit_profile_view_model.dart';
import 'package:aranduapp/ui/shared/text_email.dart';
import 'package:aranduapp/ui/shared/text_password.dart';

class EditProfile extends StatelessWidget {
const EditProfile({super.key});
Expand All @@ -26,16 +26,14 @@ class EditProfileScreen extends StatefulWidget {
}

class _EditProfileScreenState extends State<EditProfileScreen> {

@override
Widget build(BuildContext context) {
final viewModel = Provider.of<EditProfileViewModel>(context);
return Scaffold(
appBar: AppBar(
title: const Text('Editar Perfil'),
),
body: _buildForm(viewModel)
);
appBar: AppBar(
title: const Text('Editar Perfil'),
),
body: _buildForm(viewModel));
}

Widget _buildForm(EditProfileViewModel viewModel) {
Expand All @@ -46,22 +44,17 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [

TextName(
controller: viewModel.firstNameController,
padding: const EdgeInsets.symmetric(vertical: 16)
),

controller: viewModel.firstNameController,
padding: const EdgeInsets.symmetric(vertical: 16)),
TextEmail(
padding: const EdgeInsets.symmetric(vertical: 16),
controller: viewModel.emailController,
),

TextPassWord(
padding: const EdgeInsets.symmetric(vertical: 16),
controller: viewModel.passwordController,
),

const SizedBox(height: 32),
_saveButton(viewModel),
const SizedBox(height: 16),
Expand All @@ -87,13 +80,11 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
);
}
},

child: Consumer<EditProfileViewModel>(
builder: (context, value, child) => value.isLoading
? const CircularProgressIndicator(value: null)
: const Text('Salvar'),
),

);
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:aranduapp/core/data/local/StorageValue.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/data/local/storage_value.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/core/network/base_api.dart';
import 'package:aranduapp/core/network/token_manager/auth_service.dart';
import 'package:aranduapp/ui/login/model/LoginRequest.dart';
import 'package:aranduapp/ui/login/model/LoginResponse.dart';
import 'package:aranduapp/ui/login/model/login_request.dart';
import 'package:aranduapp/ui/login/model/login_response.dart';
import 'package:dio/dio.dart';

class LoginService {
Expand Down
16 changes: 8 additions & 8 deletions lib/ui/login/view/login_view.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/ui/shared/TextAndLink.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/ui/shared/text_and_link.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:aranduapp/ui/login/viewModel/login_view_model.dart';
import 'package:aranduapp/ui/login/view_model/login_view_model.dart';

import 'package:aranduapp/ui/recover_account/view/recover_account_view.dart';
import 'package:aranduapp/ui/register_account/view/register_account_view.dart';

import 'package:aranduapp/ui/shared/TitleSlogan.dart';
import 'package:aranduapp/ui/shared/TextEmail.dart';
import 'package:aranduapp/ui/shared/ErrorPopUp.dart';
import 'package:aranduapp/ui/shared/TextPassword.dart';
import 'package:aranduapp/ui/shared/OrDivider.dart';
import 'package:aranduapp/ui/shared/title_slogan.dart';
import 'package:aranduapp/ui/shared/text_email.dart';
import 'package:aranduapp/ui/shared/error_pop_up.dart';
import 'package:aranduapp/ui/shared/text_password.dart';
import 'package:aranduapp/ui/shared/or_divider.dart';

class Login extends StatelessWidget {
const Login({super.key});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/ui/navbar/view/navBarView.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/ui/navbar/view/nav_bar_view.dart';
import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';
import 'package:aranduapp/ui/login/service/LoginService.dart';
import 'package:aranduapp/ui/login/model/LoginRequest.dart';
import 'package:aranduapp/ui/login/service/login_service.dart';
import 'package:aranduapp/ui/login/model/login_request.dart';

class LoginViewModel extends ChangeNotifier {
final BuildContext context;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:aranduapp/ui/home/view/HomeView.dart';
import 'package:aranduapp/ui/home/view/home_view.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:aranduapp/ui/navbar/model/navBarViewModel.dart';
import 'package:aranduapp/ui/navbar/model/nav_bar_view_model.dart';

class NavbarView extends StatelessWidget {
const NavbarView({super.key});
Expand Down Expand Up @@ -34,7 +34,7 @@ Widget page(BuildContext context) {
currentIndex: viewModel.selectedIndex,
onTap: viewModel.changeTab,
selectedItemColor: Theme.of(context).colorScheme.primary,
unselectedItemColor:Theme.of(context).colorScheme.onSurface,
unselectedItemColor: Theme.of(context).colorScheme.onSurface,
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home_outlined),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/onboarding/view/onboarding_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../viewModel/onboarding_view_model.dart';
import '../view_model/onboarding_view_model.dart';

class OnboardingView extends StatelessWidget {
const OnboardingView({super.key});
Expand Down
File renamed without changes.
17 changes: 0 additions & 17 deletions lib/ui/recover_account/service/RecoverAccountService.dart

This file was deleted.

12 changes: 12 additions & 0 deletions lib/ui/recover_account/service/recover_account_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:aranduapp/core/network/base_api.dart';
import 'package:aranduapp/ui/recover_account/model/recover_account_request.dart';

class RecoverAccountService {
static Future<void> forgetPassword(
RecoverAccountRequest recoverAccountRequest) async {
await BaseApi.getInstance(auth: false)
.post(path: '/auth/forgot-password', data: <String, dynamic>{
'email': recoverAccountRequest.email,
});
}
}
13 changes: 6 additions & 7 deletions lib/ui/recover_account/view/recover_account_view.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/ui/recover_account/viewModel/recover_account_view_model.dart';
import 'package:aranduapp/ui/shared/ErrorPopUp.dart';
import 'package:aranduapp/ui/shared/TextAndLink.dart';
import 'package:aranduapp/ui/shared/TextEmail.dart';
import 'package:aranduapp/ui/shared/TitleSlogan.dart';
import 'package:aranduapp/ui/shared/requestbutton.dart';
import 'package:aranduapp/ui/recover_account/view_model/recover_account_view_model.dart';
import 'package:aranduapp/ui/shared/error_pop_up.dart';
import 'package:aranduapp/ui/shared/text_and_link.dart';
import 'package:aranduapp/ui/shared/text_email.dart';
import 'package:aranduapp/ui/shared/title_slogan.dart';
import 'package:aranduapp/ui/shared/request_button.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/state/command.dart';
import 'package:aranduapp/ui/recover_account/model/RecoverAccountRequest.dart';
import 'package:aranduapp/ui/recover_account/service/RecoverAccountService.dart';
import 'package:aranduapp/ui/recover_account/model/recover_account_request.dart';
import 'package:aranduapp/ui/recover_account/service/recover_account_service.dart';
import 'package:async/async.dart';
import 'package:flutter/material.dart';

Expand Down
19 changes: 9 additions & 10 deletions lib/ui/register_account/view/register_account_view.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import 'package:aranduapp/ui/login/view/login_view.dart';
import 'package:aranduapp/ui/shared/OrDivider.dart';
import 'package:aranduapp/ui/shared/TextAndLink.dart';
import 'package:aranduapp/ui/shared/TextName.dart';
import 'package:aranduapp/ui/shared/or_divider.dart';
import 'package:aranduapp/ui/shared/text_and_link.dart';
import 'package:aranduapp/ui/shared/text_name.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/log/log.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:aranduapp/ui/register_account/viewModel/register_view_model.dart';
import 'package:aranduapp/ui/register_account/view_model/register_view_model.dart';

import 'package:aranduapp/ui/shared/TitleSlogan.dart';
import 'package:aranduapp/ui/shared/TextEmail.dart';
import 'package:aranduapp/ui/shared/ErrorPopUp.dart';
import 'package:aranduapp/ui/shared/TextPassword.dart';
import 'package:aranduapp/ui/shared/title_slogan.dart';
import 'package:aranduapp/ui/shared/text_email.dart';
import 'package:aranduapp/ui/shared/error_pop_up.dart';
import 'package:aranduapp/ui/shared/text_password.dart';

class RegisterAccount extends StatelessWidget {
const RegisterAccount({super.key});
Expand Down
15 changes: 4 additions & 11 deletions lib/ui/shared/ErrorPopUp.dart → lib/ui/shared/error_pop_up.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import 'package:flutter/material.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:aranduapp/core/log/log.dart';

class ErrorPopUp extends StatelessWidget {

final Widget content;

const ErrorPopUp({super.key, required this.content});

@override
Widget build(BuildContext context) {
return AlertDialog (
title: Align(

return AlertDialog(
title: Align(
alignment: Alignment.centerLeft,

child: Icon(
Icons.error,
size: 40,
Expand All @@ -23,11 +20,7 @@ class ErrorPopUp extends StatelessWidget {
content: content,
actions: <Widget>[
TextButton(

onPressed: () => {
Log.d('tap'),
Navigator.pop(context, 'OK')
},
onPressed: () => {Log.d('tap'), Navigator.pop(context, 'OK')},
child: const Text('OK'),
),
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:aranduapp/ui/shared/ErrorPopUp.dart';
import 'package:aranduapp/ui/shared/error_pop_up.dart';

void main() {
testWidgets('Testa ErrorPopUp', (WidgetTester tester) async {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:aranduapp/ui/shared/TextEmail.dart';
import 'package:aranduapp/ui/shared/text_email.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down Expand Up @@ -29,9 +29,12 @@ void main() {

// Teste de validação para diferentes casos
await testEmail("", "E-mail Obrigatório."); // Campo vazio
await testEmail("joaozinhi", "Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem '@'
await testEmail("joaozinhi@", "Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem domínio
await testEmail("joao@domain", "Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem extensão
await testEmail("joaozinhi",
"Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem '@'
await testEmail("joaozinhi@",
"Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem domínio
await testEmail("joao@domain",
"Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem extensão
await testEmail("[email protected]", null); // Entrada válida
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:aranduapp/ui/shared/TextName.dart';
import 'package:aranduapp/ui/shared/text_name.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down Expand Up @@ -27,8 +27,10 @@ void main() {

// Teste de validação para diferentes casos de nome
await testName("", 'Nome Obrigatório.'); // Campo vazio
await testName(" a", 'Opa, seu Nome está pequeno!\nacrescente mais caracteres. (Ex: Ana)'); // Nome com menos de 3 caracteres
await testName("Jo", 'Opa, seu Nome está pequeno!\nacrescente mais um caractere. (Ex: Ana)'); // Nome com 2 caracteres
await testName(" a",
'Opa, seu Nome está pequeno!\nacrescente mais caracteres. (Ex: Ana)'); // Nome com menos de 3 caracteres
await testName("Jo",
'Opa, seu Nome está pequeno!\nacrescente mais um caractere. (Ex: Ana)'); // Nome com 2 caracteres
await testName("João", null); // Nome válido
await testName("Maria", null); // Outro nome válido
});
Expand Down
Loading

0 comments on commit 39bab3e

Please sign in to comment.