import 'package:get/get.dart';
import 'package:flutter/material.dart';

class ChangeLanguageController extends GetxController {
  final RxString currentLanguage = Get.locale?.languageCode.obs ?? 'en'.obs;

  final List<Map<String, dynamic>> languages = [
    {'name': 'English', 'code': 'en', 'country': 'US'},
    {'name': 'French', 'code': 'fr', 'country': 'FR'},
    {'name': 'Urdu', 'code': 'ur', 'country': 'PK'},
  ];

  void changeLanguage(String languageCode, String countryCode) {
    var locale = Locale(languageCode, countryCode);
    Get.updateLocale(locale);
    currentLanguage.value = languageCode;
    Get.back();
  }

  bool isCurrentLanguage(String code) {
    return currentLanguage.value == code;
  }
}
