/*
 * @Author       : WuWei
 * @LastEditors: wjc
 * @Date         : 2023-02-21 15:11:37
 * @LastEditTime: 2023-04-03 11:53:07
 * @Description  : Do not edit
 */
import 'package:app_package/src/pages/notice/components/list.dart';
import 'package:app_package/src/view_models/message_index_store.dart';
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

class NoticeListDetailPage extends StatelessWidget {
  const NoticeListDetailPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => MessageIndexStore(context),
      child: _PageView(),
      lazy: false, //取消懒加载，懒加载可能会导致获取路由传参不准确
    );
  }
}

class _PageView extends StatefulWidget {
  _PageView({Key? key}) : super(key: key);
  @override
  _PageViewState createState() => _PageViewState();
}

class _PageViewState extends State<_PageView> {
  MessageIndexStore get store => Provider.of(context, listen: false);

  @override
  Widget build(BuildContext context) {
    // final style = WTheme.of(context);final colorScheme = style.colorScheme;
    if (store.list.length == 0) {
      store.scorllViewKey.currentState?.refreshTrigger();
    }
    final colorScheme = WTheme.of(context).colorScheme;
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
        title: WisText('${store.args['appBarTitle'] ?? '消息提醒'}',
            size: 19.pt, weight: FontWeight.w600, color: colorScheme.mainTitle),
      ),
      body: WisScrollView(
        key: store.scorllViewKey,
        onInit: () => store.initPage(),
        onRefresh: () => store.initPage(),
        onLoad: () => store.getList(isLoad: true),
        slivers: <Widget>[
          ListComponent(),
        ],
      ),
    );
  }
}
