/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-07-07 15:27:43
 * @LastEditTime : 2023-07-21 15:30:38
 * @Description  : Do not edit
 */
import 'package:app_package/app_package.dart';
import 'package:flutter/widgets.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

import '../impl/industrynew_service_impl.dart';

class SassNewsStore with ChangeNotifier {
  final BuildContext context;
  late Map args;
  SassNewsStore(this.context) {
    args =
        ModalRoute.of(context)!.settings.arguments as Map<dynamic, dynamic>? ??
            {};
  }
  final scorllViewKey = GlobalKey<WisScrollViewState>();
  final communityGlobalStore = GetIt.I.get<CommunityGlobalStore>();
  final appGlobalStore = GetIt.I.get<AppGlobalStore>();

  ///从储存中取出的当前小区 拿出来可能是空
  CommunityModel? get currentCommunity => communityGlobalStore.data;

  late Map<String, dynamic> params = {
    'pageNum': 1,
    'pageSize': 20,
  };

  Future initList() async {
    appGlobalStore.onInitSassNewsList();
  }

  route2detail(item, type) {
    if ((item.jumpLink == null || item.jumpLink == '') &&
        item.informationType == 1) return;
    if (item.informationType == 2) {
      Navigator.pushNamed(context, 'industrynew/sass/detail',
          arguments: item.toJson());
      appGlobalStore.addReadCount(item.id);
    } else {
      IndustryNewsServiceImpl().getNewsDetailV2({
        'id': item.id,
      });
      WisWebViewUtil.openPage(
        initialUrl: item.jumpLink,
      );
      appGlobalStore.addReadCount(item.id);
    }
  }
}
