Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat#59/profile hearder #51

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:aranduapp/config/ThemeApp.dart';
import 'package:aranduapp/ui/login/view/LoginView.dart';
import 'package:aranduapp/ui/navbar/view/navBarView.dart';
import 'package:aranduapp/ui/profile/view/ProfileView.dart';
import 'package:aranduapp/ui/welcome/view/WelcomeView.dart';
import 'package:flutter/material.dart';

Expand Down
146 changes: 99 additions & 47 deletions lib/ui/edit_profile/view/EditProfileView.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:aranduapp/ui/shared/TextName.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/ProfileHeader.dart';
import 'package:aranduapp/ui/shared/TextName.dart';
import 'package:aranduapp/ui/shared/TextPassword.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class EditProfile extends StatelessWidget {
const EditProfile({super.key});
Expand All @@ -18,61 +18,109 @@ class EditProfile extends StatelessWidget {
}
}

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

@override
State<EditProfileScreen> createState() => _EditProfileScreenState();
}

class _EditProfileScreenState extends State<EditProfileScreen> {
class EditProfileScreen extends StatelessWidget {
const EditProfileScreen({super.key});

@override
Widget build(BuildContext context) {
final viewModel = Provider.of<EditProfileViewModel>(context);
return Scaffold(
appBar: AppBar(
title: const Text('Editar Perfil'),
backgroundColor: Theme.of(context).colorScheme.surface,
elevation: 0,
title: Center(
child: Text(
'Editar perfil',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 24,
),
),
),
actions: [
IconButton(
color: Theme.of(context).colorScheme.primary,
icon: const Icon(Icons.notifications),
onPressed: () {},
),
],
leading: IconButton(
color: Theme.of(context).colorScheme.primary,
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
),
),
body: LayoutBuilder(
builder: (context, constraints) {
final isSmallScreen = constraints.maxWidth < 600;
return SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Column(
children: [
_buildProfileHeader(context),
SizedBox(height: isSmallScreen ? 30 : 50),
_buildForm(context, viewModel, isSmallScreen),
],
),
);
},
),
body: _buildForm(viewModel)
);
}

Widget _buildForm(EditProfileViewModel viewModel) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Form(
key: viewModel.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [

TextName(
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),
_deleteButton(context),
],
),
Widget _buildForm(BuildContext context, EditProfileViewModel viewModel,
bool isSmallScreen) {
return Form(
key: viewModel.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextName(
controller: viewModel.firstNameController,
padding: const EdgeInsets.symmetric(vertical: 0),
),
const SizedBox(height: 20),
TextEmail(
padding: const EdgeInsets.symmetric(vertical: 0),
controller: viewModel.emailController,
),
const SizedBox(height: 20),
TextPassWord(
padding: const EdgeInsets.symmetric(vertical: 0),
controller: viewModel.passwordController,
),
SizedBox(height: isSmallScreen ? 100 : 56),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: _saveButton(context, viewModel),
),
SizedBox(width: isSmallScreen ? 10 : 20),
Expanded(
child: _deleteButton(context),
),
],
),
],
),
);
}

Widget _saveButton(EditProfileViewModel viewModel) {
Widget _buildProfileHeader(BuildContext context) {
return const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ProfileHeader(
name: "Stefani",
role: "Estudante",
),
]);
}

Widget _saveButton(BuildContext context, EditProfileViewModel viewModel) {
return ElevatedButton(
onPressed: () async {
if (viewModel.isLoading) return;
Expand All @@ -87,19 +135,23 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
);
}
},

style: ElevatedButton.styleFrom(
minimumSize: Size(0, 50),
),
child: Consumer<EditProfileViewModel>(
builder: (context, value, child) => value.isLoading
? const CircularProgressIndicator(value: null)
: const Text('Salvar'),
),

);
}

Widget _deleteButton(BuildContext context) {
return ElevatedButton(
onPressed: () => _showDeleteConfirmationDialog(context),
style: ElevatedButton.styleFrom(
minimumSize: Size(0, 50),
),
child: const Text('Deletar Conta'),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/ui/edit_profile/viewModel/EditProfileViewModel.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:aranduapp/core/log/Log.dart';
import 'package:flutter/material.dart';

class EditProfileViewModel extends ChangeNotifier {
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/navbar/view/navBarView.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:aranduapp/ui/home/view/HomeView.dart';
import 'package:aranduapp/ui/profile/view/ProfileView.dart';
//import 'package:aranduapp/ui/profile/view/profileView.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:aranduapp/ui/navbar/model/navBarViewModel.dart';
Expand All @@ -25,7 +27,7 @@ Widget page(BuildContext context) {
const HomeView(),
const Center(child: Text('Friends', style: TextStyle(fontSize: 20))),
const Center(child: Text('Dashbord', style: TextStyle(fontSize: 20))),
const Center(child: Text('Profile', style: TextStyle(fontSize: 20))),
const Profile(),
];

return Scaffold(
Expand All @@ -34,7 +36,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
Empty file removed lib/ui/profile/view/Profile.dart
Empty file.
115 changes: 115 additions & 0 deletions lib/ui/profile/view/ProfileView.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';

import 'package:aranduapp/ui/shared/ProfileHeader.dart';
import 'package:aranduapp/ui/profile/viewModel/ProfileViewModel.dart';
import 'package:aranduapp/ui/edit_profile/view/EditProfileView.dart';

class Profile extends StatelessWidget {
const Profile({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _buildAppBar(context),
body: ChangeNotifierProvider(
create: (context) => ProfileViewModel(context),
builder: (context, child) {
return _buildPage(context);
},
),
);
}

/// AppBar
AppBar _buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Theme.of(context).colorScheme.onPrimary,
scrolledUnderElevation: 0,
title: Text(
'Perfil',
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
),
centerTitle: true,
actions: [
Padding(
padding: const EdgeInsets.only(right: 16.0),
child: Container(
child: Center(
child: Icon(
Icons.notifications_none_outlined,
color: Theme.of(context).colorScheme.primary,
size: 32,
),
),
),
),
],
);
}

/// Página principal
Widget _buildPage(BuildContext context) {
return SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_buildProfileHeader(context),
const SizedBox(height: 80),
_buildLogoutButton(context),
],
),
),
);
}

/// Cabeçalho do Perfil
Widget _buildProfileHeader(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ProfileHeader(
name: "Stefani",
role: "Estudante",
),
Padding(
padding: const EdgeInsets.only(right: 16.0), // Margem direita
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const EditProfile()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
elevation: 2,
),
child: Text(
"Editar",
style: Theme.of(context).textTheme.bodySmall!.apply(
color: Theme.of(context).colorScheme.onPrimary,
),
),
),
),
],
);
}

/// Botão Deslogar
Widget _buildLogoutButton(BuildContext context) {
return SizedBox(
width: 291,
height: 64,
child: ElevatedButton(
onPressed: () => {},
child: const Text('Deslogar'),
),
);
}
}
Loading
Loading