This repository has been archived on 2024-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
SolarAgent/lib/screens/auth.dart

34 lines
1.0 KiB
Dart
Raw Normal View History

2024-02-07 20:40:56 +00:00
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
2024-02-08 08:34:33 +00:00
class AuthorizationScreen extends StatelessWidget {
2024-02-07 20:40:56 +00:00
final Uri authorizationUrl;
2024-02-08 08:34:33 +00:00
const AuthorizationScreen(this.authorizationUrl, {super.key});
2024-02-07 20:40:56 +00:00
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Connect with Goatpass'),
),
body: WebViewWidget(
controller: WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
2024-02-08 08:34:33 +00:00
..setBackgroundColor(Colors.white)
2024-02-07 20:40:56 +00:00
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (NavigationRequest request) {
if (request.url.startsWith('goatagent://auth')) {
Navigator.of(context).pop(request.url);
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
))
2024-02-08 08:34:33 +00:00
..loadRequest(authorizationUrl)
..clearCache(),
2024-02-07 20:40:56 +00:00
),
);
}
}