traer solo los activos aceptados y pendientes
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
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:injector/injector.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:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
import 'package:service_repository/service_repository.dart';
|
||||||
|
import 'package:shimmer/shimmer.dart';
|
||||||
|
|
||||||
class UserServiceListScreen extends StatefulWidget {
|
class UserServiceListScreen extends StatefulWidget {
|
||||||
const UserServiceListScreen({super.key});
|
const UserServiceListScreen({super.key});
|
||||||
@@ -49,11 +54,65 @@ class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
|||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {},
|
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: [
|
children: [
|
||||||
Text(user.name ?? ''),
|
Flexible(
|
||||||
Text(professional.identification),
|
child: Text(
|
||||||
Text(service.address),
|
'${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(
|
return Shimmer.fromColors(
|
||||||
child: CircularProgressIndicator(),
|
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) {
|
Stream<List<ServiceEntity>> getServicesForUser(String userId) {
|
||||||
return serviceCollection
|
return serviceCollection
|
||||||
.where('user_id', isEqualTo: userId)
|
.where('user_id', isEqualTo: userId)
|
||||||
|
.where('status', whereIn: [0, 1, 2])
|
||||||
.snapshots()
|
.snapshots()
|
||||||
.map((querySnapshot) => querySnapshot.docs
|
.map((querySnapshot) => querySnapshot.docs
|
||||||
.map((doc) => ServiceEntity.fromDocument(doc.data()))
|
.map((doc) => ServiceEntity.fromDocument(doc.data()))
|
||||||
|
|||||||
Reference in New Issue
Block a user