diff --git a/lib/screens/lists/user_service_history_list_screen.dart b/lib/screens/lists/user_service_history_list_screen.dart new file mode 100644 index 0000000..e68729a --- /dev/null +++ b/lib/screens/lists/user_service_history_list_screen.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class UserServiceHistoryScreen extends StatefulWidget { + const UserServiceHistoryScreen({super.key}); + + @override + State createState() => + _UserServiceHistoryScreenState(); +} + +class _UserServiceHistoryScreenState extends State { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/screens/lists/user_service_list_screen.dart b/lib/screens/lists/user_service_list_screen.dart index e6fddec..e67db51 100644 --- a/lib/screens/lists/user_service_list_screen.dart +++ b/lib/screens/lists/user_service_list_screen.dart @@ -1,8 +1,13 @@ import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:injector/injector.dart'; +import 'package:intl/intl.dart'; +import 'package:professional_repository/professional_repository.dart'; import 'package:prosappco/blocs/service_bloc/service_bloc.dart'; +import 'package:service_repository/service_repository.dart'; +import 'package:shimmer/shimmer.dart'; class UserServiceListScreen extends StatefulWidget { const UserServiceListScreen({super.key}); @@ -49,11 +54,65 @@ class _UserServiceListScreenState extends State { return ListTile( onTap: () {}, - title: Column( + leading: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Colors.grey.shade300, + shape: BoxShape.circle, + image: user.picture == null + ? null + : DecorationImage( + image: NetworkImage(user.picture!), + fit: BoxFit.contain, + ), + ), + child: user.picture == null + ? Icon( + CupertinoIcons.person, + color: Colors.grey.shade400, + size: 40, + ) + : null, + ), + title: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(user.name ?? ''), - Text(professional.identification), - Text(service.address), + Flexible( + child: Text( + '${user.name}', + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontWeight: FontWeight.bold), + ), + ), + const SizedBox(width: 5), + Text( + '${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}', + style: TextStyle( + color: Colors.grey[600], + ), + ), + ], + ), + subtitle: Row( + children: [ + const Text( + 'Estado:', + style: TextStyle(fontStyle: FontStyle.italic), + ), + const SizedBox(width: 5), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 3, + ), + decoration: BoxDecoration( + color: Colors.blueAccent, + borderRadius: BorderRadius.circular(8), + ), + child: customStatus(service), + ), ], ), ); @@ -61,12 +120,81 @@ class _UserServiceListScreenState extends State { ); } - return const Center( - child: CircularProgressIndicator(), + return Shimmer.fromColors( + baseColor: Colors.grey[300]!, + highlightColor: Colors.grey[100]!, + child: ListView.builder( + itemCount: 10, + itemBuilder: (_, __) => ListTile( + leading: CircleAvatar( + backgroundColor: Colors.grey[300], + radius: 30, + ), + title: Container( + height: 20, + decoration: BoxDecoration( + color: Colors.grey.shade300, + borderRadius: BorderRadius.circular(8), + ), + ), + subtitle: Container( + height: 15, + decoration: BoxDecoration( + color: Colors.grey.shade300, + borderRadius: BorderRadius.circular(8), + ), + ), + ), + ), ); }, ), ), ); } + + Text customStatus(ServiceEntity service) { + if (service.status == ServiceStatus.pending) { + return const Text( + 'Pendiente', + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.white, + ), + ); + } + + if (service.status == ServiceStatus.acepted) { + return const Text( + 'Aceptado', + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.white, + ), + ); + } + if (service.status == ServiceStatus.active) { + return const Text( + 'Activo', + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.white, + ), + ); + } + + return const Text( + 'Cancelado', + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.white, + ), + ); + } } + +// pending +// acepted +// active +// cancelled +// completed \ No newline at end of file diff --git a/packages/service_repository/lib/src/repositories/firebase_service_repository.dart b/packages/service_repository/lib/src/repositories/firebase_service_repository.dart index 09c4571..57e7d84 100644 --- a/packages/service_repository/lib/src/repositories/firebase_service_repository.dart +++ b/packages/service_repository/lib/src/repositories/firebase_service_repository.dart @@ -31,6 +31,7 @@ class FirebaseServiceRepository { Stream> getServicesForUser(String userId) { return serviceCollection .where('user_id', isEqualTo: userId) + .where('status', whereIn: [0, 1, 2]) .snapshots() .map((querySnapshot) => querySnapshot.docs .map((doc) => ServiceEntity.fromDocument(doc.data()))