This commit is contained in:
Juan Felipe Duarte
2023-06-26 17:38:13 -05:00
parent 580d1eeba0
commit 352bb40145
7 changed files with 197 additions and 60 deletions
+5 -18
View File
@@ -5,24 +5,11 @@ import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/components/primary_btn.dart';
import '../components/schedule_picker.dart';
class HorarioScreen extends StatefulWidget {
class HorarioScreen extends StatelessWidget {
Map<String, Schedule> horarios;
HorarioScreen({super.key, required this.horarios});
@override
State<HorarioScreen> createState() => _HorarioScreenState();
}
class _HorarioScreenState extends State<HorarioScreen> {
final uid = AuthenticationRepository.instance.getCurrentUserUid();
@override
void initState() {
super.initState();
print('horario a ${widget.horarios}');
}
bool lunesValue = false;
bool martesValue = false;
bool miercolesValue = false;
@@ -32,10 +19,10 @@ class _HorarioScreenState extends State<HorarioScreen> {
bool domingoValue = false;
bool jornadaContinuaLunes = false;
Future<void> updateHorario() async {
Future<void> updateHorario(BuildContext context) async {
try {
Map<String, dynamic> horariosMap = {};
widget.horarios.forEach((key, value) {
horarios.forEach((key, value) {
horariosMap[key] = {
'habilitado': value.habilitado,
'jornadaContinua': value.jornadaContinua,
@@ -87,7 +74,7 @@ class _HorarioScreenState extends State<HorarioScreen> {
@override
Widget build(BuildContext context) {
final sortedHorarios = Map.fromEntries(
widget.horarios.entries.toList()
horarios.entries.toList()
..sort(
(a, b) => _dayOfWeekToInt(a.key).compareTo(_dayOfWeekToInt(b.key))),
);
@@ -118,7 +105,7 @@ class _HorarioScreenState extends State<HorarioScreen> {
padding: const EdgeInsets.only(top: 30, bottom: 30),
child: PrimaryButtom(
onPressed: () async {
await updateHorario();
await updateHorario(context);
Navigator.pop(context);
},
label: 'Guardar',