From be4f729cc09bb46960d85b056ce14bfafaaba1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Tue, 12 Apr 2022 21:20:22 +0200 Subject: [PATCH] =?UTF-8?q?Lep=C5=A1=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + lib/okna/burza.dart | 33 ++++++++++++++++++++++++++ lib/okna/home.dart | 34 +++++++++++++++++++------- pubspec.lock | 58 ++++++++++++++++++++++++++++++++++++++++++++- pubspec.yaml | 1 + 5 files changed, 118 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a344d9..fe32586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,5 +3,6 @@ - Přidáno odsazení od okrajů u jídelníčku - Domovská obrazovka nyní zobrazuje zprávu, pokud na dnešní den není žádné jídlo v jídelníčku - Upgrade knihovny +- Odhlášení přesunuto do textového menu # 0.1.0 - První verze \ No newline at end of file diff --git a/lib/okna/burza.dart b/lib/okna/burza.dart index 922e7aa..8294074 100644 --- a/lib/okna/burza.dart +++ b/lib/okna/burza.dart @@ -50,6 +50,39 @@ class _BurzaPageState extends State { TextButton( onPressed: () { widget.canteen.objednatZBurzy(b).then((a) { + if (a) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("Objednáno"), + content: const Text( + "Jídlo bylo úspěšně objednáno."), + actions: [ + TextButton( + child: const Text("OK"), + onPressed: () => + Navigator.of(context).pop(), + ) + ], + ), + ); + } else { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("Nelze objednat"), + content: const Text( + "Jídlo se nepodařilo objednat."), + actions: [ + TextButton( + child: const Text("OK"), + onPressed: () => + Navigator.of(context).pop(), + ) + ], + ), + ); + } nactiBurzu(); }); }, diff --git a/lib/okna/home.dart b/lib/okna/home.dart index 012e683..9d8e907 100644 --- a/lib/okna/home.dart +++ b/lib/okna/home.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:opencanteen/main.dart'; import 'package:opencanteen/util.dart'; +import 'package:url_launcher/url_launcher.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key, required this.user, required this.canteen}) @@ -78,6 +79,20 @@ class _HomePageState extends State { }); } + void kliknuti(String value) { + switch (value) { + case 'Odhlásit se': + const storage = FlutterSecureStorage(); + storage.deleteAll(); + Navigator.pushReplacement( + context, MaterialPageRoute(builder: (c) => const LoginPage())); + break; + case 'Nahlásit chybu': + launch("https://github.com/hernikplays/opencanteen/issues/new/choose"); + break; + } + } + @override void initState() { super.initState(); @@ -91,14 +106,17 @@ class _HomePageState extends State { appBar: AppBar( title: const Text("Domů"), actions: [ - IconButton( - onPressed: (() { - const storage = FlutterSecureStorage(); - storage.deleteAll(); - Navigator.pushReplacement(context, - MaterialPageRoute(builder: (c) => const LoginPage())); - }), - icon: const Icon(Icons.logout)) + PopupMenuButton( + onSelected: kliknuti, + itemBuilder: (BuildContext context) { + return {'Nahlásit chybu', 'Odhlásit se'}.map((String choice) { + return PopupMenuItem( + value: choice, + child: Text(choice), + ); + }).toList(); + }, + ), ], ), body: RefreshIndicator( diff --git a/pubspec.lock b/pubspec.lock index 8a3e0a1..acfdf2b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -315,6 +315,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.20" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.15" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.15" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" vector_math: dependency: transitive description: @@ -338,4 +394,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.16.1 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5752a27..fe95241 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: cupertino_icons: ^1.0.2 connectivity_plus: ^2.2.1 flutter_secure_storage: ^5.0.2 + url_launcher: ^6.0.20 dev_dependencies: flutter_lints: ^1.0.0