33 lines
1015 B
Dart
33 lines
1015 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:webview_flutter/webview_flutter.dart';
|
||
|
|
||
|
class AuthorizationPage extends StatelessWidget {
|
||
|
final Uri authorizationUrl;
|
||
|
|
||
|
const AuthorizationPage(this.authorizationUrl, {super.key});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
appBar: AppBar(
|
||
|
title: const Text('Connect with Goatpass'),
|
||
|
),
|
||
|
body: WebViewWidget(
|
||
|
controller: WebViewController()
|
||
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||
|
..setBackgroundColor(Colors.indigo)
|
||
|
..setNavigationDelegate(NavigationDelegate(
|
||
|
onNavigationRequest: (NavigationRequest request) {
|
||
|
if (request.url.startsWith('goatagent://auth')) {
|
||
|
Navigator.of(context).pop(request.url);
|
||
|
return NavigationDecision.prevent;
|
||
|
}
|
||
|
return NavigationDecision.navigate;
|
||
|
},
|
||
|
))
|
||
|
..loadRequest(authorizationUrl),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|