Files
prosappco/lib/screens/professional/professional_calendar_screen.dart
T
2024-03-19 22:00:48 -05:00

142 lines
4.2 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';
class ProfessionalCalendarScreen extends StatefulWidget {
const ProfessionalCalendarScreen({super.key});
@override
State<ProfessionalCalendarScreen> createState() =>
_ProfessionalCalendarScreenState();
}
class _ProfessionalCalendarScreenState
extends State<ProfessionalCalendarScreen> {
TextEditingController _titleController = TextEditingController();
TextEditingController _descriptionController = TextEditingController();
DateTime today = DateTime.now();
DateTime now = DateTime.now();
CalendarFormat _calendarFormat = CalendarFormat.month;
TimeOfDay? _selectedTime1;
TimeOfDay? _selectedTime2;
Future<TimeOfDay?> _selectTime1(BuildContext context) async {
final TimeOfDay? pickedTime1 = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
if (pickedTime1 != null) {
setState(() {
_selectedTime1 = pickedTime1;
});
}
return pickedTime1;
}
Future<TimeOfDay?> _selectTime2(BuildContext context) async {
final TimeOfDay? pickedTime2 = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
if (pickedTime2 != null) {
setState(() {
_selectedTime2 = pickedTime2;
});
}
return pickedTime2;
}
void _onDaySelected(DateTime day, DateTime focusedDay) {
setState(() {
today = day;
});
}
void _onFormatChange(CalendarFormat format) {
setState(() {
_calendarFormat = format;
});
}
@override
Widget build(BuildContext context) {
DateTime lastDay = today.add(const Duration(days: 365));
return Scaffold(
appBar: AppBar(
title: const Text('Calendario'),
),
floatingActionButtonLocation: kIsWeb
? FloatingActionButtonLocation.startFloat
: FloatingActionButtonLocation.endFloat,
resizeToAvoidBottomInset: false,
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,
eventLoader: (date) {
return [];
// return events
// .where((element) {
// DateTime day = DateTime.parse(element.day);
// return (date.year == day.year &&
// date.month == day.month &&
// date.day == day.day);
// })
// .map((e) => e.description)
// .toList();
},
availableCalendarFormats: const {
CalendarFormat.month: 'Mes',
CalendarFormat.week: 'Semana',
CalendarFormat.twoWeeks: '2 Semanas',
},
),
),
// SizedBox(
// width: double.infinity,
// child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
// child: Text(DateFormat('dd MMMM yyyy', 'es').format(today),
// style: const TextStyle(
// color: Colors.black,
// fontSize: 16,
// fontWeight: FontWeight.w600,
// )),
// ),
// ),
const Divider(
height: 0,
),
Expanded(
child: SingleChildScrollView(
padding: const EdgeInsets.only(bottom: 15),
child: Column(
children: const [],
),
),
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
// onPressed: _showDialog,
child: const Icon(Icons.add),
),
);
}
}