/*
 * @Author: XianKaiQun
 * @Date: 2020-09-11 09:41:44
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-03-31 10:42:40
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:metered_package/src/assets.gen.dart';
import 'package:metered_package/src/view_models/private_detail_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

part 'components/desc.dart';
part 'components/table.dart';

class DetailPage extends StatelessWidget {
  const DetailPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (providerContext) => PrivateDetailStore(context, providerContext),
      child: _PageView(),
      lazy: false,
    );
  }
}

class _PageView extends StatelessWidget {
  const _PageView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PrivateDetailStore>(context, listen: false);
    return WillPopScope(
       onWillPop: () async {
        // 处理返回键事件
        // 这里可以添加您想要执行的操作，比如弹出对话框确认退出
         // 返回true表示允许页面退出，返回false表示阻止页面退出
         Navigator.pop(context, store.isDelete);
         return true;
      },
        child: Scaffold(
            appBar: WAppBar(
              brightness: Brightness.dark,
              title: WisText(
                '抄表记录',
                size: 19.pt,
                weight: FontWeight.w600,
                color: Colors.white,
              ),
              iconTheme: IconThemeData(
                color: Colors.white,
                size: 19.pt,
              ),
            ),
            body: Column(
              children: [
                _DescComponent(),
                _TableComponent(),
              ],
            ),),
        );
  }
}
