spotube/lib/pages/mobile_login/no_webview_runtime_dialog.dart
2025-01-30 21:44:07 +06:00

58 lines
1.8 KiB
Dart

import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:spotube/extensions/context.dart';
import 'package:url_launcher/url_launcher_string.dart';
class NoWebviewRuntimeDialog extends StatelessWidget {
const NoWebviewRuntimeDialog({super.key});
@override
Widget build(BuildContext context) {
final ThemeData(:platform) = Theme.of(context);
return AlertDialog(
title: Text(context.l10n.webview_not_found),
content: Text(context.l10n.webview_not_found_description),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(context.l10n.cancel),
),
Button.primary(
onPressed: () async {
final url = switch (platform) {
TargetPlatform.windows =>
'https://developer.microsoft.com/en-us/microsoft-edge/webview2',
TargetPlatform.macOS => 'https://www.apple.com/safari/',
TargetPlatform.linux =>
'https://webkitgtk.org/reference/webkit2gtk/stable/',
_ => "",
};
if (url.isEmpty) {
showToast(
context: context,
builder: (context, overlay) {
return const SurfaceCard(
child: Basic(
title: Text('Unsupported platform'),
),
);
},
);
}
await launchUrlString(url);
},
child: Text(switch (platform) {
TargetPlatform.windows => 'Download Edge WebView2',
TargetPlatform.macOS => 'Download Safari',
TargetPlatform.linux => 'Download Webkit2Gtk',
_ => 'Download Webview',
}),
),
],
);
}
}