cpd_2022_zi/lib/widgets/sleep_form.dart

55 lines
1.7 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2023-02-26 14:59:37 +01:00
import 'package:provider/provider.dart';
2023-03-02 20:16:46 +01:00
import 'package:smoke_cess_app/providers/tasks_provider.dart';
2023-02-17 11:35:05 +01:00
import 'package:smoke_cess_app/widgets/elevated_card.dart';
import 'package:smoke_cess_app/widgets/slider.dart';
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
import 'package:smoke_cess_app/widgets/text_formfield.dart';
2023-02-17 11:35:05 +01:00
import 'package:smoke_cess_app/widgets/timepicker.dart';
2023-02-26 14:59:37 +01:00
import '../providers/input_provider.dart';
2023-03-02 20:16:46 +01:00
import '../services/pages_service.dart';
2023-02-26 14:59:37 +01:00
2023-02-26 17:07:38 +01:00
class SleepForm extends StatelessWidget {
2023-02-20 23:59:40 +01:00
const SleepForm({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
2023-02-26 17:07:38 +01:00
InputProvider inputModel = context.watch<InputProvider>();
2023-03-02 20:16:46 +01:00
TasksProvider tasksModel = context.watch<TasksProvider>();
2023-02-26 17:07:38 +01:00
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2023-03-04 18:02:27 +01:00
const ElevatedCard(
2023-02-26 17:07:38 +01:00
title: 'Einschlafzeit',
2023-03-04 18:02:27 +01:00
child: TimePicker(SleepTimes.sleptAt),
2023-02-26 17:07:38 +01:00
),
const SizedBox(height: 16),
2023-03-04 18:02:27 +01:00
const ElevatedCard(
2023-02-26 17:07:38 +01:00
title: 'Aufwachzeit',
2023-03-04 18:02:27 +01:00
child: TimePicker(SleepTimes.wokeUpAt),
2023-02-26 17:07:38 +01:00
),
const SizedBox(height: 16),
const ElevatedCard(
title: 'Schlafbewertung',
child: MySlider(),
),
const SizedBox(height: 16),
const ElevatedCard(
title: 'Schlafbeschreibung',
child: MyTextFormField('Beschreibe deinen Schlaf'),
),
const SizedBox(
height: 80,
),
SubmitFormButton(
2023-03-04 18:02:27 +01:00
submitCallback: () =>
inputModel.saveSleep(SleepTimes.wokeUpAt, SleepTimes.sleptAt),
2023-03-02 20:33:44 +01:00
updateTasks: () => tasksModel.setTaskDone(Pages.mood),
)
2023-02-26 17:07:38 +01:00
],
2023-02-20 23:59:40 +01:00
);
}
}