/*
 * @author zzg
 * @date   2019-09-16
 **/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/MessageRepository.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/live/LiveData.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';

class AttentionModel extends BaseModel {
  LiveData<AttentionEntity> zzgLive = new LiveData();

  int page;
  int count;

  AttentionModel(this.page, this.count);

  init(BuildContext context) {
    page = 1;
    MessageRepository.getInstance().getAttentionList(page, count).listen((value) {
      if (value != null) {
        zzgLive.notifyView(value);
      }
    }).onError((error) {
      Toast.show(context, "${error.toString()}");
      print(error);
    });
  }

  more (BuildContext context) {
    page++;
    init(context);
  }

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