Add AwesomeDialog

main
Kai Mannweiler 2023-02-27 20:02:15 +01:00
parent d18d484932
commit 5b411ef6bf
6 changed files with 51 additions and 16 deletions

View File

@ -1,8 +1,8 @@
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/pages/pages_service.dart';
import 'package:smoke_cess_app/providers/settings_provider.dart';
import 'package:smoke_cess_app/widgets/missing_config_popup.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@ -19,14 +19,12 @@ class MyHomePageState extends State<MyHomePage> {
setState(() {
_isConfigured
? _selectedIndex = index
: showDialog(
: AwesomeDialog(
context: context,
builder: (BuildContext context) {
return const MissingConfigPopup(
title: 'Fehlende Konfiguration',
text: 'Bitte QR Code Scannen!',
);
});
dialogType: DialogType.info,
title: 'Fehlende Konfiguration',
desc: 'Bitte QR Code Scannen!',
).show();
});
}

View File

@ -44,11 +44,11 @@ class InputProvider extends ChangeNotifier {
notifyListeners();
}
void saveMood() {
Future<int> saveMood() {
Mood mood =
Mood(_sliderValue.toInt(), _textController.text, DateTime.now());
globals.databaseService.addMood(mood);
_resetFields();
return globals.databaseService.addMood(mood);
}
void saveRelapse() {

View File

@ -30,9 +30,8 @@ class MoodForm extends StatelessWidget {
const SizedBox(
height: 80,
),
ElevatedButton(
onPressed: () => inputModel.saveMood(),
child: const Text('Speichern'),
SubmitFormButton(
submitCallback: inputModel.saveMood,
)
],
);

View File

@ -1,15 +1,31 @@
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
class SubmitFormButton extends StatelessWidget {
final VoidCallback submitCallback;
const SubmitFormButton(this.submitCallback, {super.key});
final Future<int> Function() submitCallback;
const SubmitFormButton({super.key, required this.submitCallback});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: submitCallback,
onPressed: () async {
int success = await submitCallback();
success != 0
? AwesomeDialog(
context: context,
dialogType: DialogType.success,
title: 'Gespeichert',
desc: 'Der Eintrag wurde erfolgreich gespeichert',
).show()
: AwesomeDialog(
context: context,
dialogType: DialogType.error,
title: 'Fehler',
desc: 'Der Eintrag konnte nicht gespeichert werden',
).show();
},
child: const Text('Speichern'),
),
);

View File

@ -64,6 +64,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
awesome_dialog:
dependency: "direct main"
description:
name: awesome_dialog
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
boolean_selector:
dependency: transitive
description:
@ -177,6 +184,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
http:
dependency: transitive
description:
@ -324,6 +338,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.5"
rive:
dependency: transitive
description:
name: rive
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.1"
shared_preferences:
dependency: "direct main"
description:

View File

@ -35,6 +35,7 @@ dependencies:
path:
path_provider: ^2.0.12
provider: ^6.0.5
awesome_dialog: ^3.0.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.