Add quick actions
This commit is contained in:
parent
dd164e95ea
commit
795393d543
9 changed files with 128 additions and 2 deletions
10
android/app/src/main/res/drawable/exclamation.xml
Normal file
10
android/app/src/main/res/drawable/exclamation.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="M440,560L440,200L520,200L520,560L440,560ZM440,760L440,680L520,680L520,760L440,760Z"/>
|
||||
</vector>
|
||||
10
android/app/src/main/res/drawable/play.xml
Normal file
10
android/app/src/main/res/drawable/play.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="M320,760L320,200L760,480L320,760ZM400,480L400,480L400,480ZM400,614L610,480L400,346L400,614Z"/>
|
||||
</vector>
|
||||
10
android/app/src/main/res/drawable/stop.xml
Normal file
10
android/app/src/main/res/drawable/stop.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="M320,320L320,320L320,640L320,640L320,320ZM240,720L240,240L720,240L720,720L240,720ZM320,640L640,640L640,320L320,320L320,640Z"/>
|
||||
</vector>
|
||||
|
|
@ -153,6 +153,8 @@ PODS:
|
|||
- PromisesObjC (2.4.0)
|
||||
- PromisesSwift (2.4.0):
|
||||
- PromisesObjC (= 2.4.0)
|
||||
- quick_actions_ios (0.0.1):
|
||||
- Flutter
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
|
|
@ -165,6 +167,7 @@ DEPENDENCIES:
|
|||
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_background_geolocation (from `.symlinks/plugins/flutter_background_geolocation/ios`)
|
||||
- quick_actions_ios (from `.symlinks/plugins/quick_actions_ios/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
|
||||
SPEC REPOS:
|
||||
|
|
@ -202,6 +205,8 @@ EXTERNAL SOURCES:
|
|||
:path: Flutter
|
||||
flutter_background_geolocation:
|
||||
:path: ".symlinks/plugins/flutter_background_geolocation/ios"
|
||||
quick_actions_ios:
|
||||
:path: ".symlinks/plugins/quick_actions_ios/ios"
|
||||
shared_preferences_foundation:
|
||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||
|
||||
|
|
@ -230,6 +235,7 @@ SPEC CHECKSUMS:
|
|||
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
|
||||
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
|
||||
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
|
||||
quick_actions_ios: 4b07fb49d8d8f3518d7565fbb7a91014067a7d82
|
||||
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
|
||||
|
||||
PODFILE CHECKSUM: f8c2dcdfb50bb67645580d28a6bf814fca30bdec
|
||||
|
|
|
|||
|
|
@ -17,5 +17,8 @@
|
|||
"intervalLabel": "Frequency",
|
||||
"distanceLabel": "Distance",
|
||||
"bufferLabel": "Offline buffering",
|
||||
"trackingLabel": "Continuous tracking"
|
||||
"trackingLabel": "Continuous tracking",
|
||||
"startAction": "Start service",
|
||||
"stopAction": "Stop service",
|
||||
"sosAction": "Send SOS"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
|
||||
import 'package:traccar_client/quick_actions.dart';
|
||||
|
||||
import 'main_screen.dart';
|
||||
import 'preferences.dart';
|
||||
|
|
@ -25,7 +26,12 @@ class MainApp extends StatelessWidget {
|
|||
seedColor: Colors.green,
|
||||
),
|
||||
),
|
||||
home: MainScreen(),
|
||||
home: Stack(
|
||||
children: const [
|
||||
QuickActionsInitializer(),
|
||||
MainScreen(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
lib/quick_actions.dart
Normal file
48
lib/quick_actions.dart
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import 'dart:developer' as developer;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:quick_actions/quick_actions.dart';
|
||||
|
||||
class QuickActionsInitializer extends StatefulWidget {
|
||||
const QuickActionsInitializer({super.key});
|
||||
|
||||
@override
|
||||
State<QuickActionsInitializer> createState() => _QuickActionsInitializerState();
|
||||
}
|
||||
|
||||
class _QuickActionsInitializerState extends State<QuickActionsInitializer> {
|
||||
final QuickActions quickActions = QuickActions();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
quickActions.initialize((shortcutType) {
|
||||
developer.log('action $shortcutType');
|
||||
switch (shortcutType) {
|
||||
case 'start':
|
||||
break;
|
||||
case 'stop':
|
||||
break;
|
||||
case 'sos':
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
final localizations = AppLocalizations.of(context)!;
|
||||
quickActions.setShortcutItems(<ShortcutItem>[
|
||||
ShortcutItem(type: 'sos', localizedTitle: localizations.sosAction, icon: 'exclamation'),
|
||||
ShortcutItem(type: 'stop', localizedTitle: localizations.stopAction, icon: 'stop'),
|
||||
ShortcutItem(type: 'start', localizedTitle: localizations.startAction, icon: 'play'),
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
32
pubspec.lock
32
pubspec.lock
|
|
@ -317,6 +317,38 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
quick_actions:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: quick_actions
|
||||
sha256: "7e35dd6a21f5bbd21acf6899039eaf85001a5ac26d52cbd6a8a2814505b90798"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
quick_actions_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quick_actions_android
|
||||
sha256: "8d88e90a236ffe92f1026ecc3b85acfefedffccb0c1be1c94c1c0298e8483ad8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.21"
|
||||
quick_actions_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quick_actions_ios
|
||||
sha256: "837b7e6b5973784d3da56b8c959b446b215914f20405d88cd7d22a2fb94e4e4c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
quick_actions_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quick_actions_platform_interface
|
||||
sha256: "1fec7068db5122cd019e9340d3d7be5d36eab099695ef3402c7059ee058329a4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ dependencies:
|
|||
firebase_messaging: ^15.2.5
|
||||
firebase_analytics: ^11.4.5
|
||||
firebase_crashlytics: ^4.3.5
|
||||
quick_actions: ^1.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue