This commit is contained in:
Felipe
2024-03-11 09:24:29 -05:00
parent a71fc9efb6
commit 13896f2b6d
10 changed files with 290 additions and 451 deletions
+13 -1
View File
@@ -52,7 +52,19 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
AuthEventAddEmailAndPassword event, Emitter<AuthState> emit) async { AuthEventAddEmailAndPassword event, Emitter<AuthState> emit) async {
emit(AuthStateProcess()); emit(AuthStateProcess());
try { try {
await _userRepository.addEmailAndPassword(event.email, event.password); final String? error = await _userRepository.addEmailAndPassword(
event.email, event.password);
if (error == null) {
emit(AuthStateSuccess());
} else {
if (error == 'requires-recent-login') {
emit(AuthStateRequiresRecentLogin());
} else if (error == 'email-already-in-use') {
emit(AuthStateEmailAlreadyInUse());
} else {
emit(const AuthStateFailure());
}
}
} catch (e) { } catch (e) {
emit(const AuthStateFailure()); emit(const AuthStateFailure());
} }
+4
View File
@@ -19,6 +19,10 @@ class AuthStateVerifyOAuth extends AuthState {
class AuthStateSuccess extends AuthState {} class AuthStateSuccess extends AuthState {}
class AuthStateRequiresRecentLogin extends AuthState {}
class AuthStateEmailAlreadyInUse extends AuthState {}
class AuthStateFailure extends AuthState { class AuthStateFailure extends AuthState {
final String? message; final String? message;
+3 -3
View File
@@ -18,10 +18,10 @@ class GeneralPrimaryButton extends StatelessWidget {
onPressed: isEnabled ? onPressed : null, onPressed: isEnabled ? onPressed : null,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary, backgroundColor: Theme.of(context).colorScheme.primary,
elevation: 0, elevation: 5,
minimumSize: Size( minimumSize: Size(
MediaQuery.of(context).size.width * 0.5, MediaQuery.of(context).size.width * 0.5,
50, 55,
), ),
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(50)), borderRadius: BorderRadius.all(Radius.circular(50)),
@@ -32,7 +32,7 @@ class GeneralPrimaryButton extends StatelessWidget {
style: TextStyle( style: TextStyle(
color: isEnabled ? Colors.white : Colors.black, color: isEnabled ? Colors.white : Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 18,
), ),
), ),
); );
+43 -64
View File
@@ -1,10 +1,9 @@
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_otp_text_field/flutter_otp_text_field.dart'; import 'package:flutter_otp_text_field/flutter_otp_text_field.dart';
import 'package:injector/injector.dart'; import 'package:injector/injector.dart';
import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart'; import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart';
import 'package:prosappco/components/general_primary_button.dart';
class OtpAuthScreen extends StatefulWidget { class OtpAuthScreen extends StatefulWidget {
final String phoneNumber; final String phoneNumber;
@@ -16,87 +15,67 @@ class OtpAuthScreen extends StatefulWidget {
} }
class _OtpAuthScreenState extends State<OtpAuthScreen> { class _OtpAuthScreenState extends State<OtpAuthScreen> {
bool _isRequestSent = false; late final AuthBloc authBloc;
@override
void initState() {
super.initState();
authBloc = Injector.appInstance.get<AuthBloc>();
authBloc.add(AuthEventLoginOAuth(phone: widget.phoneNumber));
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final authBloc = Injector.appInstance.get<AuthBloc>();
if (!_isRequestSent) {
authBloc.add(AuthEventLoginOAuth(phone: widget.phoneNumber));
_isRequestSent = true;
}
return BlocProvider<AuthBloc>( return BlocProvider<AuthBloc>(
create: (context) => authBloc, create: (context) => authBloc,
child: BlocConsumer<AuthBloc, AuthState>( child: BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) { listener: (context, state) {
if (state is AuthStateSuccess) { if (state is AuthStateSuccess) {
Navigator.of(context).pop(); Navigator.of(context).pop();
} } else if (state is AuthStateVerifyOAuth && state.isWrongCode) {
if (state is AuthStateVerifyOAuth) {
if (state.isWrongCode) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('El Código es incorrecto'), content: Text('El Código es incorrecto'),
)); ));
} }
}
}, },
builder: (context, state) { builder: (context, state) {
return Scaffold( return Scaffold(
body: Column(children: [ appBar: AppBar(
getContent(state, authBloc: authBloc), title: const Text('Verificación de código'),
]), ),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * 0.1),
const Text('Te enviaremos un Código de verificación a'),
Text(
widget.phoneNumber,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 20),
OtpTextField(
numberOfFields: 6,
borderColor: const Color(0xFF512DA8),
showFieldAsBox: true,
onCodeChanged: (String code) {},
onSubmit: (String verificationCode) {
authBloc.add(AuthEventVerifyOAuth(code: verificationCode));
},
),
Expanded(child: Container()),
GeneralPrimaryButton(
onPressed: () {},
label: 'Continuar',
),
const SizedBox(height: 20),
],
),
); );
}, },
), ),
); );
} }
Widget getContent(AuthState state, {required AuthBloc authBloc}) {
if (state is AuthStateInitial) {
return const Text('Inicio');
} else if (state is AuthStateProcess) {
return Center(
child: Column(
children: [
Text('${widget.phoneNumber} - $_isRequestSent'),
OtpTextField(
numberOfFields: 6,
borderColor: const Color(0xFF512DA8),
showFieldAsBox: true,
onCodeChanged: (String code) {},
onSubmit: (String verificationCode) {
authBloc.add(AuthEventVerifyOAuth(code: verificationCode));
}, // end onSubmit
),
],
),
);
} else if (state is AuthStateVerifyOAuth) {
return Center(
child: Column(
children: [
Text('${widget.phoneNumber} - $_isRequestSent'),
state.isWrongCode ? const Text('') : const Text(''),
OtpTextField(
numberOfFields: 6,
borderColor: const Color(0xFF512DA8),
showFieldAsBox: true,
onCodeChanged: (String code) {},
onSubmit: (String verificationCode) {
authBloc.add(AuthEventVerifyOAuth(code: verificationCode));
}, // end onSubmit
),
],
),
);
} else if (state is AuthStateSuccess) {
return const CircularProgressIndicator();
} else if (state is AuthStateFailure) {
return const Text('');
} else {
return const CircularProgressIndicator();
}
}
} }
@@ -246,7 +246,7 @@ class _SignUpScreenState extends State<SignUpScreen> {
return 'Name too long'; return 'Name too long';
} }
return null; return null;
}), },),
), ),
SizedBox(height: MediaQuery.of(context).size.height * 0.02), SizedBox(height: MediaQuery.of(context).size.height * 0.02),
!signUpRequired !signUpRequired
@@ -27,7 +27,7 @@ class ProfileItem extends StatelessWidget {
title, title,
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
), ),
subtitle: subtitle == null subtitle: subtitle == null || subtitle!.isEmpty
? null ? null
: Text( : Text(
subtitle ?? '', subtitle ?? '',
+73 -26
View File
@@ -1,6 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injector/injector.dart';
import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart';
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart'; import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
import 'package:prosappco/components/general_primary_button.dart';
import 'package:prosappco/screens/authentication/sign_in_screen.dart';
class ProfileEmailScreen extends StatefulWidget { class ProfileEmailScreen extends StatefulWidget {
const ProfileEmailScreen({super.key}); const ProfileEmailScreen({super.key});
@@ -13,6 +17,14 @@ class _ProfileEmailScreenState extends State<ProfileEmailScreen> {
final TextEditingController _emailController = TextEditingController(); final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController(); final TextEditingController _passwordController = TextEditingController();
late final AuthBloc authBloc;
@override
void initState() {
super.initState();
authBloc = Injector.appInstance.get<AuthBloc>();
}
@override @override
void dispose() { void dispose() {
_emailController.dispose(); _emailController.dispose();
@@ -20,9 +32,46 @@ class _ProfileEmailScreenState extends State<ProfileEmailScreen> {
super.dispose(); super.dispose();
} }
void _showLoginModal(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Requiere inicio de sesión reciente'),
content: const Text('Por favor, inicie sesión nuevamente para continuar.'),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('OK'),
),
],
);
},
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<MyUserBloc, MyUserState>( return BlocProvider<AuthBloc>(
create: (context) => authBloc,
child: BlocListener<AuthBloc, AuthState>(
listener: (context, state) {
if (state is AuthStateSuccess) {
Navigator.of(context).pop();
}
if (state is AuthStateEmailAlreadyInUse) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('El correo ya existe'),
));
}
if (state is AuthStateRequiresRecentLogin) {
_showLoginModal(context);
}
},
child: BlocBuilder<MyUserBloc, MyUserState>(
builder: (context, state) { builder: (context, state) {
if (state.status == MyUserStatus.success) { if (state.status == MyUserStatus.success) {
_emailController.text = state.user!.email ?? ''; _emailController.text = state.user!.email ?? '';
@@ -39,8 +88,8 @@ class _ProfileEmailScreenState extends State<ProfileEmailScreen> {
// Centro del contenido // Centro del contenido
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: padding: const EdgeInsets.symmetric(
const EdgeInsets.symmetric(horizontal: 40, vertical: 10), horizontal: 40, vertical: 10),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
@@ -97,30 +146,26 @@ class _ProfileEmailScreenState extends State<ProfileEmailScreen> {
}, },
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
ElevatedButton( GeneralPrimaryButton(
onPressed: () {}, onPressed: () {
style: ElevatedButton.styleFrom( if (_emailController.text.isEmpty) {
backgroundColor: Colors.blue, return;
padding: const EdgeInsets.symmetric(vertical: 5), }
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), if (_passwordController.text.isEmpty) {
), return;
shadowColor: Colors.grey, }
elevation: 5,
), context.read<AuthBloc>().add(
child: Container( AuthEventAddEmailAndPassword(
constraints: const BoxConstraints( email: _emailController.text,
maxWidth: 300.0, minHeight: 50.0), password: _passwordController.text,
alignment: Alignment.center,
child: const Text(
'Actualizar',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
), ),
);
},
label: _emailController.text.isEmpty
? 'Registrar'
: 'Actualizar',
), ),
], ],
), ),
@@ -132,6 +177,8 @@ class _ProfileEmailScreenState extends State<ProfileEmailScreen> {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
}, },
),
),
); );
} }
} }
+55 -251
View File
@@ -33,9 +33,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
XFile? _imageFile; XFile? _imageFile;
bool isLoading = false; bool isLoading = false;
bool enableLoginWithEmail = false; late final AuthBloc authBloc;
bool obscurePassword = true;
IconData iconPassword = CupertinoIcons.eye_fill; @override
void initState() {
super.initState();
authBloc = Injector.appInstance.get<AuthBloc>();
}
@override @override
void dispose() { void dispose() {
@@ -52,8 +56,6 @@ class _ProfileScreenState extends State<ProfileScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final authBloc = Injector.appInstance.get<AuthBloc>();
return BlocProvider<AuthBloc>( return BlocProvider<AuthBloc>(
create: (context) => authBloc, create: (context) => authBloc,
child: BlocListener<ProfileBloc, ProfileState>( child: BlocListener<ProfileBloc, ProfileState>(
@@ -125,12 +127,42 @@ class _ProfileScreenState extends State<ProfileScreen> {
return null; return null;
}, },
), ),
_birthdayController.text.isEmpty &&
_genderController.text.isEmpty
? Column(
children: [
const SizedBox(height: 20.0),
BirthdayPicker(
onDateSelected: (birthDay) {
_birthdayController.text =
DateFormat('dd/MM/yyyy')
.format(birthDay);
},
controller: _birthdayController,
),
const SizedBox(height: 20.0),
GenderDropdown(
controller: _genderController,
),
],
)
: const SizedBox(),
const SizedBox(height: 20), const SizedBox(height: 20),
ProfileItem( ProfileItem(
title: 'Iniciar sesión con correo', title: 'Iniciar sesión con correo',
subtitle: _emailController.text, subtitle: _emailController.text,
leading: Icons.email_rounded, leading: Icons.email_rounded,
onTap: () { onTap: () {
if (state.user!.name == null ||
state.user!.name == '') {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text('Por favor, ingrese su nombre'),
));
return;
}
Navigator.push( Navigator.push(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
@@ -155,234 +187,6 @@ class _ProfileScreenState extends State<ProfileScreen> {
); );
}, },
), ),
// Column(
// children: [
// const SizedBox(height: 20.0),
// TextFormField(
// readOnly: true,
// controller: _emailController,
// decoration: const InputDecoration(
// labelText: 'Email',
// prefixIcon: Icon(Icons.email_rounded),
// hintText: 'Email',
// border: OutlineInputBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(10.0),
// )),
// errorBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Colors.red),
// ),
// focusedErrorBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: Colors.red, width: 2.0),
// ),
// ),
// ),
// ],
// ),
// const SizedBox(height: 20.0),
// TextFormField(
// readOnly: true,
// controller: _phoneController,
// decoration: const InputDecoration(
// labelText: 'Número de Teléfono',
// prefixIcon: Icon(Icons.phone_android_rounded),
// hintText: '+57',
// border: OutlineInputBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(10.0),
// )),
// errorBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Colors.red),
// ),
// focusedErrorBorder: OutlineInputBorder(
// borderSide:
// BorderSide(color: Colors.red, width: 2.0),
// ),
// ),
// ),
// _emailController.text.isEmpty
// ? Column(
// children: [
// const SizedBox(height: 20.0),
// GeneralCheckbox(
// text:
// 'Habilitar inicio de sesión con correo (Opcional)',
// initialValue: enableLoginWithEmail,
// onChanged: (value) {
// setState(() {
// enableLoginWithEmail = value;
// });
// },
// ),
// enableLoginWithEmail
// ? Container(
// decoration: BoxDecoration(
// border: Border.all(
// color: Colors.blue,
// width: 0.5,
// ),
// borderRadius:
// BorderRadius.circular(10),
// ),
// padding: const EdgeInsets.all(10),
// child: Column(
// children: [
// TextFormField(
// controller:
// _newEmailController,
// validator: (String? value) {
// if (enableLoginWithEmail) {
// if (value == null ||
// value.isEmpty) {
// return 'Por favor ingrese un email';
// }
// final RegExp
// emailRegExp =
// RegExp(
// r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
// if (!emailRegExp
// .hasMatch(value)) {
// return 'Por favor ingrese un email válido';
// }
// return null;
// } else {
// return null;
// }
// },
// decoration:
// const InputDecoration(
// prefixIcon: Icon(
// Icons.email_rounded),
// hintText: 'Email',
// ),
// ),
// const SizedBox(height: 20.0),
// TextFormField(
// controller:
// _passwordController,
// obscureText:
// obscurePassword,
// validator: (value) {
// if (enableLoginWithEmail) {
// if (value == null ||
// value.isEmpty) {
// return 'Por favor ingrese una contraseña.';
// }
// if (value.length < 5) {
// return 'Debe tener al menos 5 caracteres.';
// }
// return null;
// } else {
// return null;
// }
// },
// decoration: InputDecoration(
// prefixIcon: const Icon(
// Icons.lock_rounded),
// suffixIcon: IconButton(
// onPressed: () {
// setState(() {
// obscurePassword =
// !obscurePassword;
// if (obscurePassword) {
// iconPassword =
// CupertinoIcons
// .eye_fill;
// } else {
// iconPassword =
// CupertinoIcons
// .eye_slash_fill;
// }
// });
// },
// icon: Icon(iconPassword,
// color: Colors
// .grey[600]),
// ),
// hintText: 'Contraseña',
// ),
// ),
// const SizedBox(height: 20),
// Container(
// margin:
// const EdgeInsets.only(
// left: 5,
// right: 5,
// top: 5,
// bottom: 5,
// ),
// padding: const EdgeInsets
// .symmetric(
// horizontal: 10,
// vertical: 8,
// ),
// decoration: BoxDecoration(
// color: const Color(
// 0xFFD6F4FF),
// borderRadius:
// BorderRadius.circular(
// 20),
// boxShadow: [
// BoxShadow(
// color: Colors.grey
// .withOpacity(0.5),
// spreadRadius: 1,
// blurRadius: 5,
// offset: const Offset(
// 1, 3),
// ),
// ],
// ),
// child: const Row(
// children: [
// Icon(
// Icons.error_outline,
// size: 20,
// color: Colors.black54,
// ),
// SizedBox(width: 10),
// Expanded(
// child: Text(
// 'Al habilitar el inicio de sesión con correo, se cerrara la sesión actual.',
// style: TextStyle(
// color: Colors
// .black54,
// fontSize: 13,
// ),
// ),
// ),
// ],
// ),
// )
// ],
// ),
// )
// : const SizedBox(),
// ],
// )
// : const SizedBox(),
_birthdayController.text.isEmpty &&
_genderController.text.isEmpty
? Column(
children: [
const SizedBox(height: 20.0),
BirthdayPicker(
onDateSelected: (birthDay) {
_birthdayController.text =
DateFormat('dd/MM/yyyy')
.format(birthDay);
},
controller: _birthdayController,
),
const SizedBox(height: 20.0),
GenderDropdown(
controller: _genderController,
),
],
)
: const SizedBox(),
const SizedBox(height: 60.0), const SizedBox(height: 60.0),
saveButton(state, context), saveButton(state, context),
], ],
@@ -406,24 +210,24 @@ class _ProfileScreenState extends State<ProfileScreen> {
return; return;
} }
if (enableLoginWithEmail) { // if (enableLoginWithEmail) {
if (_newEmailController.text.isEmpty) { // if (_newEmailController.text.isEmpty) {
return; // return;
} // }
if (_passwordController.text.isEmpty) { // if (_passwordController.text.isEmpty) {
return; // return;
} // }
context.read<AuthBloc>().add( // context.read<AuthBloc>().add(
AuthEventAddEmailAndPassword( // AuthEventAddEmailAndPassword(
email: _newEmailController.text, // email: _newEmailController.text,
password: _passwordController.text, // password: _passwordController.text,
), // ),
); // );
_emailController.text = _newEmailController.text; // _emailController.text = _newEmailController.text;
} // }
final myUser = state.user!.copyWith( final myUser = state.user!.copyWith(
name: _nameController.text, name: _nameController.text,
@@ -447,10 +251,10 @@ class _ProfileScreenState extends State<ProfileScreen> {
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(vertical: 5), padding: const EdgeInsets.symmetric(vertical: 5),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(50),
), ),
shadowColor: Colors.grey, shadowColor: Colors.grey,
elevation: 5, // elevation: 0,
), ),
child: Container( child: Container(
constraints: const BoxConstraints(maxWidth: 300.0, minHeight: 50.0), constraints: const BoxConstraints(maxWidth: 300.0, minHeight: 50.0),
@@ -463,7 +267,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
'Actualizar', 'Actualizar',
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 18, fontSize: 16,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@@ -76,7 +76,6 @@ class FirebaseUserRepository implements UserRepository {
return _firebaseAuth.userChanges().map((event) => null != event); return _firebaseAuth.userChanges().map((event) => null != event);
} }
// Sign up
@override @override
Future<MyUser> signUp(MyUser myUser, String password) async { Future<MyUser> signUp(MyUser myUser, String password) async {
try { try {
@@ -95,7 +94,6 @@ class FirebaseUserRepository implements UserRepository {
} }
} }
// Sign in with phone number
@override @override
Future<void> signInWithPhoneNumber(String phoneNumber) async { Future<void> signInWithPhoneNumber(String phoneNumber) async {
try { try {
@@ -150,7 +148,6 @@ class FirebaseUserRepository implements UserRepository {
} }
} }
// Sign in
@override @override
Future<void> signIn(String email, String password) async { Future<void> signIn(String email, String password) async {
try { try {
@@ -164,22 +161,23 @@ class FirebaseUserRepository implements UserRepository {
} }
} }
// Add email and password to user authenticate with phone
@override @override
Future<bool> addEmailAndPassword(String email, String password) async { Future<String?> addEmailAndPassword(String email, String password) async {
try { try {
await _firebaseAuth.currentUser!.updateEmail(email); await _firebaseAuth.currentUser!.updateEmail(email);
await _firebaseAuth.currentUser!.updatePassword(password); await _firebaseAuth.currentUser!.updatePassword(password);
return true; return null;
} catch (e) { } catch (e) {
log('xd -- Error add email and password ${e.toString()}'); if (e is FirebaseAuthException && e.code == 'requires-recent-login') {
return 'requires-recent-login';
}
if (e is FirebaseAuthException && e.code == 'requires-recent-login') {} if (e is FirebaseAuthException && e.code == 'email-already-in-use') {
return 'email-already-in-use';
}
if (e is FirebaseAuthException && e.code == 'email-already-in-use') {} return 'unknown-error';
return false;
} }
} }
@@ -194,7 +192,6 @@ class FirebaseUserRepository implements UserRepository {
} }
} }
// Reset password
@override @override
Future<void> resetPassword(String email) async { Future<void> resetPassword(String email) async {
try { try {
@@ -205,7 +202,6 @@ class FirebaseUserRepository implements UserRepository {
} }
} }
// Set user data
@override @override
Future<void> setUserData(MyUser user) async { Future<void> setUserData(MyUser user) async {
try { try {
@@ -216,7 +212,6 @@ class FirebaseUserRepository implements UserRepository {
} }
} }
// Get user data
@override @override
Future<MyUser?> getMyUser(String myUserId) async { Future<MyUser?> getMyUser(String myUserId) async {
try { try {
@@ -1,17 +1,15 @@
import '../../user_repository.dart'; import '../../user_repository.dart';
abstract class UserRepository { abstract class UserRepository {
// Stream<User?> get user;
Stream<MyUser?> streamUser(); Stream<MyUser?> streamUser();
Stream<bool> isAuthenticated(); Stream<bool> isAuthenticated();
Future<void> signIn(String email, String password); Future<void> signIn(String email, String password);
Future<bool> addEmailAndPassword(String email, String password); Future<String?> addEmailAndPassword(String email, String password);
Future<void> logOut(); Future<void> logOut();
// Future<MyUser> signUp(String name, String email, String password);
Future<MyUser> signUp(MyUser myUser, String password); Future<MyUser> signUp(MyUser myUser, String password);
Future<void> signInWithPhoneNumber(String phoneNumber); Future<void> signInWithPhoneNumber(String phoneNumber);