From 68ee7d16c41d2635df77d71ca5a248e7921912ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Thu, 20 Oct 2022 17:44:04 +0200 Subject: [PATCH] =?UTF-8?q?feat(autoburza):=20vytvo=C5=99it=20z=C3=A1klad?= =?UTF-8?q?=20pro=20autoburzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile | 2 +- ios/Runner.xcodeproj/project.pbxproj | 6 ++++++ ios/Runner/AppDelegate.swift | 2 ++ ios/Runner/Info.plist | 8 ++++++++ lib/lang/lang.dart | 2 ++ lib/lang/lang_cz.dart | 4 ++++ lib/lang/lang_en.dart | 4 ++++ lib/main.dart | 3 ++- lib/okna/nastaveni.dart | 16 ++++++++++++++++ pubspec.lock | 9 ++++++++- pubspec.yaml | 3 ++- 11 files changed, 55 insertions(+), 4 deletions(-) diff --git a/ios/Podfile b/ios/Podfile index 1e8c3c9..9411102 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +platform :ios, '10.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index dad830c..eafabb4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -547,3 +547,9 @@ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } + +SystemCapabilities = { + com.apple.BackgroundModes = { + enabled = 1; + }; +}; \ No newline at end of file diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 70693e4..2cd0283 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -1,5 +1,6 @@ import UIKit import Flutter +import workmanager @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { @@ -7,6 +8,7 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + WorkmanagerPlugin.registerTask(withIdentifier: "oc_bg") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index e8f7e87..168cd23 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -50,5 +50,13 @@ CADisableMinimumFrameDurationOnPhone + UIBackgroundModes + + processing + + BGTaskSchedulerPermittedIdentifiers + + oc_bg + diff --git a/lib/lang/lang.dart b/lib/lang/lang.dart index 3abea23..45f0aa7 100644 --- a/lib/lang/lang.dart +++ b/lib/lang/lang.dart @@ -157,6 +157,8 @@ abstract class Languages { String get notifyWarning; + String get autoburzaSetting; + // Offline String get offline; diff --git a/lib/lang/lang_cz.dart b/lib/lang/lang_cz.dart index 65dcc88..4ee58bc 100644 --- a/lib/lang/lang_cz.dart +++ b/lib/lang/lang_cz.dart @@ -237,4 +237,8 @@ class LanguageCz extends Languages { @override String get review => "Ohodnotit aplikaci"; + + @override + String get autoburzaSetting => + "Automaticky objednat jídlo z burzy když bude dostupné"; } diff --git a/lib/lang/lang_en.dart b/lib/lang/lang_en.dart index bd26eec..974704d 100644 --- a/lib/lang/lang_en.dart +++ b/lib/lang/lang_en.dart @@ -235,4 +235,8 @@ class LanguageEn extends Languages { @override String get review => "Review the app"; + + @override + String get autoburzaSetting => + "Automatically order food from exchange when available"; } diff --git a/lib/main.dart b/lib/main.dart index cfc473a..9986f9d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -102,7 +102,6 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async { } void main() async { - WidgetsFlutterBinding.ensureInitialized(); tz.initializeTimeZones(); var l = tz.getLocation(await FlutterNativeTimezone.getLocalTimezone()); tz.setLocalLocation(l); @@ -137,6 +136,8 @@ void main() async { } }); + WidgetsFlutterBinding.ensureInitialized(); + // spustit aplikaci runApp(const MyApp()); } diff --git a/lib/okna/nastaveni.dart b/lib/okna/nastaveni.dart index 4839240..5189c25 100644 --- a/lib/okna/nastaveni.dart +++ b/lib/okna/nastaveni.dart @@ -27,6 +27,7 @@ class _NastaveniState extends State { bool _kontrolovatTyden = false; bool _oznameniObed = false; bool _zapamatovany = false; + bool _autoburza = false; TimeOfDay _oznameniCas = TimeOfDay.now(); void najitNastaveni() async { @@ -37,6 +38,7 @@ class _NastaveniState extends State { _preskakovatVikend = preferences.getBool("skip") ?? false; _kontrolovatTyden = preferences.getBool("tyden") ?? false; _oznameniObed = preferences.getBool("oznamit") ?? false; + _autoburza = preferences.getBool("autoburza") ?? false; var casStr = preferences.getString("oznameni_cas"); if (casStr == null) { var now = DateTime.now(); @@ -114,6 +116,20 @@ class _NastaveniState extends State { }) ], ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible(child: Text(Languages.of(context)!.autoburzaSetting)), + Switch( + value: _autoburza, + onChanged: (value) { + setState(() { + _kontrolovatTyden = value; + zmenitNastaveni("autoburza", value); + }); + }) + ], + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/pubspec.lock b/pubspec.lock index 1ba9b3e..5d8f4cc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -539,6 +539,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.0" + workmanager: + dependency: "direct main" + description: + name: workmanager + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.1" xdg_directories: dependency: transitive description: @@ -561,5 +568,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.17.0 <3.0.0" + dart: ">=2.18.0 <3.0.0" flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b3b604b..4e930eb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: 'none' # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. -version: 1.4.1+20 +version: 1.5.0+21 environment: sdk: ">=2.16.1 <3.0.0" @@ -27,6 +27,7 @@ dependencies: flutter_native_timezone: ^2.0.0 intl: ^0.17.0 package_info_plus: ^1.4.3+1 + workmanager: ^0.5.1 dev_dependencies: flutter_lints: ^2.0.1