citas con dia
This commit is contained in:
@@ -30,18 +30,19 @@ class EventoService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Event>> getByProId() async {
|
||||
Future<List<Event>> getByProId(String day) async {
|
||||
try {
|
||||
var snapshot = await FirebaseFirestore.instance
|
||||
.collection('services')
|
||||
.where('profesional_id', isEqualTo: uid)
|
||||
.where('day', isEqualTo: day.toString())
|
||||
.get();
|
||||
|
||||
List<Event> eventos = [];
|
||||
for (var element in snapshot.docs) {
|
||||
eventos.add(Event.fromJson(element.data()));
|
||||
}
|
||||
print('Error getByProId $eventos');
|
||||
print('Error getByProId 1 $eventos');
|
||||
return eventos;
|
||||
} catch (e) {
|
||||
print('Error getByProId $e');
|
||||
|
||||
@@ -78,8 +78,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
},
|
||||
label: 'Calendario',
|
||||
),
|
||||
body: Container(
|
||||
child: Column(
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: const Color.fromARGB(255, 224, 247, 255),
|
||||
@@ -100,10 +99,19 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Text(DateFormat('dd MMMM yyyy', 'es').format(today)),
|
||||
)),
|
||||
const Divider(
|
||||
height: 0,
|
||||
),
|
||||
_eventList()
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _showDialog,
|
||||
child: const Icon(Icons.add),
|
||||
@@ -271,7 +279,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
|
||||
Widget _eventList() {
|
||||
return FutureBuilder(
|
||||
future: getByProId(),
|
||||
future:
|
||||
getByProId('${DateFormat("yyyy-MM-dd 00:00:00.000").format(today)}Z'),
|
||||
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const Text('No tiene citas');
|
||||
@@ -286,15 +295,43 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
}
|
||||
|
||||
if (eventos.isEmpty) {
|
||||
return const Text('No tiene citas');
|
||||
return const Center(child: Text('No tienes citas'));
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
...eventos.map(
|
||||
(e) => ListTile(
|
||||
leading: Text('${e.range1Hour1}'),
|
||||
title: Text('${e.title}'),
|
||||
trailing: Text('${e.day}'),
|
||||
title: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${e.title}, ',
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: DateFormat('dd MMMM yyyy', 'es')
|
||||
.format(DateTime.parse(e.day!)),
|
||||
style: TextStyle(
|
||||
color: Colors.grey[400],
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('${e.description}'),
|
||||
Text('${e.description}'),
|
||||
],
|
||||
),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user