From 882f4bdf0e63af1b132e4424753d1c92876c69bf Mon Sep 17 00:00:00 2001 From: Arnob <68462590+CodeByArnob@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:00:11 +0600 Subject: [PATCH 1/3] Open Puter sign in and sign up in external browser --- .../auth/screens/puter_auth_screen.dart | 147 ++++-------------- 1 file changed, 29 insertions(+), 118 deletions(-) diff --git a/lib/features/auth/screens/puter_auth_screen.dart b/lib/features/auth/screens/puter_auth_screen.dart index 07ae447..3a86104 100644 --- a/lib/features/auth/screens/puter_auth_screen.dart +++ b/lib/features/auth/screens/puter_auth_screen.dart @@ -3,7 +3,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:webview_flutter/webview_flutter.dart'; import '../../../core/constants/app_colors.dart'; import '../../../core/constants/app_constants.dart'; import '../../../core/utils/haptic_helper.dart'; @@ -30,111 +29,38 @@ class _PuterAuthScreenState extends ConsumerState { Future _launchExternalBrowser(String url) async { final uri = Uri.parse(url); - if (await canLaunchUrl(uri)) { - await launchUrl(uri, mode: LaunchMode.externalApplication); + try { + final launched = await launchUrl( + uri, + mode: LaunchMode.externalApplication, + ); + if (!launched && mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Could not open your default browser. Please try again.'), + ), + ); + } + } catch (error) { + debugPrint('[PuterAuth] External browser launch failed: $error'); + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Could not open your default browser. Please try again.'), + ), + ); + } } } Future _handleOfficialSignIn() async { HapticHelper.mediumImpact(); - final bridge = ref.read(puterBridgeServiceProvider); - - // If bridge controller is ready, show official Puter auth modal dialog - if (bridge.webViewController != null) { - _showPuterAuthModal(context, bridge.webViewController!); - } - - final success = await ref.read(authProvider.notifier).signInWithPuterWeb(); - if (success && mounted) { - HapticHelper.vibrateSuccess(); - context.go('/home'); - } + await _launchExternalBrowser('https://puter.com/login'); } - void _showPuterAuthModal(BuildContext context, WebViewController controller) { - showModalBottomSheet( - context: context, - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - isDismissible: true, - builder: (ctx) { - return Container( - height: MediaQuery.of(ctx).size.height * 0.92, - decoration: const BoxDecoration( - color: Color(0xFF0C121E), - borderRadius: BorderRadius.vertical(top: Radius.circular(24)), - ), - child: Column( - children: [ - // Header - Container( - height: 56, - padding: const EdgeInsets.symmetric(horizontal: 16), - decoration: const BoxDecoration( - border: Border( - bottom: BorderSide(color: AppColors.darkBorder), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Container( - width: 28, - height: 28, - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [Color(0xFF0055FF), Color(0xFF00D2FF)], - ), - borderRadius: BorderRadius.circular(8), - ), - child: const Center( - child: Text( - 'P', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.w900, - fontSize: 16, - ), - ), - ), - ), - const SizedBox(width: 10), - const Text( - 'Puter Official Authorization', - style: TextStyle( - color: Colors.white, - fontSize: 14, - fontWeight: FontWeight.w700, - ), - ), - ], - ), - IconButton( - icon: const Icon( - Icons.close, - color: AppColors.textSecondaryDark, - size: 20, - ), - onPressed: () { - HapticHelper.lightImpact(); - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ), - // Official Puter Bridge & Popup Viewport - Expanded( - child: ClipRRect(child: WebViewWidget(controller: controller)), - ), - ], - ), - ); - }, - ); + Future _handleOfficialSignUp() async { + HapticHelper.mediumImpact(); + await _launchExternalBrowser('https://puter.com/signup'); } Future _pasteToken() async { @@ -373,27 +299,12 @@ class _PuterAuthScreenState extends ConsumerState { ), const SizedBox(height: 12), - // Action: Continue with Google via Puter + // Create a new Puter account in the device default browser. CustomButton( - text: 'Continue with Google', - icon: Icons.g_mobiledata_rounded, + text: 'Sign Up with Puter', isSecondary: true, - onPressed: () { - HapticHelper.lightImpact(); - _launchExternalBrowser('https://puter.com/login'); - }, - ), - const SizedBox(height: 12), - - // Action 2: Open External Browser for Account Creation / Management - CustomButton( - text: 'Open Puter.com in Browser', - isSecondary: true, - icon: Icons.open_in_browser_rounded, - onPressed: () { - HapticHelper.lightImpact(); - _launchExternalBrowser('https://puter.com/login'); - }, + icon: Icons.person_add_alt_1_rounded, + onPressed: _handleOfficialSignUp, ), const SizedBox(height: 12), From 066f4fb95abdd4383dd650a9e28be48e38834ed7 Mon Sep 17 00:00:00 2001 From: Arnob <68462590+CodeByArnob@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:02:26 +0600 Subject: [PATCH 2/3] Format external browser authentication screen --- lib/features/auth/screens/puter_auth_screen.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/features/auth/screens/puter_auth_screen.dart b/lib/features/auth/screens/puter_auth_screen.dart index 3a86104..802d304 100644 --- a/lib/features/auth/screens/puter_auth_screen.dart +++ b/lib/features/auth/screens/puter_auth_screen.dart @@ -37,7 +37,9 @@ class _PuterAuthScreenState extends ConsumerState { if (!launched && mounted) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text('Could not open your default browser. Please try again.'), + content: Text( + 'Could not open your default browser. Please try again.', + ), ), ); } From 59277bfab73d4eb948802782969eb4d3bd0eecf5 Mon Sep 17 00:00:00 2001 From: Arnob <68462590+CodeByArnob@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:04:11 +0600 Subject: [PATCH 3/3] Format remaining external browser error branch --- lib/features/auth/screens/puter_auth_screen.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/features/auth/screens/puter_auth_screen.dart b/lib/features/auth/screens/puter_auth_screen.dart index 802d304..ba37293 100644 --- a/lib/features/auth/screens/puter_auth_screen.dart +++ b/lib/features/auth/screens/puter_auth_screen.dart @@ -48,7 +48,9 @@ class _PuterAuthScreenState extends ConsumerState { if (mounted) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text('Could not open your default browser. Please try again.'), + content: Text( + 'Could not open your default browser. Please try again.', + ), ), ); }