2023-02-15 23:02:29 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:smoke_cess_app/widgets/slider.dart';
|
2023-02-15 23:28:19 +01:00
|
|
|
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
|
|
|
|
import 'package:smoke_cess_app/widgets/text_formfield.dart';
|
2023-02-15 23:02:29 +01:00
|
|
|
|
|
|
|
class MoodForm extends StatefulWidget {
|
|
|
|
const MoodForm({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MoodForm> createState() => _MoodFormState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MoodFormState extends State<MoodForm> {
|
|
|
|
final GlobalKey<FormState> _moodFormKey = GlobalKey<FormState>();
|
2023-02-16 12:00:02 +01:00
|
|
|
MySlider slider = const MySlider('Bewerte deine Stimmung');
|
2023-02-15 23:02:29 +01:00
|
|
|
String _textInput = "";
|
2023-02-15 23:28:19 +01:00
|
|
|
|
|
|
|
void submitForm() {
|
|
|
|
if (_moodFormKey.currentState!.validate()) {
|
|
|
|
_moodFormKey.currentState?.save(); //call every onSave Method
|
|
|
|
//TODO Businesslogik aufrufen!
|
|
|
|
print(_textInput);
|
|
|
|
print(slider.getSliderValue());
|
|
|
|
_moodFormKey.currentState?.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onFormFieldSave(String? newValue) => _textInput = newValue!;
|
|
|
|
|
2023-02-15 23:02:29 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Form(
|
|
|
|
key: _moodFormKey,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
slider,
|
2023-02-16 12:00:02 +01:00
|
|
|
MyTextFormField('Beschreibe deine Stimmung', onFormFieldSave),
|
2023-02-15 23:28:19 +01:00
|
|
|
SubmitFormButton(submitForm)
|
2023-02-15 23:02:29 +01:00
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|