cpd_2022_zi/lib/widgets/sleep_form.dart

55 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/providers/tasks_provider.dart';
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';
import 'package:smoke_cess_app/widgets/timepicker.dart';
import '../providers/input_provider.dart';
import '../services/pages_service.dart';
class SleepForm extends StatelessWidget {
const SleepForm({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
InputProvider inputModel = context.watch<InputProvider>();
TasksProvider tasksModel = context.watch<TasksProvider>();
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const ElevatedCard(
title: 'Einschlafzeit',
child: TimePicker(SleepTimes.sleptAt),
),
const SizedBox(height: 16),
const ElevatedCard(
title: 'Aufwachzeit',
child: TimePicker(SleepTimes.wokeUpAt),
),
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(
submitCallback: () =>
inputModel.saveSleep(SleepTimes.wokeUpAt, SleepTimes.sleptAt),
updateTasks: () => tasksModel.setTaskDone(Pages.mood),
)
],
);
}
}