stream image
This commit is contained in:
+22
-24
@@ -6,8 +6,6 @@ import 'package:prosappco/blocs/my_user_bloc/my_user_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:prosappco/blocs/update_user_info_bloc/update_user_info_bloc.dart';
|
||||||
import 'package:prosappco/screens/home/home_screen.dart';
|
|
||||||
import 'package:user_repository/user_repository.dart';
|
|
||||||
|
|
||||||
import 'app_view.dart';
|
import 'app_view.dart';
|
||||||
|
|
||||||
@@ -17,28 +15,28 @@ class MainApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider<AuthenticationBloc>(
|
BlocProvider<AuthenticationBloc>(
|
||||||
create: (context) => Injector.appInstance.get<AuthenticationBloc>(),
|
create: (context) => Injector.appInstance.get<AuthenticationBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<MyUserBloc>(
|
BlocProvider<MyUserBloc>(
|
||||||
create: (context) => Injector.appInstance.get<MyUserBloc>(),
|
create: (context) => Injector.appInstance.get<MyUserBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<UpdateUserInfoBloc>(
|
BlocProvider<UpdateUserInfoBloc>(
|
||||||
create: (context) => Injector.appInstance.get<UpdateUserInfoBloc>(),
|
create: (context) => Injector.appInstance.get<UpdateUserInfoBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<SignInBloc>(
|
BlocProvider<SignInBloc>(
|
||||||
create: (context) => Injector.appInstance.get<SignInBloc>(),
|
create: (context) => Injector.appInstance.get<SignInBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<SignUpBloc>(
|
BlocProvider<SignUpBloc>(
|
||||||
create: (context) => Injector.appInstance.get<SignUpBloc>(),
|
create: (context) => Injector.appInstance.get<SignUpBloc>(),
|
||||||
)
|
)
|
||||||
// RepositoryProvider<AuthenticationBloc>(
|
],
|
||||||
// create: (_) => AuthenticationBloc(myUserRepository: userRepository),
|
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||||
// ),
|
builder: (context, state) {
|
||||||
],
|
|
||||||
child: BlocBuilder<MyUserBloc, MyUserState>(builder: (context, state) {
|
|
||||||
return const MyAppView();
|
return const MyAppView();
|
||||||
}));
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-31
@@ -1,11 +1,7 @@
|
|||||||
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/my_user_bloc/my_user_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:prosappco/screens/authentication/welcome_screen.dart';
|
import 'package:prosappco/screens/authentication/welcome_screen.dart';
|
||||||
import 'package:prosappco/screens/home/home_screen.dart';
|
import 'package:prosappco/screens/home/home_screen.dart';
|
||||||
import 'package:prosappco/screens/profile/profile_screen.dart';
|
|
||||||
|
|
||||||
import 'blocs/authentication_bloc/authentication_bloc.dart';
|
import 'blocs/authentication_bloc/authentication_bloc.dart';
|
||||||
|
|
||||||
@@ -31,33 +27,17 @@ class MyAppView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
home: BlocBuilder<AuthenticationBloc, AuthenticationState>(
|
home: BlocBuilder<AuthenticationBloc, AuthenticationState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state.status == AuthenticationStatus.authenticated) {
|
switch (state.status) {
|
||||||
// MultiBlocProvider(
|
case AuthenticationStatus.authenticated:
|
||||||
// providers: [
|
return const HomeScreen();
|
||||||
// BlocProvider(
|
|
||||||
// create: (context) => SignInBloc(
|
case AuthenticationStatus.unauthenticated:
|
||||||
// userRepository:
|
return const WelcomeScreen();
|
||||||
// context.read<AuthenticationBloc>().userRepository),
|
|
||||||
// ),
|
case AuthenticationStatus.unknown:
|
||||||
// BlocProvider(
|
return const Center(
|
||||||
// create: (context) => UpdateUserInfoBloc(
|
child: CircularProgressIndicator(), // splash screen
|
||||||
// userRepository:
|
);
|
||||||
// context.read<AuthenticationBloc>().userRepository),
|
|
||||||
// ),
|
|
||||||
// BlocProvider(
|
|
||||||
// create: (context) => MyUserBloc(
|
|
||||||
// myUserRepository:
|
|
||||||
// context.read<AuthenticationBloc>().userRepository)
|
|
||||||
// ..add(GetMyUser(
|
|
||||||
// myUserId:
|
|
||||||
// context.read<AuthenticationBloc>().state.user!.uid)),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// child: const HomeScreen(),
|
|
||||||
// );
|
|
||||||
return const HomeScreen();
|
|
||||||
} else {
|
|
||||||
return const WelcomeScreen();
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:user_repository/user_repository.dart';
|
import 'package:user_repository/user_repository.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -15,38 +15,12 @@ class MyUserBloc extends Bloc<MyUserEvent, MyUserState> {
|
|||||||
: _userRepository = myUserRepository,
|
: _userRepository = myUserRepository,
|
||||||
super(const MyUserState.loading()) {
|
super(const MyUserState.loading()) {
|
||||||
_userRepository.streamUser().listen((event) {
|
_userRepository.streamUser().listen((event) {
|
||||||
log('xd ---: ${event}');
|
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
log('UserChanged: ${event}');
|
|
||||||
emit(const MyUserState.failure());
|
emit(const MyUserState.failure());
|
||||||
} else {
|
} else {
|
||||||
log('UserChanged: ${event}');
|
emit(MyUserState.success(event));
|
||||||
emit(MyUserState.success(event!));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// on<UserChanged>(_onUserChanged);
|
|
||||||
// _userRepository.user.first.then((user) {
|
|
||||||
// log('xd: ${user}');
|
|
||||||
// if (user != null) {
|
|
||||||
// add(UserChanged(user: user));
|
|
||||||
// _userSubscription = _userRepository.user.listen((user) {
|
|
||||||
// log('xd: ${user}');
|
|
||||||
// add(UserChanged(user: user));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }).catchError((e) {
|
|
||||||
// log('xd: ${e}');
|
|
||||||
// add(UserChanged(user: null));
|
|
||||||
// });
|
|
||||||
// on<GetMyUser>(_onGetMyUser);
|
|
||||||
// _userRepository.user.listen((user) {
|
|
||||||
// if (user != null) {
|
|
||||||
// add(GetMyUser(myUserId: user.uid));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// emit(MyUserState.success(MyUser(
|
|
||||||
// name: 'John', id: '123', email: 'johndoe@gmail.com', picture: '')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onUserChanged(UserChanged event, Emitter<MyUserState> emit) {
|
void _onUserChanged(UserChanged event, Emitter<MyUserState> emit) {
|
||||||
@@ -59,17 +33,4 @@ class MyUserBloc extends Bloc<MyUserEvent, MyUserState> {
|
|||||||
emit(MyUserState.success(event.user!));
|
emit(MyUserState.success(event.user!));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// void _onGetMyUser(GetMyUser event, Emitter<MyUserState> emit) async {
|
|
||||||
// log('GetMyUser: ${event.myUserId}');
|
|
||||||
// emit(const MyUserState.loading());
|
|
||||||
// try {
|
|
||||||
// MyUser myUser = await _userRepository.getMyUser(event.myUserId);
|
|
||||||
// log('GetMyUser: $myUser');
|
|
||||||
// emit(MyUserState.success(myUser));
|
|
||||||
// } catch (e) {
|
|
||||||
// log('GetMyUser: $e');
|
|
||||||
// emit(const MyUserState.failure());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
RegExp emailRexExp = RegExp(r'^[\w-\.]+@([\w-]+.)+[\w-]{2,4}$');
|
RegExp emailRexExp = RegExp(r'^[\w-\.]+@([\w-]+.)+[\w-]{2,4}$');
|
||||||
|
|
||||||
RegExp passwordRexExp = RegExp(
|
RegExp passwordRexExp = RegExp(r'^(?=.*?[A-Z])(?=.*?[0-9]).{8,}$');
|
||||||
r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~`)\%\-(_+=;:,.<>/?"[{\]}\|^]).{8,}$');
|
|
||||||
|
|
||||||
RegExp specialCharRexExp =
|
RegExp specialCharRexExp =
|
||||||
RegExp(r'^(?=.*?[!@#$&*~`)\%\-(_+=;:,.<>/?"[{\]}\|^])');
|
RegExp(r'^(?=.*?[!@#$&*~`)\%\-(_+=;:,.<>/?"[{\]}\|^])');
|
||||||
|
|||||||
@@ -169,29 +169,22 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
|||||||
? Colors.green
|
? Colors.green
|
||||||
: Theme.of(context).colorScheme.onBackground),
|
: Theme.of(context).colorScheme.onBackground),
|
||||||
),
|
),
|
||||||
Text(
|
|
||||||
"⚈ 1 number",
|
|
||||||
style: TextStyle(
|
|
||||||
color: containsNumber
|
|
||||||
? Colors.green
|
|
||||||
: Theme.of(context).colorScheme.onBackground),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"⚈ 1 special character",
|
"⚈ 8 minimum character",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: containsSpecialChar
|
color: contains8Length
|
||||||
? Colors.green
|
? Colors.green
|
||||||
: Theme.of(context).colorScheme.onBackground),
|
: Theme.of(context).colorScheme.onBackground),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"⚈ 8 minimum character",
|
"⚈ 1 number",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: contains8Length
|
color: containsNumber
|
||||||
? Colors.green
|
? Colors.green
|
||||||
: Theme.of(context).colorScheme.onBackground),
|
: Theme.of(context).colorScheme.onBackground),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,112 +26,104 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: Theme.of(context).colorScheme.background,
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
drawer:
|
drawer: Drawer(
|
||||||
BlocBuilder<MyUserBloc, MyUserState>(builder: (context, state) {
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
if (state.status == MyUserStatus.success) {
|
child: SingleChildScrollView(
|
||||||
return Drawer(
|
child: Column(
|
||||||
backgroundColor: Theme.of(context).colorScheme.background,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
child: SingleChildScrollView(
|
children: [
|
||||||
child: Column(
|
Material(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
children: [
|
child: InkWell(
|
||||||
Material(
|
onTap: () {
|
||||||
color: Theme.of(context).colorScheme.primary,
|
Navigator.push(
|
||||||
child: InkWell(
|
context,
|
||||||
onTap: () {
|
CupertinoPageRoute(
|
||||||
Navigator.push(
|
builder: (context) => const ProfileScreen(),
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => const ProfileScreen(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: 20 + MediaQuery.of(context).padding.top,
|
|
||||||
bottom: 20,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
state.user!.picture == ""
|
|
||||||
? Container(
|
|
||||||
width: 80,
|
|
||||||
height: 80,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey.shade300,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
CupertinoIcons.person,
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
size: 35,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
width: 80,
|
|
||||||
height: 80,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
image: DecorationImage(
|
|
||||||
image: NetworkImage(
|
|
||||||
state.user!.picture!,
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
state.user!.name,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
state.user!.email,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: 20 + MediaQuery.of(context).padding.top,
|
||||||
|
bottom: 20,
|
||||||
),
|
),
|
||||||
),
|
child: Column(
|
||||||
Container(
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
child: ListView(
|
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
context.read<MyUserBloc>().state.user!.picture == ""
|
||||||
onTap: () {
|
? Container(
|
||||||
context
|
width: 80,
|
||||||
.read<SignInBloc>()
|
height: 80,
|
||||||
.add(const SignOutRequired());
|
decoration: BoxDecoration(
|
||||||
},
|
color: Colors.grey.shade300,
|
||||||
title: const Text(
|
shape: BoxShape.circle,
|
||||||
'Cerrar Sesión',
|
),
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.person,
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
width: 80,
|
||||||
|
height: 80,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
image: DecorationImage(
|
||||||
|
image: NetworkImage(
|
||||||
|
context
|
||||||
|
.read<MyUserBloc>()
|
||||||
|
.state
|
||||||
|
.user!
|
||||||
|
.picture!,
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
context.read<MyUserBloc>().state.user!.name,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
context.read<MyUserBloc>().state.user!.email,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Container(
|
||||||
);
|
height: MediaQuery.of(context).size.height,
|
||||||
} else {
|
color: Theme.of(context).colorScheme.background,
|
||||||
return Drawer(
|
child: ListView(
|
||||||
backgroundColor: Theme.of(context).colorScheme.background,
|
children: [
|
||||||
child: const Center(
|
ListTile(
|
||||||
child: CircularProgressIndicator(),
|
onTap: () {
|
||||||
),
|
context
|
||||||
);
|
.read<SignInBloc>()
|
||||||
}
|
.add(const SignOutRequired());
|
||||||
}),
|
},
|
||||||
|
title: const Text(
|
||||||
|
'Cerrar Sesión',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ class FirebaseUserRepository implements UserRepository {
|
|||||||
_userStreamController.add(null);
|
_userStreamController.add(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.streamUser().listen((event) {
|
|
||||||
log('xd - : ${event}');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stream<MyUser?> get user => _userStreamController.stream;
|
// Stream<MyUser?> get user => _userStreamController.stream;
|
||||||
|
|||||||
Reference in New Issue
Block a user