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

Implementa register #34

Merged
merged 6 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
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';

void main() {
runApp(const MyApp());
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/onboarding/view/onboarding_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ class _OnboardingViewState extends State<OnboardingView> {
{
'title': 'Lorem',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remova esse lorem

'description':
'AranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduArandu',
'Seja bem vindo ao Arandu!!! Sou um ambiente voltado para aprendizado de forma gratuita',
'imageAsset': 'assets/images/Component1.png',
},
{
'title': 'Lorem',
'description':
'AranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduArandu',
'Aqui você encontrará livros interativos de diversas disciplinas com objetivo de entregar praticidade e qualidade no aprendizado.',
'imageAsset': 'assets/images/Component2.png',
},
{
'title': 'Lorem',
'description':
'AranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduAranduArandu',
'Para acessar uma trilha basta se inscrever na disciplina de sua preferência e ter acesso aos materiais. \n Bons estudos !!!',
'imageAsset': 'assets/images/Component3.png',
},
];
Expand Down
199 changes: 196 additions & 3 deletions lib/ui/register_account/view/RegisterAccount.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,205 @@
import 'package:aranduapp/ui/login/view/LoginView.dart';
import 'package:aranduapp/ui/shared/TextName.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:aranduapp/core/log/Log.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class RegisterAccount extends StatelessWidget{
import 'package:aranduapp/ui/register_account/viewModel/RegisterViewModel.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';


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

@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
return ChangeNotifierProvider(
create: (context) => RegisterAccountViewModel(),
child: const _RegisterAccount(),
);
}
}

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

@override
State<StatefulWidget> createState() {
return _RegisterAccountState();
}
}

class _RegisterAccountState extends State<_RegisterAccount> {

@override
Widget build(BuildContext context) {
RegisterAccountViewModel viewModel = Provider.of<RegisterAccountViewModel>(context);

return Scaffold(
body: Column(
children: [
// Cabeçalho com padrão de losangos
_buildHeader(viewModel),
// Corpo do formulário
_buildForm(viewModel),
],
),
);
}

Widget _buildHeader(RegisterAccountViewModel viewModel) {
return const Stack(
children: [
Expanded(
child: Center(
child: Padding(
padding: EdgeInsets.only(top: 25.0),
child: TitleSlogan(),
),
),
),
],
);
}


Widget _buildForm(RegisterAccountViewModel viewModel) {
return Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 10),
const Text(
'Olá,\nCrie uma conta',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 30),
TextName(controller: viewModel.firstNameController, padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 0)),
TextEmail(padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 0), controller: viewModel.emailController),
TextPassWord(padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 0), controller: viewModel.passwordController),
TextPassWord(padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 0), controller: viewModel.confPasswordController),
const SizedBox(height: 10),
_buildTermsCheckbox(context),
const SizedBox(height: 20),
_buildRegisterButton(context, viewModel),
const SizedBox(height: 20),
_buildDividerWithText(),
const SizedBox(height: 20),
_buildGoogleLoginButton(),
const SizedBox(height: 20),
_buildLoginRedirectButton(context),
],
),
),
),
);
}

Widget _buildTermsCheckbox(BuildContext context) {
final viewModel = Provider.of<RegisterAccountViewModel>(context);
return Row(
children: [
Checkbox(
value: viewModel.isTermsAccepted,
onChanged: (value) {
// Ação ao clicar no checkbox
if (value != null) {
viewModel.toggleTermsAccepted(value);
}
},
),
const Expanded(
child: Text(
'Para continuar, aceite os termos de privacidade e políticas de uso',
style: TextStyle(fontSize: 12),
),
),
],
);
}

Widget _buildRegisterButton(BuildContext context, RegisterAccountViewModel viewModel) {
return SizedBox(
width: 291,
height: 64,
child: ElevatedButton(
onPressed: () {
viewModel
.register()
.catchError((e) => showDialog<Object>(
context: context,
builder: (BuildContext context) =>
ErrorPopUp(content: Text('$e')),
));
// Ação ao clicar no botão de cadastro
},
child: Consumer<RegisterAccountViewModel>(
builder: (context, value, child) => value.isLoading
? const CircularProgressIndicator(value: null)
: const Text('Registrar'),
)),
);
}

Widget _buildDividerWithText() {
return const Row(
children: [
Expanded(child: Divider()),
Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Text('ou'),
),
Expanded(child: Divider()),
],
);
}

Widget _buildGoogleLoginButton() {
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,
),
),
);
}


Widget _buildLoginRedirectButton(BuildContext context) {
return TextButton(
onPressed: () {
// Navegar para a tela de login
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const Login(),
),
);
},
child: const Text(
'Já tem uma conta? faça login',
),
);
}
}
1 change: 1 addition & 0 deletions lib/ui/register_account/viewModel/RegisterViewModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class RegisterAccountViewModel extends ChangeNotifier {
final TextEditingController firstNameController = TextEditingController();
final TextEditingController lastNameController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
final TextEditingController confirmPasswordController = TextEditingController();
final TextEditingController confPasswordController = TextEditingController();
bool isLoading = false;
bool isTermsAccepted = false; // Adicionado
Expand Down
Loading