import 'dart:convert';

import 'package:flutter/services.dart';
import 'package:flutter_translate/common/components/view_state.dart';
import 'package:flutter_translate/generated/assets.dart';
import 'package:flutter_translate/model/scene_model.dart';
import 'package:flutter_translate/router/get_gages.dart';
import 'package:get/get.dart';

class SceneCategoryController extends GetxController {
  var sceneTypeList = <SceneModel>[].obs;
  var viewState = ViewStateEnum.loading.obs;

  @override
  void onReady() async {
    super.onReady();
    var data = jsonDecode(await rootBundle.loadString(Assets.jsonScene));
    if (data != null && data is List) {
      sceneTypeList.value = data.map((e) => SceneModel.fromMap(e)).toList();
    }
    viewState.value = sceneTypeList.isNotEmpty ? ViewStateEnum.normal : ViewStateEnum.empty;
  }

  void sceneList(List<SceneList> sceneList) {
    Get.toNamed(GetPages.sceneList, arguments: sceneList);
  }
}
