engedelyek

This commit is contained in:
sagiferi
2026-10-27 21:31:27 +01:00
parent 29528f561b
commit 4a016fb1d1
7 changed files with 137 additions and 32 deletions
+15
View File
@@ -88,6 +88,7 @@ class WebShell extends StatefulWidget {
class _WebShellState extends State<WebShell> with WidgetsBindingObserver {
static const _files = MethodChannel('sfzenith/files');
static const _location = MethodChannel('sfzenith/location');
final LocalServer _server = LocalServer();
@@ -271,6 +272,19 @@ class _WebShellState extends State<WebShell> with WidgetsBindingObserver {
return {'status': result.status == ShareResultStatus.dismissed ? 'cancelled' : 'shared'};
}
/// iOS: one location fix from Core Location ({lat, lon, accuracy, alt?} or
/// {error}); the WebView's own geolocation would ask again on every launch.
/// Android: {unsupported} – the page uses navigator.geolocation, whose
/// prompt the shell answers once and for all (onGeolocationPermissionsShowPrompt).
Future<dynamic> _handleGetLocation(List<dynamic> args) async {
if (!Platform.isIOS) return {'unsupported': true};
try {
return await _location.invokeMapMethod<String, dynamic>('getLocation');
} on PlatformException catch (e) {
return {'error': e.code};
}
}
/// Screen stays on while the web app captures (WebView has no Wake Lock API).
Future<dynamic> _handleKeepAwake(List<dynamic> args) async {
final on = args.isNotEmpty && args[0] == true;
@@ -431,6 +445,7 @@ class _WebShellState extends State<WebShell> with WidgetsBindingObserver {
controller.addJavaScriptHandler(handlerName: 'saveFiles', callback: _handleSaveFiles);
controller.addJavaScriptHandler(handlerName: 'shareFiles', callback: _handleShareFiles);
controller.addJavaScriptHandler(handlerName: 'savePng', callback: _handleSavePng);
controller.addJavaScriptHandler(handlerName: 'getLocation', callback: _handleGetLocation);
},
onPermissionRequest: (controller, request) async {
// The OS-level permissions were requested at start.