historial y pendientes
This commit is contained in:
@@ -78,12 +78,20 @@ class _ProfessionListScreenState extends State<ProfessionListScreen> {
|
||||
itemCount: _filteredProfessions!.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final profession = _filteredProfessions![index];
|
||||
return ListTile(
|
||||
title: Text(profession),
|
||||
onTap: () {
|
||||
Navigator.pop(
|
||||
context, _filteredProfessions![index]);
|
||||
},
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(profession),
|
||||
onTap: () {
|
||||
Navigator.pop(
|
||||
context, _filteredProfessions![index]);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
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 ProfessionalServiceHistoryListScreen extends StatefulWidget {
|
||||
const ProfessionalServiceHistoryListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfessionalServiceHistoryListScreen> createState() =>
|
||||
_ProfessionalServiceHistoryListScreenState();
|
||||
}
|
||||
|
||||
class _ProfessionalServiceHistoryListScreenState
|
||||
extends State<ProfessionalServiceHistoryListScreen> {
|
||||
late final ServiceBloc serviceBloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
||||
|
||||
serviceBloc.add(
|
||||
LoadServicesHistoryForUser(FirebaseAuth.instance.currentUser!.uid));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ServiceBloc>(
|
||||
create: (context) => serviceBloc,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Historial'),
|
||||
),
|
||||
body: BlocBuilder<ServiceBloc, ServiceState>(
|
||||
builder: (context, serviceState) {
|
||||
if (serviceState is ServicesForUserLoaded) {
|
||||
return serviceState.services.isEmpty
|
||||
? const Center(
|
||||
child: Text('No tienes servicios'),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: serviceState.services.length,
|
||||
itemBuilder: (_, index) {
|
||||
final serviceInfo = serviceState.services[index];
|
||||
final user = serviceInfo.user;
|
||||
final professional = serviceInfo.professional;
|
||||
final service = serviceInfo.service;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {},
|
||||
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: [
|
||||
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: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'Estado:',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
customStatus(service),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'"${service.description.trim()}"',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container customStatus(ServiceEntity service) {
|
||||
if (service.status == ServiceStatus.completed) {
|
||||
return itemStatus(Colors.blueAccent, 'Completado');
|
||||
}
|
||||
if (service.status == ServiceStatus.cancelled) {
|
||||
return itemStatus(Colors.red, 'Cancelado');
|
||||
}
|
||||
|
||||
return itemStatus(Colors.red, 'Cancelado');
|
||||
}
|
||||
|
||||
Container itemStatus(Color color, String text) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// pending - 0
|
||||
// acepted - 1
|
||||
// active - 2
|
||||
// cancelled - 3
|
||||
// completed - 4
|
||||
@@ -1,16 +1,204 @@
|
||||
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 UserServiceHistoryScreen extends StatefulWidget {
|
||||
const UserServiceHistoryScreen({super.key});
|
||||
class UserServiceHistoryListScreen extends StatefulWidget {
|
||||
const UserServiceHistoryListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<UserServiceHistoryScreen> createState() =>
|
||||
_UserServiceHistoryScreenState();
|
||||
State<UserServiceHistoryListScreen> createState() =>
|
||||
_UserServiceHistoryListScreenState();
|
||||
}
|
||||
|
||||
class _UserServiceHistoryScreenState extends State<UserServiceHistoryScreen> {
|
||||
class _UserServiceHistoryListScreenState
|
||||
extends State<UserServiceHistoryListScreen> {
|
||||
late final ServiceBloc serviceBloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
||||
|
||||
serviceBloc.add(
|
||||
LoadServicesHistoryForUser(FirebaseAuth.instance.currentUser!.uid));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
return BlocProvider<ServiceBloc>(
|
||||
create: (context) => serviceBloc,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Historial'),
|
||||
),
|
||||
body: BlocBuilder<ServiceBloc, ServiceState>(
|
||||
builder: (context, serviceState) {
|
||||
if (serviceState is ServicesForUserLoaded) {
|
||||
return serviceState.services.isEmpty
|
||||
? const Center(
|
||||
child: Text('No tienes servicios'),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: serviceState.services.length,
|
||||
itemBuilder: (_, index) {
|
||||
final serviceInfo = serviceState.services[index];
|
||||
final user = serviceInfo.user;
|
||||
final professional = serviceInfo.professional;
|
||||
final service = serviceInfo.service;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {},
|
||||
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: [
|
||||
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: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'Estado:',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
customStatus(service),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'"${service.description.trim()}"',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container customStatus(ServiceEntity service) {
|
||||
if (service.status == ServiceStatus.completed) {
|
||||
return itemStatus(Colors.blueAccent, 'Completado');
|
||||
}
|
||||
if (service.status == ServiceStatus.cancelled) {
|
||||
return itemStatus(Colors.red, 'Cancelado');
|
||||
}
|
||||
|
||||
return itemStatus(Colors.red, 'Cancelado');
|
||||
}
|
||||
|
||||
Container itemStatus(Color color, String text) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// pending - 0
|
||||
// acepted - 1
|
||||
// active - 2
|
||||
// cancelled - 3
|
||||
// completed - 4
|
||||
@@ -52,68 +52,78 @@ class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
||||
final professional = serviceInfo.professional;
|
||||
final service = serviceInfo.service;
|
||||
|
||||
return ListTile(
|
||||
onTap: () {},
|
||||
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,
|
||||
),
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
child: user.picture == null
|
||||
? Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.grey.shade400,
|
||||
size: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${user.name}',
|
||||
child: ListTile(
|
||||
onTap: () {},
|
||||
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: [
|
||||
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: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'Estado:',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
customStatus(service),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'"${service.description.trim()}"',
|
||||
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),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -153,48 +163,43 @@ class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Text customStatus(ServiceEntity service) {
|
||||
Container customStatus(ServiceEntity service) {
|
||||
if (service.status == ServiceStatus.pending) {
|
||||
return const Text(
|
||||
'Pendiente',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.white,
|
||||
),
|
||||
);
|
||||
return itemStatus(Colors.black54, 'Pendiente');
|
||||
}
|
||||
|
||||
if (service.status == ServiceStatus.acepted) {
|
||||
return const Text(
|
||||
'Aceptado',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.white,
|
||||
),
|
||||
);
|
||||
return itemStatus(Colors.green, 'Aceptado');
|
||||
}
|
||||
if (service.status == ServiceStatus.active) {
|
||||
return const Text(
|
||||
'Activo',
|
||||
style: TextStyle(
|
||||
return itemStatus(Colors.blueAccent, 'Activo');
|
||||
}
|
||||
|
||||
return itemStatus(Colors.red, 'Cancelado');
|
||||
}
|
||||
|
||||
Container itemStatus(Color color, String text) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.white,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return const Text(
|
||||
'Cancelado',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.white,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// pending
|
||||
// acepted
|
||||
// active
|
||||
// cancelled
|
||||
// completed
|
||||
// pending - 0
|
||||
// acepted - 1
|
||||
// active - 2
|
||||
// cancelled - 3
|
||||
// completed - 4
|
||||
Reference in New Issue
Block a user