import 'package:get/get.dart';
import 'package:news_getx/data/model/categories.dart';
import 'package:news_getx/data/model/channels.dart';
import 'package:news_getx/data/model/news.dart';

class MainState {
  // 分类
  var _categories = Rx<List<CategoryResponse>?>(null);

  set categories(value) => _categories.value = value;

  List<CategoryResponse>? get categories => _categories.value;

  // 新闻翻页
  var _newsPageList = Rx<NewsPageListResponse?>(null);

  set newsPageList(value) => _newsPageList.value = value;

  NewsPageListResponse? get newsPageList => _newsPageList.value;

  void appendNewsPageList(NewsPageListResponse value) {
    if (_newsPageList.value != null) {
      _newsPageList.value!.items?.addAll(value.items!.toList());
    }
  }

  // 新闻推荐
  var _newsRecommend = Rx<NewsItem?>(null);

  set newsRecommend(value) => _newsRecommend.value = value;

  NewsItem? get newsRecommend => _newsRecommend.value;

  // 频道
  var _channels = Rx<List<ChannelResponse>?>(null);

  set channels(value) => _channels.value = value;

  List<ChannelResponse>? get channels => _channels.value;

  // 选中的分类Code
  var _selCategoryCode = "".obs;

  set selCategoryCode(value) => _selCategoryCode.value = value;

  String get selCategoryCode => _selCategoryCode.value;
}
