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 {
|
try {
|
||||||
var snapshot = await FirebaseFirestore.instance
|
var snapshot = await FirebaseFirestore.instance
|
||||||
.collection('services')
|
.collection('services')
|
||||||
.where('profesional_id', isEqualTo: uid)
|
.where('profesional_id', isEqualTo: uid)
|
||||||
|
.where('day', isEqualTo: day.toString())
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
List<Event> eventos = [];
|
List<Event> eventos = [];
|
||||||
for (var element in snapshot.docs) {
|
for (var element in snapshot.docs) {
|
||||||
eventos.add(Event.fromJson(element.data()));
|
eventos.add(Event.fromJson(element.data()));
|
||||||
}
|
}
|
||||||
print('Error getByProId $eventos');
|
print('Error getByProId 1 $eventos');
|
||||||
return eventos;
|
return eventos;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error getByProId $e');
|
print('Error getByProId $e');
|
||||||
|
|||||||
@@ -78,31 +78,39 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
|||||||
},
|
},
|
||||||
label: 'Calendario',
|
label: 'Calendario',
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Column(
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Container(
|
||||||
Container(
|
color: const Color.fromARGB(255, 224, 247, 255),
|
||||||
color: const Color.fromARGB(255, 224, 247, 255),
|
child: TableCalendar(
|
||||||
child: TableCalendar(
|
locale: 'es_MX',
|
||||||
locale: 'es_MX',
|
firstDay: DateTime.utc(2010, 10, 16),
|
||||||
firstDay: DateTime.utc(2010, 10, 16),
|
lastDay: lastDay,
|
||||||
lastDay: lastDay,
|
focusedDay: today,
|
||||||
focusedDay: today,
|
availableGestures: AvailableGestures.all,
|
||||||
availableGestures: AvailableGestures.all,
|
onDaySelected: _onDaySelected,
|
||||||
onDaySelected: _onDaySelected,
|
selectedDayPredicate: (day) => isSameDay(day, today),
|
||||||
selectedDayPredicate: (day) => isSameDay(day, today),
|
calendarFormat: _calendarFormat,
|
||||||
calendarFormat: _calendarFormat,
|
onFormatChanged: _onFormatChange,
|
||||||
onFormatChanged: _onFormatChange,
|
availableCalendarFormats: const {
|
||||||
availableCalendarFormats: const {
|
CalendarFormat.month: 'Mes',
|
||||||
CalendarFormat.month: 'Mes',
|
CalendarFormat.week: 'Semana',
|
||||||
CalendarFormat.week: 'Semana',
|
CalendarFormat.twoWeeks: '2 Semanas',
|
||||||
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(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: _showDialog,
|
onPressed: _showDialog,
|
||||||
@@ -271,7 +279,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
|||||||
|
|
||||||
Widget _eventList() {
|
Widget _eventList() {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: getByProId(),
|
future:
|
||||||
|
getByProId('${DateFormat("yyyy-MM-dd 00:00:00.000").format(today)}Z'),
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return const Text('No tiene citas');
|
return const Text('No tiene citas');
|
||||||
@@ -286,15 +295,43 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (eventos.isEmpty) {
|
if (eventos.isEmpty) {
|
||||||
return const Text('No tiene citas');
|
return const Center(child: Text('No tienes citas'));
|
||||||
}
|
}
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
...eventos.map(
|
...eventos.map(
|
||||||
(e) => ListTile(
|
(e) => ListTile(
|
||||||
leading: Text('${e.range1Hour1}'),
|
leading: Text('${e.range1Hour1}'),
|
||||||
title: Text('${e.title}'),
|
title: RichText(
|
||||||
trailing: Text('${e.day}'),
|
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