import 'package:rasadyar_chicken/chicken.dart';
import 'package:rasadyar_chicken/data/models/local/widely_used_local_model.dart';
import 'package:rasadyar_core/core.dart';

import 'chicken_local.dart';

class ChickenLocalDataSourceImp implements ChickenLocalDataSource {
  HiveLocalStorage local = diCore.get<HiveLocalStorage>();
  final String boxName = 'Chicken_Widley_Box';

  @override
  Future<void> openBox() async {
    await local.openBox<WidelyUsedLocalModel>(boxName);
  }

  @override
  Future<void> initWidleyUsed() async {
    List<WidelyUsedLocalItem> tmpList = [
      WidelyUsedLocalItem(
        index: 0,
        pathId: 0,
        title: 'خرید داخل استان',
        color: AppColor.greenLightActive.toARGB32(),
        iconColor: AppColor.greenNormal.toARGB32(),
        iconPath: Assets.vec.cubeSearchSvg.path,
        path: ChickenRoutes.buysInProvinceSteward,
      ),
      WidelyUsedLocalItem(
        index: 1,
        pathId: 1,
        title: 'فروش داخل استان',
        color: AppColor.blueLightActive.toARGB32(),
        iconColor: AppColor.blueNormal.toARGB32(),
        iconPath: Assets.vec.cubeSvg.path,
        path: ChickenRoutes.salesInProvinceSteward,
      ),

      WidelyUsedLocalItem(
        index: 2,
        title: 'قطعه‌بندی',
        color: AppColor.blueLightActive.toARGB32(),
        iconColor: AppColor.blueNormal.toARGB32(),
        iconPath: Assets.vec.cubeRotateSvg.path,
        path: ChickenRoutes.buysInProvinceSteward,
      ),
    ];

  }

  @override
  WidelyUsedLocalModel? getAllWidely() {
    var res = local.readBox<WidelyUsedLocalModel>(boxName: boxName);
    return res?.first;
  }
}
