update
This commit is contained in:
@@ -243,8 +243,7 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
|||||||
}
|
}
|
||||||
final userIds = services.map((e) => e.userId);
|
final userIds = services.map((e) => e.userId);
|
||||||
|
|
||||||
final List<MyUser> users =
|
final List<MyUser> users = await _userRepository.getUsersFromIds(userIds);
|
||||||
await _userRepository.getUsersFromIds(userIds);
|
|
||||||
|
|
||||||
final usersDir = {for (var e in users) e.id: e};
|
final usersDir = {for (var e in users) e.id: e};
|
||||||
|
|
||||||
|
|||||||
@@ -205,17 +205,12 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
trailing: shouldProModeActive(
|
trailing: shouldProModeActive(context, professionalState)
|
||||||
context, professionalState)
|
? FutureBuilder(builder: (context, AsyncSnapshot<int> snapshot) {
|
||||||
? FutureBuilder(
|
if (!snapshot.hasData || snapshot.data! < 1) {
|
||||||
builder: (context,
|
|
||||||
AsyncSnapshot<int> snapshot) {
|
|
||||||
if (!snapshot.hasData ||
|
|
||||||
snapshot.data! < 1) {
|
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
final int notificationCount =
|
final int notificationCount = snapshot.data!;
|
||||||
snapshot.data!;
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 8,
|
horizontal: 8,
|
||||||
@@ -223,14 +218,12 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
borderRadius:
|
borderRadius: BorderRadius.circular(12),
|
||||||
BorderRadius.circular(12),
|
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
notificationCount > 9
|
notificationCount > 9
|
||||||
? '+9'
|
? '+9'
|
||||||
: notificationCount
|
: notificationCount.toString(),
|
||||||
.toString(),
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -242,8 +235,7 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
future: Injector.appInstance
|
future: Injector.appInstance
|
||||||
.get<FirebaseServiceRepository>()
|
.get<FirebaseServiceRepository>()
|
||||||
.countPendingServicesForProfessional(
|
.countPendingServicesForProfessional(
|
||||||
FirebaseAuth
|
FirebaseAuth.instance.currentUser!.uid),
|
||||||
.instance.currentUser!.uid),
|
|
||||||
)
|
)
|
||||||
: const Icon(
|
: const Icon(
|
||||||
Icons.keyboard_arrow_right,
|
Icons.keyboard_arrow_right,
|
||||||
@@ -251,8 +243,7 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
size: 25,
|
size: 25,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
shouldProModeActive(
|
shouldProModeActive(context, professionalState)
|
||||||
context, professionalState)
|
|
||||||
? 'Solicitudes'
|
? 'Solicitudes'
|
||||||
: 'Solicitar servicio',
|
: 'Solicitar servicio',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -278,11 +269,8 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final isProModeActive = (professionalState
|
final isProModeActive = (professionalState is LoadedModeProState) && professionalState.isProModeActive;
|
||||||
is LoadedModeProState) &&
|
isProModeActive ? Navigator.push(context,
|
||||||
professionalState.isProModeActive;
|
|
||||||
isProModeActive
|
|
||||||
? Navigator.push(context,
|
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const ProfessionalScoreListScreen();
|
return const ProfessionalScoreListScreen();
|
||||||
@@ -390,17 +378,11 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
if (myUserState.status == MyUserStatus.success) {
|
if (myUserState.status == MyUserStatus.success) {
|
||||||
final user = myUserState.user!;
|
final user = myUserState.user!;
|
||||||
|
|
||||||
if (user.name != null &&
|
if (user.name != null && user.email != null && user.city != null && user.phone != null) {
|
||||||
user.email != null &&
|
|
||||||
user.city != null &&
|
|
||||||
user.phone != null) {
|
|
||||||
switch (user.proState) {
|
switch (user.proState) {
|
||||||
case ProState.active:
|
case ProState.active: Navigator.pop(context);
|
||||||
Navigator.pop(context);
|
|
||||||
|
|
||||||
context
|
context.read<ProfessionalBloc>().add(const SwitchProModeEvent());
|
||||||
.read<ProfessionalBloc>()
|
|
||||||
.add(const SwitchProModeEvent());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ProState.inactive:
|
case ProState.inactive:
|
||||||
@@ -415,8 +397,7 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => const ProfessionalPendingScreen(),
|
||||||
const ProfessionalPendingScreen(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@@ -424,8 +405,7 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => const ProfessionalDeniedScreen(),
|
||||||
const ProfessionalDeniedScreen(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ class _ProfessionalPendingServiceListScreenState
|
|||||||
|
|
||||||
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
||||||
|
|
||||||
serviceBloc.add(LoadPendingServicesForProfessional(
|
serviceBloc.add(LoadPendingServicesForProfessional(FirebaseAuth.instance.currentUser!.uid));
|
||||||
FirebaseAuth.instance.currentUser!.uid));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
|||||||
|
|
||||||
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
||||||
|
|
||||||
serviceBloc.add(LoadServicesForUser(FirebaseAuth.instance.currentUser!.uid));
|
serviceBloc
|
||||||
|
.add(LoadServicesForUser(FirebaseAuth.instance.currentUser!.uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -127,7 +128,9 @@ class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
|||||||
customStatus(service),
|
customStatus(service),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Text(
|
service.description.isEmpty
|
||||||
|
? Container()
|
||||||
|
: Text(
|
||||||
'"${service.description.trim()}"',
|
'"${service.description.trim()}"',
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _startTimer() {
|
||||||
|
_timer = Timer.periodic(const Duration(minutes: 5), (timer) {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _loadSettings() {
|
void _loadSettings() {
|
||||||
settingRepository.getSettings().then(
|
settingRepository.getSettings().then(
|
||||||
(value) => setState(() {
|
(value) => setState(() {
|
||||||
@@ -54,12 +60,6 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startTimer() {
|
|
||||||
_timer = Timer.periodic(const Duration(minutes: 5), (timer) {
|
|
||||||
setState(() {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider<ServiceBloc>(
|
return BlocProvider<ServiceBloc>(
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import 'package:user_repository/user_repository.dart';
|
|||||||
|
|
||||||
class UserServiceScreen extends StatefulWidget {
|
class UserServiceScreen extends StatefulWidget {
|
||||||
final String serviceId;
|
final String serviceId;
|
||||||
const UserServiceScreen({Key? key, required this.serviceId})
|
const UserServiceScreen({super.key, required this.serviceId});
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<UserServiceScreen> createState() => _UserServiceScreenState();
|
State<UserServiceScreen> createState() => _UserServiceScreenState();
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ class FirebaseServiceRepository {
|
|||||||
final serviceCollection = FirebaseFirestore.instance.collection('services');
|
final serviceCollection = FirebaseFirestore.instance.collection('services');
|
||||||
|
|
||||||
Future<String> createService(ServiceEntity entity) async {
|
Future<String> createService(ServiceEntity entity) async {
|
||||||
DocumentReference<Map<String, dynamic>> docRef = await serviceCollection.add(entity.toDocument());
|
DocumentReference<Map<String, dynamic>> docRef =
|
||||||
|
await serviceCollection.add(entity.toDocument());
|
||||||
return docRef.id;
|
return docRef.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +80,7 @@ class FirebaseServiceRepository {
|
|||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<List<ServiceEntity>> getPendingServicesForProfessional(
|
Stream<List<ServiceEntity>> getPendingServicesForProfessional(String professionalId) {
|
||||||
String professionalId) {
|
|
||||||
return serviceCollection
|
return serviceCollection
|
||||||
.where('professional_id', isEqualTo: professionalId)
|
.where('professional_id', isEqualTo: professionalId)
|
||||||
.where('status', whereIn: [0])
|
.where('status', whereIn: [0])
|
||||||
|
|||||||
Reference in New Issue
Block a user