
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:router/ext/auto_router_extensions.dart';
import 'package:shared/utils/log_utils.dart';


import '../../../respository/services_respository.dart';
import '../constants_services.dart';
import '../modules/services/service_evaluate_create/service_evaluate_create_page.dart';

part 'status_card_item_vm.g.dart';


@riverpod
class StatusCardItemVm extends _$StatusCardItemVm {
  late ServicesRespository serviceRespositoryInstance;

  late int _serviceId;
  late int _cleanServiceTypeId;
  late int _serviceStatusCode;


  initState(){
    Log.d("--------------------------initState---------------------");
    return null;
  }

  @override
  build(){
    // 引入数据仓库
    // serviceRespositoryInstance = ref.read(servicesRespositoryProvider);
    final state = initState();
    Log.d("--------------------------build---------------------");

    return state;
  }

  // void changeLoadingState(LoadState loadState, String? errorMsg) {
  //   state = state.copyWith(
  //       loadingState: loadState,
  //       errorMessage: errorMsg
  //   );
  // }

  setInitData(BuildContext context,int serviceId, int? cleanServiceTypeId, int serviceStatusCode){
    _serviceId = serviceId;
    _cleanServiceTypeId = cleanServiceTypeId!;
    _serviceStatusCode = serviceStatusCode;
  }

  handlerClickActionBtn(BuildContext context, Map<String, dynamic> actionBtn){
    final actionBtnCode = actionBtn['code']!.toString();
    switch (actionBtnCode) {
      case '0':
        // context.router.pushNamed('/detail');
        break;
      case '1':
      // context.router.pushNamed('/detail');
        break;
      case '2':
      // context.router.pushNamed('/detail');
        break;
      case '3':
      // context.router.pushNamed('/detail');
        break;
      case '4':
        // 去评价
        // context.router.pushNamed('/detail');
        ServiceEvaluateCreatePage.startInstance(id: _serviceId, cleanServiceTypeId: _cleanServiceTypeId,);
        break;
      default:
        break;
    }
  }
}
