79 lines
2.2 KiB
Dart
79 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Common/controller/MainController.dart';
|
|
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart';
|
|
|
|
final MainController mainController = Get.put(MainController());
|
|
class MainScreen extends StatefulWidget {
|
|
const MainScreen({super.key});
|
|
|
|
@override
|
|
State<MainScreen> createState() => _MainScreenState();
|
|
}
|
|
|
|
class _MainScreenState extends State<MainScreen> {
|
|
@override
|
|
void initState() {
|
|
InterestListApi().getinterestlistApi();
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@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;
|
|
}
|
|
}
|