prosapp_web_app has chat, dashboard, calendar, support, 13 providers and Fluro URL routing. Keep Dockerfile + nginx.conf from previous prosappweb. Upgrade google_fonts 6.2.1 → 8.1.0 (Dart 3.12 compat fix). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
156 lines
6.0 KiB
Dart
156 lines
6.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:prosapp_web_app/models/schedules_entity.dart';
|
|
import 'package:prosapp_web_app/models/service.dart';
|
|
import 'package:prosapp_web_app/models/service_status.dart';
|
|
import 'package:prosapp_web_app/services/navigation_service.dart';
|
|
import 'package:prosapp_web_app/ui/labels/custom_labels.dart';
|
|
import 'package:prosapp_web_app/ui/shared/widgets/status_item.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
import 'package:prosapp_web_app/providers/auth_provider.dart';
|
|
import 'package:prosapp_web_app/providers/services_provider.dart';
|
|
|
|
import 'package:prosapp_web_app/ui/cards/white_card.dart';
|
|
|
|
class ServicesView extends StatelessWidget {
|
|
final String type;
|
|
|
|
const ServicesView({super.key, required this.type});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final servicesProvider =
|
|
Provider.of<ServicesProvider>(context, listen: false);
|
|
|
|
if (type == 'user') {
|
|
servicesProvider.getServicesForUser(
|
|
Provider.of<AuthProvider>(context, listen: false).user!.id);
|
|
}
|
|
if (type == 'professional') {
|
|
servicesProvider.getServicesForProfessional(
|
|
Provider.of<AuthProvider>(context, listen: false).user!.id);
|
|
}
|
|
|
|
return Center(
|
|
child: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 900),
|
|
child: Consumer<ServicesProvider>(
|
|
builder: (context, servicesProvider, child) {
|
|
if (servicesProvider.isLoading) {
|
|
return const Center(
|
|
child: CircularProgressIndicator(),
|
|
);
|
|
}
|
|
|
|
if (servicesProvider.services.isEmpty) {
|
|
return ListView(
|
|
children: const [
|
|
WhiteCard(
|
|
child: Center(child: Text('No hay servicios disponibles.')),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
return ListView.builder(
|
|
itemCount: servicesProvider.services.length,
|
|
itemBuilder: (context, index) {
|
|
final data = servicesProvider.services[index];
|
|
|
|
final image =
|
|
(data.user.picture == '' || data.user.picture == null)
|
|
? const Image(image: AssetImage('no-image.jpg'))
|
|
: FadeInImage.assetNetwork(
|
|
placeholder: 'loader.gif',
|
|
fit: BoxFit.cover,
|
|
image: data.user.picture!,
|
|
);
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.only(bottom: 10),
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
NavigationService.replaceTo(
|
|
'/dashboard/$type/service/${data.service.id}');
|
|
},
|
|
child: WhiteCard(
|
|
child: Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 10),
|
|
child: SizedBox(
|
|
width: 80,
|
|
height: 80,
|
|
child: ClipOval(
|
|
child: image,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 20),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
data.user.name,
|
|
style: CustomLabels.h2,
|
|
),
|
|
if (data.service.description != '')
|
|
Text(
|
|
'"${data.service.description}"',
|
|
style: CustomLabels.h5,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 10),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
'${ScheduleEntity.getFormatTime(data.service.range1Hour1)} - ${DateFormat('dd MMMM yyyy', 'es').format(DateTime.parse(data.service.day))}',
|
|
style: const TextStyle(
|
|
color: Colors.black54, fontSize: 16),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
vertical: 10),
|
|
child: customStatus(data.service),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget customStatus(Service service) {
|
|
if (service.status == ServiceStatus.pending) {
|
|
return const StatusItem(text: 'Pendiente', color: Colors.black54);
|
|
}
|
|
if (service.status == ServiceStatus.acepted) {
|
|
return const StatusItem(text: 'Aceptado', color: Colors.green);
|
|
}
|
|
if (service.status == ServiceStatus.active) {
|
|
return const StatusItem(text: 'Activo', color: Colors.blueAccent);
|
|
}
|
|
|
|
return const SizedBox();
|
|
}
|