import 'package:flutter/services.dart';
import 'package:rasadyar_core/core.dart';

class BuyLogic extends GetxController {
  List<String> routesName = ['خرید'];
  DateTime? _lastBackPressed;

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    fLog('BuyLogic onReady');
    super.onReady();
  }

  @override
  void onClose() {
    // TODO: implement onClose
    super.onClose();
  }

  void onPopScopTaped() async {
    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();
    }
  }
}
