fix : twice back press for exit application on live stock
This commit is contained in:
@@ -67,7 +67,6 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
super.onReady();
|
||||
determineCurrentPosition();
|
||||
getLoc();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -189,13 +188,12 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
final newLat = currentPosition.latitude + (dy / 111000.0);
|
||||
|
||||
// 1 درجه lon ≈ 111km * cos(lat)
|
||||
final newLng = currentPosition.longitude +
|
||||
(dx / (111000.0 * cos(currentPosition.latitude * pi / 180)));
|
||||
final newLng =
|
||||
currentPosition.longitude + (dx / (111000.0 * cos(currentPosition.latitude * pi / 180)));
|
||||
|
||||
locations.add(LatLng(newLat, newLng));
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/data/repository/livestock/livestock_repository.dart';
|
||||
import 'package:rasadyar_livestock/data/repository/livestock/livestock_repository_imp.dart';
|
||||
import 'package:rasadyar_livestock/injection/live_stock_di.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/map/view.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/profile/view.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/request_tagging/view.dart';
|
||||
@@ -14,9 +11,13 @@ import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||
|
||||
class RootLogic extends GetxController {
|
||||
List<Widget> pages = [
|
||||
MapPage(),
|
||||
Navigator(
|
||||
key: Get.nestedKey(0),
|
||||
onGenerateRoute: (settings) => GetPageRoute(page: () => MapPage()),
|
||||
),
|
||||
|
||||
Navigator(
|
||||
key: Get.nestedKey(1),
|
||||
initialRoute: LiveStockRoutes.requests,
|
||||
onGenerateRoute: (settings) {
|
||||
switch (settings.name) {
|
||||
@@ -30,7 +31,10 @@ class RootLogic extends GetxController {
|
||||
},
|
||||
),
|
||||
|
||||
ProfilePage(),
|
||||
Navigator(
|
||||
key: Get.nestedKey(2),
|
||||
onGenerateRoute: (settings) => GetPageRoute(page: () => ProfilePage()),
|
||||
),
|
||||
];
|
||||
|
||||
RxInt currentIndex = 0.obs;
|
||||
@@ -48,7 +52,7 @@ class RootLogic extends GetxController {
|
||||
}
|
||||
});
|
||||
|
||||
/* GetIt.instance.allReady().then((value) async {
|
||||
/* GetIt.instance.allReady().then((value) async {
|
||||
await diLiveStock.get<LivestockRepositoryImp>().addLocations(generateRandomPoints());
|
||||
});*/
|
||||
}
|
||||
|
||||
@@ -1,40 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class RootPage extends GetView<RootLogic> {
|
||||
const RootPage({super.key});
|
||||
RootPage({super.key});
|
||||
|
||||
DateTime? _lastBackPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ObxValue((currentIndex) {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
final navigatorKey = Get.nestedKey(currentIndex);
|
||||
eLog('Pop invoked with result: $result, didPop: $didPop');
|
||||
navigatorKey?.currentState?.pop();
|
||||
onPopInvokedWithResult: (didPop, result) async {
|
||||
final nestedKey = Get.nestedKey(controller.currentIndex.value);
|
||||
final currentNavigator = nestedKey?.currentState;
|
||||
|
||||
/*eLog('Pop invoked with result: $result, didPop: $didPop');
|
||||
iLog(Get.currentRoute);
|
||||
iLog(Get.previousRoute);
|
||||
|
||||
final navigatorKey = Get.nestedKey(currentIndex);
|
||||
|
||||
if (currentIndex.value == 0 &&
|
||||
|
||||
navigatorKey != null &&
|
||||
navigatorKey.currentState != null) {
|
||||
if (navigatorKey.currentState!.canPop()) {
|
||||
navigatorKey.currentState!.pop();
|
||||
return;
|
||||
if (currentNavigator?.canPop() ?? false) {
|
||||
currentNavigator?.pop();
|
||||
} else {
|
||||
final now = DateTime.now();
|
||||
if (_lastBackPressed == null ||
|
||||
now.difference(_lastBackPressed!) > Duration(seconds: 2)) {
|
||||
_lastBackPressed = now;
|
||||
Get.snackbar(
|
||||
'خروج از برنامه',
|
||||
'برای خروج دوباره بازگشت را بزنید',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: AppColor.warning,
|
||||
);
|
||||
} else {
|
||||
await SystemNavigator.pop();
|
||||
}
|
||||
|
||||
if (!didPop) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
},
|
||||
|
||||
child: Scaffold(
|
||||
|
||||
@@ -6,6 +6,7 @@ sealed class LiveStockRoutes {
|
||||
static const auth = '/AuthLiveStock';
|
||||
static const init = '/liveStock';
|
||||
static const requests = '/requests';
|
||||
static const map = '/map';
|
||||
static const profile = '/profile';
|
||||
|
||||
//static const requestTagging = '$init/tagging';
|
||||
|
||||
Reference in New Issue
Block a user