feat(autoburza): vytvořit základ pro autoburzu

This commit is contained in:
Matyáš Caras 2022-10-20 17:44:04 +02:00
parent 656c5739a8
commit 68ee7d16c4
11 changed files with 55 additions and 4 deletions

View file

@ -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'

View file

@ -547,3 +547,9 @@
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
};
};

View file

@ -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)
}

View file

@ -50,5 +50,13 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>processing</string>
</array>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>oc_bg</string>
</array>
</dict>
</plist>

View file

@ -157,6 +157,8 @@ abstract class Languages {
String get notifyWarning;
String get autoburzaSetting;
// Offline
String get offline;

View file

@ -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é";
}

View file

@ -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";
}

View file

@ -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());
}

View file

@ -27,6 +27,7 @@ class _NastaveniState extends State<Nastaveni> {
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<Nastaveni> {
_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<Nastaveni> {
})
],
),
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: [

View file

@ -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"

View file

@ -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