2024-02-07 20:40:56 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-02-10 14:23:05 +00:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2024-02-07 20:40:56 +00:00
|
|
|
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(
|
2024-03-17 12:22:46 +00:00
|
|
|
title: const Text('Sign in'),
|
2024-02-07 20:40:56 +00:00
|
|
|
),
|
2024-02-10 12:55:46 +00:00
|
|
|
body: Stack(children: [
|
|
|
|
WebViewWidget(
|
|
|
|
controller: WebViewController()
|
|
|
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
|
|
..setBackgroundColor(Colors.white)
|
|
|
|
..setNavigationDelegate(NavigationDelegate(
|
|
|
|
onNavigationRequest: (NavigationRequest request) {
|
2024-03-17 12:22:46 +00:00
|
|
|
if (request.url.startsWith('solaragent://auth')) {
|
2024-02-10 12:55:46 +00:00
|
|
|
Navigator.of(context).pop(request.url);
|
|
|
|
return NavigationDecision.prevent;
|
2024-03-17 12:22:46 +00:00
|
|
|
} else if (request.url.startsWith("https://solsynth.dev/auth/sign-up")) {
|
2024-02-10 14:23:05 +00:00
|
|
|
launchUrl(Uri.parse(request.url));
|
|
|
|
return NavigationDecision.prevent;
|
2024-02-10 12:55:46 +00:00
|
|
|
}
|
|
|
|
return NavigationDecision.navigate;
|
|
|
|
},
|
|
|
|
))
|
|
|
|
..loadRequest(authorizationUrl)
|
|
|
|
..clearCache(),
|
|
|
|
),
|
|
|
|
]),
|
2024-02-07 20:40:56 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|