66 lines
1.9 KiB
Dart
66 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Common/controller/MainController.dart';
|
|
|
|
final MainController mainController = Get.put(MainController());
|
|
|
|
class MainScreen extends StatelessWidget {
|
|
const MainScreen({super.key});
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Obx(() {
|
|
return WillPopScope(
|
|
onWillPop: () async {
|
|
_onBackButtonPressed(context);
|
|
return true; // Return true to allow the pop action
|
|
},
|
|
child: Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
body: mainController.currentTab[mainController.selectedIndex.value],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
Future<bool> _onBackButtonPressed(BuildContext context) async {
|
|
bool? exitApp = await showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
backgroundColor: Color(0xFF222935),
|
|
title: const Text('Exit App', style: TextStyle(color: Colors.white)),
|
|
content: const Text('Do you really want to close the app?',
|
|
style: TextStyle(color: Colors.white)),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop(false);
|
|
},
|
|
child: const Text(
|
|
'No',
|
|
style: TextStyle(
|
|
color: Color(0xFFD90B2E),
|
|
),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
SystemNavigator.pop();
|
|
Navigator.pop(context);
|
|
},
|
|
child: const Text(
|
|
'Yes',
|
|
style: TextStyle(
|
|
color: Color(0xFFD90B2E),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
},
|
|
);
|
|
return exitApp ?? false;
|
|
}
|
|
}
|