feat(interface,android): Allow passing an initial locale to the service

This commit is contained in:
2023-09-03 21:57:25 +02:00
parent 81e819b4a7
commit 4167227c7b
8 changed files with 25 additions and 11 deletions

View File

@@ -8,10 +8,12 @@ abstract class IsolateHandler {
/// [entrypoint] is the entrypoint that is run inside the new isolate.
/// [handleUIEvent] is a handler function that is called when the isolate receives data from the UI.
/// [handleIsolateEvent] is a handler function that is called when the UI receives data from the service.
/// [initialLocale] the locale to pass to the background service when first starting.
Future<void> start(
Future<void> Function() entrypoint,
Future<void> Function(String initialLocale) entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleUIEvent,
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
String initialLocale,
);
/// Make sure that the UI event handler is registered without starting the isolate.

View File

@@ -22,9 +22,10 @@ class StubIsolateHandler extends IsolateHandler {
@override
Future<void> start(
Future<void> Function() entrypoint,
Future<void> Function(String initialLocale) entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleUIEvent,
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
String initialLocale,
) async {
// ignore: avoid_print
print('STUB STARTED!!!!!!');

View File

@@ -17,6 +17,9 @@ class StubPlatformImplementation extends PlatformImplementation {
@override
Future<bool> generateVideoThumbnail(
String src, String dest, int width) async =>
String src,
String dest,
int width,
) async =>
false;
}

View File

@@ -11,7 +11,8 @@ abstract class BackgroundService {
/// [handleEvent] is a function that is called whenever the service receives
/// data.
void init(
Future<void> Function() entrypoint,
Future<void> Function(String initialLocale) entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleEvent,
String initialLocale,
);
}