
import 'package:flutter/cupertino.dart';
import 'package:liftmanager/internal/notification/page/notification_list_page.dart';
import 'package:liftmanager/mvp/base_page_presenter.dart';
import 'package:liftmanager/net/api_service.dart';
import 'package:liftmanager/widgets/state_layout.dart';

class NotificationListPresenter extends BasePagePresenter<NotificationListPageState> {
  Future myTeamList(BuildContext context) async {
    await ApiService(context: context).teamList(onSuccess: (data) {
      if (data != null) {
        view.provider.list.clear();
        if (data.isEmpty) {
          view.provider.setStateType(StateType.empty);
        } else {
          view.provider.addAll(data);
        }
      } else {
        /// 加载失败
        view.provider.setHasMore(false);
        view.provider.setStateType(StateType.empty);
      }
    }, onError: (code, msg) {
      view.provider.setHasMore(false);
      view.provider.setStateType(StateType.network);
    });
  }
}
