/*
 * @author lsy
 * @date   2019-09-16
 **/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/PrestigeRepository.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/live/LiveData.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';

class ReputationsModel extends BaseModel {

  LiveData<PrestigeEntity> prestigeLive = new LiveData();

  final String cookie;

  ReputationsModel(this.cookie);

  init(BuildContext context) {
    Map<String, dynamic> headMap = new Map();
    headMap.putIfAbsent("Cookie", () => cookie);
    DioUtil.addHeadMap=headMap;
    PrestigeRepository.getInstance().getReputations().listen((value) {
      if (value != null) {
        prestigeLive.notifyView(value);
      }
    }).onError((error) {
      Toast.show(context, "${error.toString()}");
      print(error);
    });
  }

  @override
  void dispose() {
    prestigeLive.dispost();
  }

}