import 'package:liftmanager/internal/bbs/page/tab/video/video_list.dart';
import 'package:liftmanager/internal/wode/page/video/my_video.dart';
import 'package:liftmanager/mvp/base_page_presenter.dart';
import 'package:liftmanager/net/api_service.dart';
import 'package:liftmanager/widgets/state_layout.dart';

class   VideoListPresenterSeconds extends BasePagePresenter<VideoListState> {

  Future getVideoList(int page,int brandIdss,String title) async {
    await NewApiService().getVideoList(page,10,null,title,brandIdss,"app",onSuccess: (res) {
      print('视频列表');
      print(res);
      view.closeProgress();
      if (res != null) {
        view.provider.setHasMore(res.records.length == 10);
        if(page == 1){
          view.provider.list.clear();
          if (res.records.isEmpty) {
            view.provider.setStateType(StateType.empty);
          } else {
            view.provider.addAll(res.records);
          }
        }else{
          view.provider.addAll(res.records);
        }
      } else {
        /// 加载失败
        view.provider.setHasMore(false);
        view.provider.setStateType(StateType.empty);
      }
    }, onError: (code, msg) {
      view.closeProgress();
      view.provider.setHasMore(false);
      view.provider.setStateType(StateType.network);
    });
  }
}

class   MyVideoListPresenter extends BasePagePresenter<MyVideoState> {

  Future getVideoList(int page,int userId,String title) async {
    await NewApiService().getVideoList(page,10,userId,title,null,"web",onSuccess: (res) {
      print('我的视频列表');
      print(res);
      view.closeProgress();
      if (res != null) {
        view.provider.setHasMore(res.records.length == 10);
        if(page == 1){
          view.provider.list.clear();
          if (res.records.isEmpty) {
            view.provider.setStateType(StateType.empty);
          } else {
            view.provider.addAll(res.records);
          }
        }else{
          view.provider.addAll(res.records);
        }
      } else {
        /// 加载失败
        view.provider.setHasMore(false);
        view.provider.setStateType(StateType.empty);
      }
    }, onError: (code, msg) {
      view.closeProgress();
      view.provider.setHasMore(false);
      view.provider.setStateType(StateType.network);
    });
  }
}


// class MyVideoListPresenterThird extends BasePagePresenter<CollectPageState> {

//   Future getVideoList(int page,int userId) async {
//     await NewApiService().getVideoList(page,3,null,1,userId,onSuccess: (res) {
//       print('我的视频列表');
//       print(res);
//       view.closeProgress();
//       if (res != null) {
//         view.providerVideo.setHasMore(res.records.length == 3);
//         if(page == 1){
//           view.providerVideo.list.clear();
//           if (res.records.isEmpty) {
//             view.providerVideo.setStateType(StateType.empty);
//           } else {
//             view.providerVideo.addAll(res.records);
//           }
//         }else{
//           view.providerVideo.addAll(res.records);
//         }
//       } else {
//         /// 加载失败
//         view.providerVideo.setHasMore(false);
//         view.providerVideo.setStateType(StateType.empty);
//       }
//     }, onError: (code, msg) {
//       view.closeProgress();
//       view.providerVideo.setHasMore(false);
//       view.providerVideo.setStateType(StateType.network);
//     });
//   }
// }
