Add AwesomeDialog
parent
d18d484932
commit
5b411ef6bf
|
@ -1,8 +1,8 @@
|
||||||
|
import 'package:awesome_dialog/awesome_dialog.dart';
|
||||||
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/pages/pages_service.dart';
|
import 'package:smoke_cess_app/pages/pages_service.dart';
|
||||||
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
||||||
import 'package:smoke_cess_app/widgets/missing_config_popup.dart';
|
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({super.key});
|
const MyHomePage({super.key});
|
||||||
|
@ -19,14 +19,12 @@ class MyHomePageState extends State<MyHomePage> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isConfigured
|
_isConfigured
|
||||||
? _selectedIndex = index
|
? _selectedIndex = index
|
||||||
: showDialog(
|
: AwesomeDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
dialogType: DialogType.info,
|
||||||
return const MissingConfigPopup(
|
|
||||||
title: 'Fehlende Konfiguration',
|
title: 'Fehlende Konfiguration',
|
||||||
text: 'Bitte QR Code Scannen!',
|
desc: 'Bitte QR Code Scannen!',
|
||||||
);
|
).show();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,11 @@ class InputProvider extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveMood() {
|
Future<int> saveMood() {
|
||||||
Mood mood =
|
Mood mood =
|
||||||
Mood(_sliderValue.toInt(), _textController.text, DateTime.now());
|
Mood(_sliderValue.toInt(), _textController.text, DateTime.now());
|
||||||
globals.databaseService.addMood(mood);
|
|
||||||
_resetFields();
|
_resetFields();
|
||||||
|
return globals.databaseService.addMood(mood);
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveRelapse() {
|
void saveRelapse() {
|
||||||
|
|
|
@ -30,9 +30,8 @@ class MoodForm extends StatelessWidget {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 80,
|
height: 80,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
SubmitFormButton(
|
||||||
onPressed: () => inputModel.saveMood(),
|
submitCallback: inputModel.saveMood,
|
||||||
child: const Text('Speichern'),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,15 +1,31 @@
|
||||||
|
import 'package:awesome_dialog/awesome_dialog.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SubmitFormButton extends StatelessWidget {
|
class SubmitFormButton extends StatelessWidget {
|
||||||
final VoidCallback submitCallback;
|
final Future<int> Function() submitCallback;
|
||||||
const SubmitFormButton(this.submitCallback, {super.key});
|
const SubmitFormButton({super.key, required this.submitCallback});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: ElevatedButton(
|
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'),
|
child: const Text('Speichern'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
21
pubspec.lock
21
pubspec.lock
|
@ -64,6 +64,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
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:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -177,6 +184,13 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
graphs:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: graphs
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -324,6 +338,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.5"
|
version: "6.0.5"
|
||||||
|
rive:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: rive
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.1"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -35,6 +35,7 @@ dependencies:
|
||||||
path:
|
path:
|
||||||
path_provider: ^2.0.12
|
path_provider: ^2.0.12
|
||||||
provider: ^6.0.5
|
provider: ^6.0.5
|
||||||
|
awesome_dialog: ^3.0.2
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|
Loading…
Reference in New Issue