import 'package:get/get.dart';

import 'package:kaer_with_panels/app/model/kr_area_code.dart'; // 假设这个文件中有 KRAreaCode 类

class KRSearchAreaController extends GetxController {
  final areas = <KRAreaCodeItem>[].obs;
  final searchQuery = ''.obs;

  @override
  void onInit() {
    super.onInit();
    areas.assignAll(KRAreaCode.kr_getCodeList());
  }

  List<KRAreaCodeItem> get filteredAreas {
    if (searchQuery.value.isEmpty) {
      return areas;
    } else {
      return areas
          .where((area) => area.kr_dialCode.toLowerCase().contains(searchQuery.value.toLowerCase()))
          .toList();
    }
  }
} 