traer solo los activos aceptados y pendientes

This commit is contained in:
Felipe
2024-04-06 11:40:19 -05:00
parent df9f44a8f2
commit d9c5e97dbc
3 changed files with 151 additions and 6 deletions
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
class UserServiceHistoryScreen extends StatefulWidget {
const UserServiceHistoryScreen({super.key});
@override
State<UserServiceHistoryScreen> createState() =>
_UserServiceHistoryScreenState();
}
class _UserServiceHistoryScreenState extends State<UserServiceHistoryScreen> {
@override
Widget build(BuildContext context) {
return Container();
}
}
+134 -6
View File
@@ -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<UserServiceListScreen> {
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<UserServiceListScreen> {
);
}
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
@@ -31,6 +31,7 @@ class FirebaseServiceRepository {
Stream<List<ServiceEntity>> 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()))