import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; import 'package:eatvio_app/features/registration/services/registration_analytics_service.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; bool _isLoading = true; @override void initState() { super.initState(); // Report phone verification screen opened RegistrationAnalyticsService.reportRegistrationStep(17); // Phone verification step _controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setNavigationDelegate( NavigationDelegate( onPageFinished: (url) { setState(() { _isLoading = false; }); }, onNavigationRequest: (NavigationRequest request) async { if (request.url.contains('user_detailz') && !request.url.contains('change-phone-verify') || request.url.contains('email/verify')) { // Report phone verification success RegistrationAnalyticsService.reportPhoneVerification(); 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: Stack( children: [ WebViewWidget(controller: _controller), if (_isLoading) const Center(child: Loader()), ], ), ), ); } }