162 lines
5.2 KiB
Dart
162 lines
5.2 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:prosappco/src/components/drawer_professional.dart';
|
|
import 'package:prosappco/src/components/pop_appbar.dart';
|
|
import 'package:prosappco/src/models/event_model.dart';
|
|
import 'package:prosappco/src/screens/cita.dart';
|
|
|
|
class MyServicesScreen extends StatefulWidget {
|
|
MyServicesScreen({super.key});
|
|
|
|
@override
|
|
State<MyServicesScreen> createState() => _MyServicesScreenState();
|
|
}
|
|
|
|
class _MyServicesScreenState extends State<MyServicesScreen> {
|
|
DateTime today = DateTime.now();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
child: Scaffold(
|
|
appBar: PopAppbar(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
label: 'Mis servicios'),
|
|
drawer: DrawerProfessional(),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
_eventList(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _eventList() {
|
|
return FutureBuilder(
|
|
future: getByUserIdAll('aprobado', 'denegado'),
|
|
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
|
if (!snapshot.hasData) {
|
|
return const Center(
|
|
child: CircularProgressIndicator(),
|
|
);
|
|
}
|
|
|
|
List<Event> eventos = [];
|
|
|
|
try {
|
|
eventos.addAll(snapshot.data!);
|
|
} catch (e) {
|
|
print("Error" + e.toString());
|
|
}
|
|
|
|
if (eventos.isEmpty) {
|
|
return const Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 50),
|
|
child: Center(child: Text('No tienes citas')),
|
|
);
|
|
}
|
|
return Column(
|
|
children: [
|
|
...eventos.map(
|
|
(event) => ListTile(
|
|
tileColor: event.status == 'aprobado'
|
|
? Colors.blue[100]
|
|
: Colors.red[100],
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (BuildContext context) {
|
|
return CitaScreen(evento: event);
|
|
},
|
|
),
|
|
);
|
|
},
|
|
leading: event.status == 'aprobado'
|
|
? const Icon(
|
|
Icons.check,
|
|
color: Colors.blue,
|
|
size: 40,
|
|
)
|
|
: const Icon(
|
|
Icons.close,
|
|
color: Colors.red,
|
|
size: 40,
|
|
),
|
|
title: RichText(
|
|
text: TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: '${event.title}, ',
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text:
|
|
'${DateFormat('dd MMM', 'es').format(DateTime.parse(event.day))} - ${event.range1Hour1}',
|
|
style: TextStyle(
|
|
color: Colors.grey[600],
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
RatingBar.builder(
|
|
initialRating: event.scoresModel?.average ?? 0,
|
|
minRating: 1,
|
|
direction: Axis.horizontal,
|
|
allowHalfRating: true,
|
|
itemCount: 5,
|
|
itemSize: 25,
|
|
maxRating: 5,
|
|
itemPadding:
|
|
const EdgeInsets.symmetric(horizontal: 0),
|
|
itemBuilder: (context, _) => const Icon(
|
|
Icons.star,
|
|
color: Color(0xFF2BA4EC),
|
|
),
|
|
onRatingUpdate: (rating) {},
|
|
ignoreGestures: true,
|
|
),
|
|
const SizedBox(width: 5),
|
|
Text(
|
|
'(${event.scoresModel?.total.toString()}) ${event.scoresModel?.average.toString()}'),
|
|
],
|
|
),
|
|
Text(
|
|
'" ${event.description}"',
|
|
style: const TextStyle(fontStyle: FontStyle.italic),
|
|
),
|
|
],
|
|
),
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|