From c8291da6995ede8aed1263041b030a854abcfadf Mon Sep 17 00:00:00 2001 From: kyy Date: Thu, 19 Mar 2026 13:39:12 +0900 Subject: [PATCH] =?UTF-8?q?QR=20=EC=8A=A4=EC=BA=94=20=EB=92=A4=EB=A1=9C?= =?UTF-8?q?=EA=B0=80=EA=B8=B0=20fallback=20=EC=B6=94=EA=B0=80=EB=A1=9C=20?= =?UTF-8?q?=EC=A7=84=EC=9E=85=20=EB=B3=B5=EA=B7=80=20=EB=B3=B4=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/features/auth/presentation/qr_scan_route.dart | 11 +++++++++++ .../auth/presentation/qr_scan_screen_stub.dart | 11 ++++++++++- .../auth/presentation/qr_scan_screen_web.dart | 11 ++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/userfront/lib/features/auth/presentation/qr_scan_route.dart b/userfront/lib/features/auth/presentation/qr_scan_route.dart index b69c7905..2f20393d 100644 --- a/userfront/lib/features/auth/presentation/qr_scan_route.dart +++ b/userfront/lib/features/auth/presentation/qr_scan_route.dart @@ -15,3 +15,14 @@ String buildQrApprovePath( ); return '/$resolvedLocale/approve?ref=${Uri.encodeQueryComponent(value)}'; } + +String buildQrBackFallbackPath({String? localeCode, Uri? currentUri}) { + final explicitLocale = localeCode?.trim(); + final uri = currentUri ?? Uri.base; + final resolvedLocale = explicitLocale != null && explicitLocale.isNotEmpty + ? explicitLocale.toLowerCase().replaceAll('_', '-') + : normalizeLocaleCode( + extractLocaleFromPath(uri) ?? resolvePreferredLocaleCode(), + ); + return '/$resolvedLocale/dashboard'; +} diff --git a/userfront/lib/features/auth/presentation/qr_scan_screen_stub.dart b/userfront/lib/features/auth/presentation/qr_scan_screen_stub.dart index 7f6b77d2..cd524661 100644 --- a/userfront/lib/features/auth/presentation/qr_scan_screen_stub.dart +++ b/userfront/lib/features/auth/presentation/qr_scan_screen_stub.dart @@ -38,6 +38,15 @@ class _QRScanScreenState extends State { context.go(buildQrApprovePath(raw)); } + void _handleBack() { + final router = GoRouter.of(context); + if (router.canPop()) { + router.pop(); + return; + } + router.go(buildQrBackFallbackPath()); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -45,7 +54,7 @@ class _QRScanScreenState extends State { title: Text(tr('ui.userfront.qr.title', fallback: 'Scan QR Code')), leading: IconButton( icon: const Icon(Icons.arrow_back), - onPressed: () => context.pop(), + onPressed: _handleBack, ), ), body: Padding( diff --git a/userfront/lib/features/auth/presentation/qr_scan_screen_web.dart b/userfront/lib/features/auth/presentation/qr_scan_screen_web.dart index c3e5291e..ea07d07b 100644 --- a/userfront/lib/features/auth/presentation/qr_scan_screen_web.dart +++ b/userfront/lib/features/auth/presentation/qr_scan_screen_web.dart @@ -131,6 +131,15 @@ class _QRScanScreenState extends State { } } + void _handleBack() { + final router = GoRouter.of(context); + if (router.canPop()) { + router.pop(); + return; + } + router.go(buildQrBackFallbackPath()); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -138,7 +147,7 @@ class _QRScanScreenState extends State { title: Text(tr('ui.userfront.qr.title', fallback: 'Scan QR Code')), leading: IconButton( icon: const Icon(Icons.arrow_back), - onPressed: () => context.pop(), + onPressed: _handleBack, ), ), body: Padding(