import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:lottie/lottie.dart'; import 'package:webview_flutter/webview_flutter.dart'; class VerifyScreen extends StatefulWidget { final String passKey; const VerifyScreen({ super.key, required this.passKey, }); @override State createState() => _VerifyScreenState(); } class _VerifyScreenState extends State { late final WebViewController _controller; @override void initState() { super.initState(); _controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setNavigationDelegate( NavigationDelegate( onNavigationRequest: (NavigationRequest request) async { if (request.url.contains('user_detailz') && !request.url.contains('change-phone-verify') || request.url.contains('email/verify')) { GoRouter.of(context).pop(); await showModalBottomSheet( useRootNavigator: true, showDragHandle: true, context: context, builder: (context) => Container( padding: const EdgeInsets.all(16), width: MediaQuery.of(context).size.width, child: Column( mainAxisSize: MainAxisSize.min, children: [ const Text( 'Номер телефона\nуспешно привязан', textAlign: TextAlign.center, style: TextStyle( fontSize: 20, height: 1, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 16), Lottie.asset( 'assets/lottie_animations/success.json', width: 160, height: 160, ), const SizedBox(height: 16), const Text( 'Теперь Вам доступен весь функционал!', textAlign: TextAlign.center, style: TextStyle( fontSize: 16, height: 1, fontWeight: FontWeight.w500, ), ), const SizedBox(height: 16), InkWell( onTap: () { Navigator.of(context).pop(); }, child: Ink( width: MediaQuery.of(context).size.width - 32, height: 52, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: appTheme.blueA400, ), child: const Center( child: Text( 'Закрыть', style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w600, ), ), ), ), ), ], ), ), ); return NavigationDecision.prevent; } return NavigationDecision.navigate; }, ), ) ..loadRequest(Uri.parse('$baseUrl/login_with_pass_key?id=${widget.passKey}')); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( toolbarHeight: 0, ), body: SafeArea( child: WebViewWidget(controller: _controller), ), ); } }