feat(app): 뒤로가기 두 번 눌러서 앱 종료

메인 화면에서 뒤로가기 1회 → '한 번 더 누르면 앱이 종료됩니다' 스낵바
2초 내 다시 누르면 앱 종료

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
caadiq 2026-04-04 13:47:26 +09:00
parent dd15958e90
commit 9375a78d63
2 changed files with 34 additions and 3 deletions

View file

@ -17,7 +17,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:enableOnBackInvokedCallback="false">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues

View file

@ -2,23 +2,52 @@
library;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../core/constants.dart';
/// ( + + )
class MainShell extends StatelessWidget {
class MainShell extends StatefulWidget {
final Widget child;
const MainShell({super.key, required this.child});
@override
State<MainShell> createState() => _MainShellState();
}
class _MainShellState extends State<MainShell> {
DateTime? _lastBackPressed;
@override
Widget build(BuildContext context) {
final child = widget.child;
final location = GoRouterState.of(context).uri.path;
final isMembersPage = location == '/members';
final isSchedulePage = location.startsWith('/schedule');
return Scaffold(
return PopScope(
canPop: false,
onPopInvokedWithResult: (bool didPop, dynamic result) {
if (didPop) return;
final now = DateTime.now();
if (_lastBackPressed != null &&
now.difference(_lastBackPressed!) < const Duration(seconds: 2)) {
SystemNavigator.pop();
} else {
_lastBackPressed = now;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('한 번 더 누르면 앱이 종료됩니다'),
duration: Duration(seconds: 2),
behavior: SnackBarBehavior.floating,
),
);
}
},
child: Scaffold(
backgroundColor: AppColors.background,
// () - ,
appBar: isSchedulePage
@ -60,6 +89,7 @@ class MainShell extends StatelessWidget {
body: child,
//
bottomNavigationBar: const _BottomNavBar(),
),
);
}