forked from baron/baron-sso
QR 스캔 뒤로가기 fallback 추가로 진입 복귀 보장
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
@@ -38,6 +38,15 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
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<QRScanScreen> {
|
||||
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(
|
||||
|
||||
@@ -131,6 +131,15 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
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<QRScanScreen> {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user