diff --git a/lib/lang/lang.dart b/lib/lang/lang.dart index df15826..07d398f 100644 --- a/lib/lang/lang.dart +++ b/lib/lang/lang.dart @@ -133,12 +133,12 @@ abstract class Languages { // About - String get usedLibs; - String get license; String get copyright; + String get source; + // Nastavení String get settings; diff --git a/lib/lang/lang_cz.dart b/lib/lang/lang_cz.dart index b23a4a3..3a43f58 100644 --- a/lib/lang/lang_cz.dart +++ b/lib/lang/lang_cz.dart @@ -148,9 +148,6 @@ class LanguageCz extends Languages { @override String get tuesday => "Úterý"; - @override - String get usedLibs => "Použité knihovny:"; - @override String get username => "Uživatelské jméno"; @@ -234,4 +231,7 @@ class LanguageCz extends Languages { @override String get jump => "Přeskočit"; + + @override + String get source => "Zdrojový kód"; } diff --git a/lib/lang/lang_en.dart b/lib/lang/lang_en.dart index 2044f32..0d6d789 100644 --- a/lib/lang/lang_en.dart +++ b/lib/lang/lang_en.dart @@ -55,7 +55,7 @@ class LanguageEn extends Languages { String get inExchange => "ON EXCHANGE"; @override - String get license => "Released under GNU GPLv3"; + String get license => "Released under the GNU GPLv3"; @override String get loading => "Loading..."; @@ -148,9 +148,6 @@ class LanguageEn extends Languages { @override String get tuesday => "Tuesday"; - @override - String get usedLibs => "Used libraries:"; - @override String get username => "Username"; @@ -232,4 +229,7 @@ class LanguageEn extends Languages { @override String get jump => "Jump"; + + @override + String get source => "Source code"; } diff --git a/lib/okna/about.dart b/lib/okna/about.dart deleted file mode 100644 index b62b7f1..0000000 --- a/lib/okna/about.dart +++ /dev/null @@ -1,109 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../lang/lang.dart'; - -class AboutPage extends StatefulWidget { - const AboutPage({Key? key}) : super(key: key); - - @override - State createState() => _AboutPageState(); -} - -class _AboutPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(Languages.of(context)!.about), - ), - body: Center( - child: SizedBox( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width - 50, - child: SingleChildScrollView( - child: Column(mainAxisSize: MainAxisSize.min, children: [ - const Text("OpenCanteen", style: TextStyle(fontSize: 30)), - Text(Languages.of(context)!.copyright), - InkWell( - onTap: () => launchUrl(Uri.parse( - "https://github.com/hernikplays/opencanteen/blob/main/LICENSE")), - child: Text(Languages.of(context)!.license)), - const SizedBox(height: 15), - Text(Languages.of(context)!.usedLibs, - style: const TextStyle(fontSize: 19)), - const SizedBox(height: 10), - cudlik( - "Flutter", - "Copyright 2014 The Flutter Authors. All rights reserved, licence BSD 3-Clause", - "https://github.com/flutter/flutter/blob/master/LICENSE"), - const SizedBox(height: 10), - cudlik( - "Flutter_secure_storage", - "Copyright 2017 German Saprykin. All rights reserved, licence BSD 3-Clause", - "https://github.com/mogol/flutter_secure_storage/blob/develop/flutter_secure_storage/LICENSE"), - const SizedBox(height: 10), - cudlik( - "url_launcher", - "Copyright 2013 The Flutter Authors. All rights reserved, licence BSD 3-Clause", - "https://github.com/flutter/plugins/blob/main/packages/url_launcher/url_launcher/LICENSE"), - const SizedBox(height: 10), - cudlik( - "canteenlib", - "Copyright (c) 2022 Matyáš Caras and contributors, licence MIT", - "https://github.com/hernikplays/canteenlib/blob/main/LICENSE"), - const SizedBox(height: 10), - cudlik( - "path_provider", - "Copyright 2013 The Flutter Authors. All rights reserved, licence BSD-3-Clause", - "https://github.com/flutter/plugins/blob/main/packages/path_provider/path_provider/LICENSE"), - const SizedBox(height: 10), - cudlik( - "shared_preferences", - "Copyright 2013 The Flutter Authors. All rights reserved, licence BSD-3-Clause", - "https://github.com/flutter/plugins/blob/main/packages/path_provider/path_provider/LICENSE"), - const SizedBox(height: 10), - cudlik( - "introduction_screen", - "Copyright 2019 Jean-Charles Moussé, licence MIT", - "https://github.com/Pyozer/introduction_screen/blob/master/LICENSE"), - const SizedBox(height: 10), - cudlik( - "flutter_local_notifications", - "Copyright 2018 Michael Bui. All rights reserved, licence BSD-3-Clause", - "https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/LICENSE"), - const SizedBox(height: 10), - cudlik( - "timezone", - "Copyright 2014, timezone project authors, licence BSD-2-Clause", - "https://github.com/srawlins/timezone/blob/master/LICENSE"), - const SizedBox(height: 10), - cudlik( - "flutter_native_timezone", - "Copyright 2019 pinkfish, licence Apache 2.0", - "https://github.com/pinkfish/flutter_native_timezone/blob/master/LICENSE"), - ]), - ), - ), - ), - ); - } - - Widget cudlik(String nazev, String copyright, String licence) { - return InkWell( - onTap: () => launchUrl(Uri.parse(licence)), - child: Column(children: [ - Text( - nazev, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 17), - textAlign: TextAlign.center, - ), - Text( - copyright, - textAlign: TextAlign.center, - style: const TextStyle(fontSize: 12), - ), - ]), - ); - } -} diff --git a/lib/okna/jidelnicek.dart b/lib/okna/jidelnicek.dart index d67ac54..f79880b 100644 --- a/lib/okna/jidelnicek.dart +++ b/lib/okna/jidelnicek.dart @@ -7,13 +7,13 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:opencanteen/okna/nastaveni.dart'; import 'package:opencanteen/util.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; import '../lang/lang.dart'; import '../main.dart'; -import 'about.dart'; class JidelnicekPage extends StatefulWidget { const JidelnicekPage({Key? key, required this.canteen, required this.n}) @@ -344,8 +344,20 @@ class _JidelnicekPageState extends State { launchUrl(Uri.parse( "https://github.com/hernikplays/opencanteen/issues/new/choose")); } else if (value == Languages.of(context)!.about) { - Navigator.push( - context, MaterialPageRoute(builder: (c) => const AboutPage())); + var packageInfo = await PackageInfo.fromPlatform(); + if (!mounted) return; + showAboutDialog( + context: context, + applicationName: "OpenCanteen", + applicationLegalese: + "${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}", + applicationVersion: packageInfo.version, + children: [ + TextButton( + onPressed: (() => launchUrl( + Uri.parse("https://github.com/hernikplays/opencanteen"))), + child: Text(Languages.of(context)!.source)) + ]); } else if (value == Languages.of(context)!.settings) { Navigator.push( context, MaterialPageRoute(builder: (c) => Nastaveni(n: n))); diff --git a/lib/okna/offline_jidelnicek.dart b/lib/okna/offline_jidelnicek.dart index d4bf0ec..4bc30ef 100644 --- a/lib/okna/offline_jidelnicek.dart +++ b/lib/okna/offline_jidelnicek.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:opencanteen/util.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:url_launcher/url_launcher.dart'; import '../lang/lang.dart'; import '../main.dart'; -import 'about.dart'; class OfflineJidelnicek extends StatefulWidget { const OfflineJidelnicek({Key? key, required this.jidla}) : super(key: key); @@ -75,7 +75,7 @@ class _OfflineJidelnicekState extends State { setState(() {}); } - void kliknuti(String value, BuildContext context) { + void kliknuti(String value, BuildContext context) async { if (value == Languages.of(context)!.signOut) { const storage = FlutterSecureStorage(); storage.deleteAll(); @@ -85,8 +85,20 @@ class _OfflineJidelnicekState extends State { launchUrl(Uri.parse( "https://github.com/hernikplays/opencanteen/issues/new/choose")); } else if (value == Languages.of(context)!.about) { - Navigator.push( - context, MaterialPageRoute(builder: (c) => const AboutPage())); + var packageInfo = await PackageInfo.fromPlatform(); + if (!mounted) return; + showAboutDialog( + context: context, + applicationName: "OpenCanteen", + applicationLegalese: + "${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}", + applicationVersion: packageInfo.version, + children: [ + TextButton( + onPressed: (() => launchUrl( + Uri.parse("https://github.com/hernikplays/opencanteen"))), + child: Text(Languages.of(context)!.source)) + ]); } } diff --git a/pubspec.lock b/pubspec.lock index b425f36..01aab47 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -247,6 +247,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.3+1" + package_info_plus_linux: + dependency: transitive + description: + name: package_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_info_plus_macos: + dependency: transitive + description: + name: package_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_web: + dependency: transitive + description: + name: package_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_info_plus_windows: + dependency: transitive + description: + name: package_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2fc9892..f86059d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: timezone: ^0.8.0 flutter_native_timezone: ^2.0.0 intl: ^0.17.0 + package_info_plus: ^1.4.3+1 dev_dependencies: flutter_lints: ^2.0.1 @@ -41,9 +42,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - - assets/burza.png - - assets/doburzy.png - - assets/objednavam.png + - assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware.