import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import '../widgets/dialogs/kr_dialog.dart';
import '../localization/app_translations.dart';

class KRNetworkStatus {
  static Future<bool> checkNetworkStatus() async {
    final connectivityResult = await Connectivity().checkConnectivity();
    if (connectivityResult != ConnectivityResult.none) {
      return true;
    }

    bool? result;
    await KRDialog.show(
      title: AppTranslations.kr_networkStatus.title,
      message: AppTranslations.kr_networkStatus.checkNetwork,
      confirmText: AppTranslations.kr_networkStatus.retry,
      cancelText: AppTranslations.kr_networkStatus.cancel,
      onConfirm: () => result = true,
      onCancel: () => result = false,
    );

    if (result == true) {
      return checkNetworkStatus();
    }

    return false;
  }
} 