import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_core/core.dart';

const int timeDebounce = 1200;

void handleGeneric(DioException error, [void Function()? onError]) {
  Get.showSnackbar(_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'));

  Get.offAllNamed(ChickenRoutes.auth, arguments: Module.chicken);
}

GetSnackBar _errorSnackBar(String message) {
  return GetSnackBar(
    titleText: Text('خطا', style: AppFonts.yekan14.copyWith(color: Colors.white)),
    messageText: Text(message, style: AppFonts.yekan12.copyWith(color: Colors.white)),
    backgroundColor: AppColor.error,
    margin: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
    borderRadius: 12,
    duration: Duration(milliseconds: 3500),
    snackPosition: SnackPosition.TOP,
  );
}
