Added Submitformbutton to sleep and relapse
parent
5b411ef6bf
commit
591317df26
|
@ -51,17 +51,17 @@ class InputProvider extends ChangeNotifier {
|
|||
return globals.databaseService.addMood(mood);
|
||||
}
|
||||
|
||||
void saveRelapse() {
|
||||
Future<int> saveRelapse() {
|
||||
Relapse relapse =
|
||||
Relapse(_relapseCategory, _textController.text, DateTime.now());
|
||||
globals.databaseService.addRelapse(relapse);
|
||||
_resetFields();
|
||||
return globals.databaseService.addRelapse(relapse);
|
||||
}
|
||||
|
||||
void saveSleep(String wokeUpKey, String sleptKey) {
|
||||
Future<int> saveSleep(String wokeUpKey, String sleptKey) {
|
||||
Sleep sleep = Sleep(_sliderValue.toInt(), _textController.text,
|
||||
DateTime.now(), getTimeEntry(sleptKey), getTimeEntry(wokeUpKey));
|
||||
globals.databaseService.addSleep(sleep);
|
||||
_resetFields();
|
||||
return globals.databaseService.addSleep(sleep);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:smoke_cess_app/widgets/drop_down.dart';
|
||||
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
|
||||
import 'package:smoke_cess_app/widgets/text_formfield.dart';
|
||||
|
||||
import '../providers/input_provider.dart';
|
||||
|
@ -28,10 +29,7 @@ class RelapseForm extends StatelessWidget {
|
|||
const SizedBox(
|
||||
height: 80,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => inputModel.saveRelapse(),
|
||||
child: const Text('Speichern'),
|
||||
)
|
||||
SubmitFormButton(submitCallback: inputModel.saveRelapse)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:provider/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';
|
||||
|
||||
|
@ -41,9 +42,9 @@ class SleepForm extends StatelessWidget {
|
|||
const SizedBox(
|
||||
height: 80,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => inputModel.saveSleep(wokeUpKey, sleptKey),
|
||||
child: const Text('Speichern'))
|
||||
SubmitFormButton(
|
||||
submitCallback: () => inputModel.saveSleep(wokeUpKey, sleptKey),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue