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