Skip to content

Commit

Permalink
Merge branch 'feat#59/Tela-de-EditProfile' of https://github.com/fga-…
Browse files Browse the repository at this point in the history
…eps-mds/2024.2-ARANDU-APP into feat#59/Tela-de-EditProfile
  • Loading branch information
zDrNz committed Dec 7, 2024
2 parents 537e92a + 4edf644 commit fda0bdf
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 141 deletions.
9 changes: 5 additions & 4 deletions lib/config/ThemeApp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ThemeApp {

static themeData(){
return FlexThemeData.light(
scheme: FlexScheme.redWine,
scheme: FlexScheme.amber,
surfaceMode: FlexSurfaceMode.levelSurfacesLowScaffold,
blendLevel: 7,
subThemesData: const FlexSubThemesData(
Expand All @@ -30,7 +30,8 @@ class ThemeApp {
visualDensity: FlexColorScheme.comfortablePlatformDensity,
useMaterial3: true,
swapLegacyOnMaterial3: true,
fontFamily: GoogleFonts.notoSans().fontFamily,
fontFamily: GoogleFonts.comfortaa().fontFamily,


textTheme: textTheme,

Expand All @@ -44,7 +45,7 @@ class ThemeApp {

static darkThemeData(){
return FlexThemeData.dark(
scheme: FlexScheme.redWine,
scheme: FlexScheme.mango,
surfaceMode: FlexSurfaceMode.levelSurfacesLowScaffold,
blendLevel: 13,
subThemesData: const FlexSubThemesData(
Expand All @@ -57,7 +58,7 @@ class ThemeApp {
visualDensity: FlexColorScheme.comfortablePlatformDensity,
useMaterial3: true,
swapLegacyOnMaterial3: true,
fontFamily: GoogleFonts.notoSans().fontFamily,
fontFamily: GoogleFonts.comfortaa().fontFamily,


textTheme: textTheme,
Expand Down
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:aranduapp/config/ThemeApp.dart';
import 'package:aranduapp/ui/welcome/view/WelcomeView.dart';
import 'package:flutter/material.dart';
import 'package:aranduapp/ui/login/view/LoginView.dart';
import 'package:aranduapp/ui/edit_profile/view/EditProfileView.dart';
Expand All @@ -16,7 +17,7 @@ class MyApp extends StatelessWidget {
theme: ThemeApp.themeData(),
darkTheme: ThemeApp.darkThemeData(),
debugShowCheckedModeBanner: false,
home: EditProfile(),
home: WelcomeView(),
);
}
}
59 changes: 7 additions & 52 deletions lib/ui/edit_profile/view/EditProfileView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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';

class EditProfile extends StatelessWidget {
Expand All @@ -31,45 +30,10 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
Widget build(BuildContext context) {
final viewModel = Provider.of<EditProfileViewModel>(context);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent, // Define o fundo transparente
elevation: 0, // Remove a sombra da AppBar
title: Center(
child: Text(
style: TextStyle(
color: Colors.black, // Muda a cor do texto
fontSize: 24, // Ajusta o tamanho (opcional)
),
'Editar perfil',
),
appBar: AppBar(
title: const Text('Editar Perfil'),
),
actions: [
IconButton(
color: Colors.black,
icon: Icon(Icons.notifications), // Ícone de notificação
onPressed: () {
// Ação quando o ícone de notificação for pressionado
},
),
],
leading: IconButton(
color: Colors.black,
icon: Icon(Icons.arrow_back),
onPressed: () {},
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center, // Centraliza verticalmente
crossAxisAlignment:
CrossAxisAlignment.center, // Centraliza horizontalmente
children: [
_icon(context),
SizedBox(height: 50),
_buildForm(viewModel),
],
)),
);
body: _buildForm(viewModel));
}

Widget _buildForm(EditProfileViewModel viewModel) {
Expand All @@ -83,24 +47,18 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
TextName(
controller: viewModel.firstNameController,
padding: const EdgeInsets.symmetric(vertical: 16)),
SizedBox(height: 20),
TextEmail(
padding: const EdgeInsets.symmetric(vertical: 16),
controller: viewModel.emailController,
),
SizedBox(height: 20),
TextPassWord(
padding: const EdgeInsets.symmetric(vertical: 16),
controller: viewModel.passwordController,
),
SizedBox(height: 56),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_saveButton(viewModel),
_deleteButton(context),
],
),
const SizedBox(height: 32),
_saveButton(viewModel),
const SizedBox(height: 16),
_deleteButton(context),
],
),
),
Expand All @@ -122,9 +80,6 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
);
}
},
style: ElevatedButton.styleFrom(
minimumSize: Size(150, 50), // Largura: 200, Altura: 50
),
child: Consumer<EditProfileViewModel>(
builder: (context, value, child) => value.isLoading
? const CircularProgressIndicator(value: null)
Expand Down
62 changes: 55 additions & 7 deletions lib/ui/login/view/LoginView.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:aranduapp/core/log/Log.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/LoginViewModel.dart';

Expand All @@ -24,7 +26,7 @@ class Login extends StatelessWidget {
}

class _Login extends StatefulWidget {
const _Login({Key? key}) : super(key: key);
const _Login({super.key});

@override
State<StatefulWidget> createState() {
Expand Down Expand Up @@ -120,9 +122,11 @@ class _LoginState extends State<_Login> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
_loginButtonSection(context, viewModel),
_createAccountLink(context)
_orDivider(),
_loggingInWithOther(),
_createAccountLink(context),
],
))
)),
],
),
),
Expand Down Expand Up @@ -157,12 +161,12 @@ class _LoginState extends State<_Login> {
);
},
child: Align(
alignment: Alignment.centerRight,
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.only(top: 13, right: 20),
padding: const EdgeInsets.only(top: 10),
child: Text(
'esqueceu a senha ?',
textAlign: TextAlign.right,
'esqueceu sua senha ?',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodySmall!.apply(
color: Theme.of(context).colorScheme.primary,
),
Expand Down Expand Up @@ -225,4 +229,48 @@ class _LoginState extends State<_Login> {
),
);
}

Widget _orDivider() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Row(
children: <Widget>[
const Expanded(child: Divider()),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
'ou',
style: Theme.of(context).textTheme.bodyMedium!.apply(
color: Theme.of(context).colorScheme.primary,
),
),
),
const Expanded(child: Divider()),
],
),
);
}



Widget _loggingInWithOther(){

return GestureDetector(
onTap: () => Log.d(""),
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Theme.of(context).colorScheme.outline),
color: Colors.transparent,
),
child: Icon(
FontAwesomeIcons.google,
size: 20,
color: Theme.of(context).colorScheme.primary,
),
),
);
}
}
34 changes: 34 additions & 0 deletions lib/ui/register_account/model/RegisterRequest.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'dart:convert';
class RegisterRequest {
final String email;
final String firstName;
final String lastName;
final String password;
final String confPassword;
RegisterRequest({
required this.email,
required this.firstName,
required this.lastName,
required this.password,
required this.confPassword,
});
Map<String, dynamic> toJson() {
return {
'email': email,
'firstName': firstName,
'lastName': lastName,
'password': password,
'confPassword': confPassword,
};
}
factory RegisterRequest.fromJsonString(String jsonString) {
final json = jsonDecode(jsonString);
return RegisterRequest(
email: json['email'],
firstName: json['firstName'],
lastName: json['lastName'],
password: json['password'],
confPassword: json['confPassword'],
);
}
}
16 changes: 16 additions & 0 deletions lib/ui/register_account/model/RegisterResponse.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'dart:convert';
class RegisterResponse {
final String authToken;
final String refreshToken;
RegisterResponse({
required this.authToken,
required this.refreshToken,
});
factory RegisterResponse.fromJsonString(String jsonString) {
final json = jsonDecode(jsonString);
return RegisterResponse(
authToken: json['auth_token'],
refreshToken: json['refresh_token'],
);
}
}
14 changes: 14 additions & 0 deletions lib/ui/register_account/service/RegisterService.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:dio/dio.dart';
import '../model/RegisterRequest.dart';
class RegisterService {
static final Dio _dio = Dio();
static Future<void> register(RegisterRequest request) async {
final response = await _dio.post(
'https://example.com/register',
data: request.toJson(),
);
if (response.statusCode != 200) {
throw Exception('Erro ao criar conta: ${response.data['message']}');
}
}
}
46 changes: 46 additions & 0 deletions lib/ui/register_account/viewModel/RegisterViewModel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import '../model/RegisterRequest.dart';
import '../service/RegisterService.dart';
class RegisterAccountViewModel extends ChangeNotifier {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final TextEditingController emailController = TextEditingController();
final TextEditingController firstNameController = TextEditingController();
final TextEditingController lastNameController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
final TextEditingController confPasswordController = TextEditingController();
bool isLoading = false;
bool isTermsAccepted = false; // Adicionado
// Método para alternar a aceitação dos termos
void toggleTermsAccepted(bool value) {
isTermsAccepted = value;
notifyListeners();
}
Future<void> register() async {
if (isLoading) return;
// Valida se os termos foram aceitos
if (!isTermsAccepted) {
throw Exception('Você deve aceitar os termos de privacidade e políticas de uso.');
}
try {
isLoading = true;
notifyListeners();
// Valida os campos do formulário
if (!formKey.currentState!.validate()) {
throw Exception('Por favor, preencha todos os campos corretamente');
}
// Criação do objeto de requisição
final request = RegisterRequest(
email: emailController.text,
firstName: firstNameController.text,
lastName: lastNameController.text,
password: passwordController.text,
confPassword: confPasswordController.text,
);
// Chamada do serviço de registro
await RegisterService.register(request);
} finally {
isLoading = false;
notifyListeners();
}
}
}
Loading

0 comments on commit fda0bdf

Please sign in to comment.