citas con dia

This commit is contained in:
Juan Felipe Duarte
2023-04-25 09:02:09 -05:00
parent e071cbe2a5
commit 77cfb5cd4a
2 changed files with 68 additions and 30 deletions
+3 -2
View File
@@ -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');
+65 -28
View File
@@ -78,31 +78,39 @@ class _CalendarScreenState extends State<CalendarScreen> {
},
label: 'Calendario',
),
body: Container(
child: Column(
children: [
Container(
color: const Color.fromARGB(255, 224, 247, 255),
child: TableCalendar(
locale: 'es_MX',
firstDay: DateTime.utc(2010, 10, 16),
lastDay: lastDay,
focusedDay: today,
availableGestures: AvailableGestures.all,
onDaySelected: _onDaySelected,
selectedDayPredicate: (day) => isSameDay(day, today),
calendarFormat: _calendarFormat,
onFormatChanged: _onFormatChange,
availableCalendarFormats: const {
CalendarFormat.month: 'Mes',
CalendarFormat.week: 'Semana',
CalendarFormat.twoWeeks: '2 Semanas',
},
),
body: Column(
children: [
Container(
color: const Color.fromARGB(255, 224, 247, 255),
child: TableCalendar(
locale: 'es_MX',
firstDay: DateTime.utc(2010, 10, 16),
lastDay: lastDay,
focusedDay: today,
availableGestures: AvailableGestures.all,
onDaySelected: _onDaySelected,
selectedDayPredicate: (day) => isSameDay(day, today),
calendarFormat: _calendarFormat,
onFormatChanged: _onFormatChange,
availableCalendarFormats: const {
CalendarFormat.month: 'Mes',
CalendarFormat.week: 'Semana',
CalendarFormat.twoWeeks: '2 Semanas',
},
),
_eventList()
],
),
),
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,
@@ -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),
),
),
],