after
This commit is contained in:
+3
-9
@@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:injector/injector.dart';
|
import 'package:injector/injector.dart';
|
||||||
import 'package:prosappco/blocs/authentication_bloc/authentication_bloc.dart';
|
import 'package:prosappco/blocs/authentication_bloc/authentication_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/blocs/profile_bloc/profile_bloc.dart';
|
||||||
import 'package:prosappco/blocs/sign_up_bloc/sign_up_bloc.dart';
|
import 'package:prosappco/blocs/sign_up_bloc/sign_up_bloc.dart';
|
||||||
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
|
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
|
||||||
import 'package:prosappco/blocs/update_user_info_bloc/update_user_info_bloc.dart';
|
|
||||||
|
|
||||||
import 'app_view.dart';
|
import 'app_view.dart';
|
||||||
|
|
||||||
@@ -22,15 +22,9 @@ class MainApp extends StatelessWidget {
|
|||||||
BlocProvider<MyUserBloc>(
|
BlocProvider<MyUserBloc>(
|
||||||
create: (context) => Injector.appInstance.get<MyUserBloc>(),
|
create: (context) => Injector.appInstance.get<MyUserBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<UpdateUserInfoBloc>(
|
BlocProvider<ProfileBloc>(
|
||||||
create: (context) => Injector.appInstance.get<UpdateUserInfoBloc>(),
|
create: (context) => Injector.appInstance.get<ProfileBloc>(),
|
||||||
),
|
),
|
||||||
// BlocProvider<SignInBloc>(
|
|
||||||
// create: (context) => Injector.appInstance.get<SignInBloc>(),
|
|
||||||
// ),
|
|
||||||
// BlocProvider<SignUpBloc>(
|
|
||||||
// create: (context) => Injector.appInstance.get<SignUpBloc>(),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
child: BlocBuilder<MyUserBloc, MyUserState>(
|
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
|||||||
+6
-8
@@ -2,22 +2,20 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:user_repository/user_repository.dart';
|
import 'package:user_repository/user_repository.dart';
|
||||||
|
|
||||||
part 'update_user_info_event.dart';
|
part 'profile_event.dart';
|
||||||
part 'update_user_info_state.dart';
|
part 'profile_state.dart';
|
||||||
|
|
||||||
class UpdateUserInfoBloc
|
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
extends Bloc<UpdateUserInfoEvent, UpdateUserInfoState> {
|
|
||||||
final UserRepository _userRepository;
|
final UserRepository _userRepository;
|
||||||
|
|
||||||
UpdateUserInfoBloc({required UserRepository userRepository})
|
ProfileBloc({required UserRepository userRepository})
|
||||||
: _userRepository = userRepository,
|
: _userRepository = userRepository,
|
||||||
super(UpdateUserInfoInitial()) {
|
super(UpdateUserInfoInitial()) {
|
||||||
on<UploadPicture>(_onUploadPicture);
|
on<UploadPicture>(_onUploadPicture);
|
||||||
on<UpdateUserInfo>(_onUpdateUserInfo);
|
on<UpdateUserInfo>(_onUpdateUserInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onUploadPicture(
|
void _onUploadPicture(UploadPicture event, Emitter<ProfileState> emit) async {
|
||||||
UploadPicture event, Emitter<UpdateUserInfoState> emit) async {
|
|
||||||
emit(UploadPictureLoading());
|
emit(UploadPictureLoading());
|
||||||
try {
|
try {
|
||||||
String userImage =
|
String userImage =
|
||||||
@@ -29,7 +27,7 @@ class UpdateUserInfoBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateUserInfo(
|
void _onUpdateUserInfo(
|
||||||
UpdateUserInfo event, Emitter<UpdateUserInfoState> emit) async {
|
UpdateUserInfo event, Emitter<ProfileState> emit) async {
|
||||||
emit(UpdateUserInfoLoading());
|
emit(UpdateUserInfoLoading());
|
||||||
try {
|
try {
|
||||||
await _userRepository.updateUserInfo(event.userId, {
|
await _userRepository.updateUserInfo(event.userId, {
|
||||||
+5
-5
@@ -1,13 +1,13 @@
|
|||||||
part of 'update_user_info_bloc.dart';
|
part of 'profile_bloc.dart';
|
||||||
|
|
||||||
abstract class UpdateUserInfoEvent extends Equatable {
|
abstract class ProfileEvent extends Equatable {
|
||||||
const UpdateUserInfoEvent();
|
const ProfileEvent();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class UploadPicture extends UpdateUserInfoEvent {
|
class UploadPicture extends ProfileEvent {
|
||||||
final String file;
|
final String file;
|
||||||
final String userId;
|
final String userId;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class UploadPicture extends UpdateUserInfoEvent {
|
|||||||
List<Object> get props => [file, userId];
|
List<Object> get props => [file, userId];
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdateUserInfo extends UpdateUserInfoEvent {
|
class UpdateUserInfo extends ProfileEvent {
|
||||||
final String userId;
|
final String userId;
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
part of 'profile_bloc.dart';
|
||||||
|
|
||||||
|
abstract class ProfileState extends Equatable {
|
||||||
|
const ProfileState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdateUserInfoInitial extends ProfileState {}
|
||||||
|
|
||||||
|
class UploadPictureFailure extends ProfileState {}
|
||||||
|
|
||||||
|
class UploadPictureLoading extends ProfileState {}
|
||||||
|
|
||||||
|
class UploadPictureSuccess extends ProfileState {
|
||||||
|
final String userImage;
|
||||||
|
|
||||||
|
const UploadPictureSuccess(this.userImage);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [userImage];
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdateUserInfoFailure extends ProfileState {}
|
||||||
|
|
||||||
|
class UpdateUserInfoLoading extends ProfileState {}
|
||||||
|
|
||||||
|
class UpdateUserInfoSuccess extends ProfileState {
|
||||||
|
const UpdateUserInfoSuccess();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:user_repository/user_repository.dart';
|
||||||
|
|
||||||
|
part 'setting_event.dart';
|
||||||
|
part 'setting_state.dart';
|
||||||
|
|
||||||
|
class SettingBloc extends Bloc<SettingEvent, SettingState> {
|
||||||
|
final UserRepository _userRepository;
|
||||||
|
late final StreamSubscription<bool> _authSubscription;
|
||||||
|
|
||||||
|
SettingBloc({required UserRepository userRepository})
|
||||||
|
: _userRepository = userRepository,
|
||||||
|
super(SettingInitial()) {
|
||||||
|
_authSubscription =
|
||||||
|
_userRepository.isAuthenticated().listen((isAuthenticated) {
|
||||||
|
if (!isAuthenticated) {
|
||||||
|
try {
|
||||||
|
emit(SettingLogoutSuccess());
|
||||||
|
} catch (e) {
|
||||||
|
log('xd Error en el settings bloc ${e.toString()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
on<SettingLogoutRequest>(_onSettingLogoutRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSettingLogoutRequest(
|
||||||
|
SettingLogoutRequest event, Emitter<SettingState> emit) async {
|
||||||
|
await _userRepository.logOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> close() {
|
||||||
|
_authSubscription.cancel();
|
||||||
|
return super.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
part of 'setting_bloc.dart';
|
||||||
|
|
||||||
|
abstract class SettingEvent extends Equatable {
|
||||||
|
const SettingEvent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingLogoutRequest extends SettingEvent {}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
part of 'setting_bloc.dart';
|
||||||
|
|
||||||
|
abstract class SettingState extends Equatable {
|
||||||
|
const SettingState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingInitial extends SettingState {}
|
||||||
|
|
||||||
|
class SettingLogoutSuccess extends SettingState {}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
part of 'update_user_info_bloc.dart';
|
|
||||||
|
|
||||||
abstract class UpdateUserInfoState extends Equatable {
|
|
||||||
const UpdateUserInfoState();
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateUserInfoInitial extends UpdateUserInfoState {}
|
|
||||||
|
|
||||||
class UploadPictureFailure extends UpdateUserInfoState {}
|
|
||||||
|
|
||||||
class UploadPictureLoading extends UpdateUserInfoState {}
|
|
||||||
|
|
||||||
class UploadPictureSuccess extends UpdateUserInfoState {
|
|
||||||
final String userImage;
|
|
||||||
|
|
||||||
const UploadPictureSuccess(this.userImage);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [userImage];
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateUserInfoFailure extends UpdateUserInfoState {}
|
|
||||||
|
|
||||||
class UpdateUserInfoLoading extends UpdateUserInfoState {}
|
|
||||||
|
|
||||||
class UpdateUserInfoSuccess extends UpdateUserInfoState {
|
|
||||||
const UpdateUserInfoSuccess();
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [];
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,10 @@ import 'package:firebase_auth/firebase_auth.dart';
|
|||||||
import 'package:injector/injector.dart';
|
import 'package:injector/injector.dart';
|
||||||
import 'package:prosappco/blocs/authentication_bloc/authentication_bloc.dart';
|
import 'package:prosappco/blocs/authentication_bloc/authentication_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/blocs/profile_bloc/profile_bloc.dart';
|
||||||
|
import 'package:prosappco/blocs/setting_bloc/setting_bloc.dart';
|
||||||
import 'package:prosappco/blocs/sign_up_bloc/sign_up_bloc.dart';
|
import 'package:prosappco/blocs/sign_up_bloc/sign_up_bloc.dart';
|
||||||
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
|
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
|
||||||
import 'package:prosappco/blocs/update_user_info_bloc/update_user_info_bloc.dart';
|
|
||||||
import 'package:user_repository/user_repository.dart';
|
import 'package:user_repository/user_repository.dart';
|
||||||
|
|
||||||
class UserDI {
|
class UserDI {
|
||||||
@@ -20,13 +21,16 @@ class UserDI {
|
|||||||
injector.registerSingleton<MyUserBloc>(
|
injector.registerSingleton<MyUserBloc>(
|
||||||
(() => MyUserBloc(myUserRepository: injector.get<UserRepository>())));
|
(() => MyUserBloc(myUserRepository: injector.get<UserRepository>())));
|
||||||
|
|
||||||
injector.registerSingleton<UpdateUserInfoBloc>((() =>
|
injector.registerSingleton<ProfileBloc>(
|
||||||
UpdateUserInfoBloc(userRepository: injector.get<UserRepository>())));
|
(() => ProfileBloc(userRepository: injector.get<UserRepository>())));
|
||||||
|
|
||||||
injector.registerDependency<SignInBloc>(
|
injector.registerDependency<SignInBloc>(
|
||||||
(() => SignInBloc(userRepository: injector.get<UserRepository>())));
|
(() => SignInBloc(userRepository: injector.get<UserRepository>())));
|
||||||
|
|
||||||
injector.registerDependency<SignUpBloc>(
|
injector.registerDependency<SignUpBloc>(
|
||||||
(() => SignUpBloc(userRepository: injector.get<UserRepository>())));
|
(() => SignUpBloc(userRepository: injector.get<UserRepository>())));
|
||||||
|
|
||||||
|
injector.registerDependency<SettingBloc>(
|
||||||
|
(() => SettingBloc(userRepository: injector.get<UserRepository>())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:prosappco/screens/authentication/sign_up_screen.dart';
|
|||||||
class SignScreen extends StatefulWidget {
|
class SignScreen extends StatefulWidget {
|
||||||
final int initialIndex;
|
final int initialIndex;
|
||||||
|
|
||||||
SignScreen({super.key, required this.initialIndex});
|
const SignScreen({super.key, required this.initialIndex});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SignScreen> createState() => _SignScreenState();
|
State<SignScreen> createState() => _SignScreenState();
|
||||||
@@ -48,19 +48,22 @@ class _SignScreenState extends State<SignScreen> with TickerProviderStateMixin {
|
|||||||
color: Theme.of(context).colorScheme.tertiary,
|
color: Theme.of(context).colorScheme.tertiary,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Container(
|
||||||
child: Image(
|
color: Theme.of(context).colorScheme.tertiary,
|
||||||
width: width * 0.7,
|
padding: const EdgeInsets.only(bottom: 20.0),
|
||||||
image: AssetImage('images/logo_prosapp.png'),
|
child: Center(
|
||||||
|
child: Image(
|
||||||
|
width: width * 0.7,
|
||||||
|
image: const AssetImage('images/logo_prosapp.png'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
|
||||||
TabBar(
|
TabBar(
|
||||||
controller: tabController,
|
controller: tabController,
|
||||||
unselectedLabelColor:
|
unselectedLabelColor:
|
||||||
Theme.of(context).colorScheme.onBackground,
|
Theme.of(context).colorScheme.onBackground,
|
||||||
labelColor: Theme.of(context).colorScheme.onBackground,
|
labelColor: Theme.of(context).colorScheme.onBackground,
|
||||||
tabs: [
|
tabs: const [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(12.0),
|
padding: EdgeInsets.all(12.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -102,20 +105,6 @@ class _SignScreenState extends State<SignScreen> with TickerProviderStateMixin {
|
|||||||
Injector.appInstance.get<SignUpBloc>(),
|
Injector.appInstance.get<SignUpBloc>(),
|
||||||
child: SignUpScreen(),
|
child: SignUpScreen(),
|
||||||
),
|
),
|
||||||
// BlocProvider<SignInBloc>(
|
|
||||||
// create: (context) => SignInBloc(
|
|
||||||
// userRepository: context
|
|
||||||
// .read<AuthenticationBloc>()
|
|
||||||
// .userRepository),
|
|
||||||
// child: SignInScreen(),
|
|
||||||
// ),
|
|
||||||
// BlocProvider<SignUpBloc>(
|
|
||||||
// create: (context) => SignUpBloc(
|
|
||||||
// userRepository: context
|
|
||||||
// .read<AuthenticationBloc>()
|
|
||||||
// .userRepository),
|
|
||||||
// child: SignUpScreen(),
|
|
||||||
// ),
|
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,124 +6,312 @@ import 'package:intl_phone_field/intl_phone_field.dart';
|
|||||||
import 'package:prosappco/screens/authentication/sign_screen.dart';
|
import 'package:prosappco/screens/authentication/sign_screen.dart';
|
||||||
|
|
||||||
class WelcomeScreen extends StatelessWidget {
|
class WelcomeScreen extends StatelessWidget {
|
||||||
const WelcomeScreen({super.key});
|
const WelcomeScreen({Key? key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double width = MediaQuery.of(context).size.width;
|
double width = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: Theme.of(context).colorScheme.tertiary,
|
||||||
body: Column(
|
body: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Padding(
|
||||||
color: Theme.of(context).colorScheme.tertiary,
|
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||||
child: Column(
|
child: Center(
|
||||||
children: [
|
child: Image(
|
||||||
const SizedBox(height: 20),
|
width: width * 0.7,
|
||||||
Center(
|
image: const AssetImage('images/logo_prosapp.png'),
|
||||||
child: Image(
|
|
||||||
width: width * 0.7,
|
|
||||||
image: const AssetImage('images/logo_prosapp.png'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: Text(
|
|
||||||
'Iniciar sesión',
|
|
||||||
style: TextStyle(
|
|
||||||
// fontSize: 30,
|
|
||||||
fontSize: width * 0.08,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: Container(
|
||||||
child: Column(
|
decoration: const BoxDecoration(
|
||||||
children: [
|
color: Colors.white,
|
||||||
const SizedBox(height: 10),
|
borderRadius: BorderRadius.only(
|
||||||
SizedBox(
|
topLeft: Radius.circular(60),
|
||||||
width: double.infinity,
|
topRight: Radius.circular(60),
|
||||||
child: Text(
|
),
|
||||||
'Numero de celular',
|
),
|
||||||
style: TextStyle(
|
child: Padding(
|
||||||
fontSize: width * 0.045,
|
padding:
|
||||||
color: Theme.of(context).colorScheme.onBackground,
|
const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
|
||||||
),
|
child: SingleChildScrollView(
|
||||||
),
|
child: Column(
|
||||||
),
|
children: [
|
||||||
Form(
|
SizedBox(
|
||||||
child: IntlPhoneField(
|
width: double.infinity,
|
||||||
initialCountryCode: 'CO',
|
child: Text(
|
||||||
keyboardType: TextInputType.number,
|
'Iniciar sesión',
|
||||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
style: TextStyle(
|
||||||
),
|
// fontSize: 30,
|
||||||
),
|
fontSize: width * 0.08,
|
||||||
Text(
|
fontWeight: FontWeight.bold,
|
||||||
'Un código será enviado a este numero de celular.',
|
),
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13.0,
|
|
||||||
color: Theme.of(context).colorScheme.onBackground,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => SignScreen(initialIndex: 0),
|
|
||||||
),
|
),
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'Inicia sesión con tu correo electrónico',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: width * 0.04,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
),
|
SizedBox(
|
||||||
RichText(
|
width: double.infinity,
|
||||||
text: TextSpan(
|
child: Text(
|
||||||
style: const TextStyle(
|
'Numero de celular',
|
||||||
fontSize: 16.0,
|
style: TextStyle(
|
||||||
color: Color(0xFF65676B),
|
fontSize: width * 0.045,
|
||||||
fontFamily: 'Poppins',
|
color: Theme.of(context).colorScheme.onBackground,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
children: [
|
Form(
|
||||||
const TextSpan(text: '¿No estás registrado? '),
|
child: IntlPhoneField(
|
||||||
TextSpan(
|
initialCountryCode: 'CO',
|
||||||
text: 'Regístrate',
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Un código será enviado a este numero de celular.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13.0,
|
||||||
|
color: Theme.of(context).colorScheme.onBackground,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
const SignScreen(initialIndex: 1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Iniciar Sesión'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
const SignScreen(initialIndex: 0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Inicia sesión con tu correo electrónico',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: width * 0.04,
|
fontSize: width * 0.04,
|
||||||
color: Colors.blue,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
),
|
||||||
recognizer: TapGestureRecognizer()
|
|
||||||
..onTap = () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
SignScreen(initialIndex: 1),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16.0,
|
||||||
|
color: Color(0xFF65676B),
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
const TextSpan(text: '¿No estás registrado? '),
|
||||||
|
TextSpan(
|
||||||
|
text: 'Regístrate',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: width * 0.04,
|
||||||
|
color: Colors.blue,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
SignScreen(initialIndex: 1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Scaffold(
|
||||||
|
// backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
// body: Column(
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// color: Theme.of(context).colorScheme.tertiary,
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// const SizedBox(height: 20),
|
||||||
|
// Center(
|
||||||
|
// child: Image(
|
||||||
|
// width: width * 0.7,
|
||||||
|
// image: const AssetImage('images/logo_prosapp.png'),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 20),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// width: double.infinity,
|
||||||
|
// child: Text(
|
||||||
|
// 'Iniciar sesión',
|
||||||
|
// style: TextStyle(
|
||||||
|
// // fontSize: 30,
|
||||||
|
// fontSize: width * 0.08,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Expanded(
|
||||||
|
// child: SingleChildScrollView(
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// const SizedBox(height: 10),
|
||||||
|
// SizedBox(
|
||||||
|
// width: double.infinity,
|
||||||
|
// child: Text(
|
||||||
|
// 'Numero de celular',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: width * 0.045,
|
||||||
|
// color: Theme.of(context).colorScheme.onBackground,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Form(
|
||||||
|
// child: IntlPhoneField(
|
||||||
|
// initialCountryCode: 'CO',
|
||||||
|
// keyboardType: TextInputType.number,
|
||||||
|
// inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Text(
|
||||||
|
// 'Un código será enviado a este numero de celular.',
|
||||||
|
// textAlign: TextAlign.center,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 13.0,
|
||||||
|
// color: Theme.of(context).colorScheme.onBackground,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// TextButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.push(
|
||||||
|
// context,
|
||||||
|
// CupertinoPageRoute(
|
||||||
|
// builder: (context) => SignScreen(initialIndex: 0),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: Text(
|
||||||
|
// 'Inicia sesión con tu correo electrónico',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: width * 0.04,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// RichText(
|
||||||
|
// text: TextSpan(
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontSize: 16.0,
|
||||||
|
// color: Color(0xFF65676B),
|
||||||
|
// fontFamily: 'Poppins',
|
||||||
|
// ),
|
||||||
|
// children: [
|
||||||
|
// const TextSpan(text: '¿No estás registrado? '),
|
||||||
|
// TextSpan(
|
||||||
|
// text: 'Regístrate',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: width * 0.04,
|
||||||
|
// color: Colors.blue,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// ),
|
||||||
|
// recognizer: TapGestureRecognizer()
|
||||||
|
// ..onTap = () {
|
||||||
|
// Navigator.push(
|
||||||
|
// context,
|
||||||
|
// CupertinoPageRoute(
|
||||||
|
// builder: (context) =>
|
||||||
|
// SignScreen(initialIndex: 1),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// Scaffold(
|
||||||
|
// backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
// body: ListView(
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// color: Theme.of(context).colorScheme.tertiary,
|
||||||
|
// padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||||
|
// child: Center(
|
||||||
|
// child: Image(
|
||||||
|
// width: width * 0.7,
|
||||||
|
// image: const AssetImage('images/logo_prosapp.png'),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Container(
|
||||||
|
// decoration: const BoxDecoration(
|
||||||
|
// color: Colors.white,
|
||||||
|
// borderRadius: BorderRadius.only(
|
||||||
|
// topLeft: Radius.circular(60),
|
||||||
|
// topRight: Radius.circular(60),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: const EdgeInsets.all(20.0),
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// const TextField(
|
||||||
|
// decoration: InputDecoration(
|
||||||
|
// labelText: 'Usuario',
|
||||||
|
// border: OutlineInputBorder(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 20.0),
|
||||||
|
// const TextField(
|
||||||
|
// decoration: InputDecoration(
|
||||||
|
// labelText: 'Contraseña',
|
||||||
|
// border: OutlineInputBorder(),
|
||||||
|
// ),
|
||||||
|
// obscureText: true,
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 20.0),
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,9 +125,12 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
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:prosappco/blocs/authentication_bloc/authentication_bloc.dart';
|
import 'package:injector/injector.dart';
|
||||||
|
import 'package:prosappco/blocs/setting_bloc/setting_bloc.dart';
|
||||||
import 'package:prosappco/components/general_drawer_item.dart';
|
import 'package:prosappco/components/general_drawer_item.dart';
|
||||||
|
|
||||||
class ConfigurationScreen extends StatelessWidget {
|
class ConfigurationScreen extends StatelessWidget {
|
||||||
@@ -135,36 +138,45 @@ class ConfigurationScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocListener<AuthenticationBloc, AuthenticationState>(
|
final settingBloc = Injector.appInstance.get<SettingBloc>();
|
||||||
listener: (context, state) {
|
|
||||||
if (state.status == AuthenticationStatus.unauthenticated) {
|
return BlocProvider<SettingBloc>(
|
||||||
Navigator.pop(context);
|
create: (context) => settingBloc,
|
||||||
}
|
child: BlocListener<SettingBloc, SettingState>(
|
||||||
},
|
listener: (context, state) {
|
||||||
child: Scaffold(
|
if (state is SettingLogoutSuccess) {
|
||||||
appBar: AppBar(
|
Navigator.pop(context);
|
||||||
title: const Text('Configuración'),
|
}
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Configuración'),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: [
|
||||||
|
GeneralDrawerItem(
|
||||||
|
label: 'Acerca de la aplicación',
|
||||||
|
onTap: () {},
|
||||||
|
trailing: true,
|
||||||
|
),
|
||||||
|
GeneralDrawerItem(
|
||||||
|
label: 'Cerrar sesión',
|
||||||
|
onTap: () {
|
||||||
|
try {
|
||||||
|
settingBloc.add(SettingLogoutRequest());
|
||||||
|
} catch (e) {
|
||||||
|
log('xd conigura ${e.toString()}');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
GeneralDrawerItem(
|
||||||
|
label: 'Eliminar cuenta',
|
||||||
|
onTap: () {},
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: ListView(children: [
|
|
||||||
GeneralDrawerItem(
|
|
||||||
label: 'Acerca de la aplicación',
|
|
||||||
onTap: () {},
|
|
||||||
trailing: true,
|
|
||||||
),
|
|
||||||
GeneralDrawerItem(
|
|
||||||
label: 'Cerrar sesión',
|
|
||||||
onTap: () {
|
|
||||||
context
|
|
||||||
.read<AuthenticationBloc>()
|
|
||||||
.add(AuthenticationLogoutRequested());
|
|
||||||
},
|
|
||||||
),
|
|
||||||
GeneralDrawerItem(
|
|
||||||
label: 'Eliminar cuenta',
|
|
||||||
onTap: () {},
|
|
||||||
color: Theme.of(context).colorScheme.error,
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.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/blocs/update_user_info_bloc/update_user_info_bloc.dart';
|
import 'package:prosappco/blocs/profile_bloc/profile_bloc.dart';
|
||||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||||
|
|
||||||
class ProfileScreen extends StatefulWidget {
|
class ProfileScreen extends StatefulWidget {
|
||||||
@@ -24,7 +24,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocListener<UpdateUserInfoBloc, UpdateUserInfoState>(
|
return BlocListener<ProfileBloc, ProfileState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is UploadPictureSuccess) {
|
if (state is UploadPictureSuccess) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -57,7 +57,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
context.read<UpdateUserInfoBloc>().add(
|
context.read<ProfileBloc>().add(
|
||||||
UploadPicture(image.path, state.user!.id),
|
UploadPicture(image.path, state.user!.id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<UpdateUserInfoBloc>().add(
|
context.read<ProfileBloc>().add(
|
||||||
UpdateUserInfo(state.user!.id, _nameController.text));
|
UpdateUserInfo(state.user!.id, _nameController.text));
|
||||||
},
|
},
|
||||||
child: const Text('Guardar'),
|
child: const Text('Guardar'),
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ class FirebaseUserRepository implements UserRepository {
|
|||||||
return _userStreamController.stream;
|
return _userStreamController.stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<bool> isAuthenticated() {
|
||||||
|
return _firebaseAuth.userChanges().map((event) => null != event);
|
||||||
|
}
|
||||||
|
|
||||||
// Sign up
|
// Sign up
|
||||||
@override
|
@override
|
||||||
Future<MyUser> signUp(MyUser myUser, String password) async {
|
Future<MyUser> signUp(MyUser myUser, String password) async {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import '../../user_repository.dart';
|
|||||||
abstract class UserRepository {
|
abstract class UserRepository {
|
||||||
// Stream<User?> get user;
|
// Stream<User?> get user;
|
||||||
Stream<MyUser?> streamUser();
|
Stream<MyUser?> streamUser();
|
||||||
|
Stream<bool> isAuthenticated();
|
||||||
|
|
||||||
Future<void> signIn(String email, String password);
|
Future<void> signIn(String email, String password);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user