/*
 * @Author: XianKaiQun
 * @Date: 2020-07-29 11:50:15
 * @LastEditors  : WuWei
 * @LastEditTime : 2022-01-19 15:36:29
 * @Description: 
 */

import 'package:app_package/app_package.dart';
import 'package:flutter/material.dart';
import 'package:qrcode_package/src/models/repair_equipment_record.dart';
import 'package:qrcode_package/src/view_models/private_repair_item_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

part 'components/maintain.dart';
part 'components/motify.dart';
part 'components/repair.dart';
part 'components/anti_cheating.dart';

///设备二级详情
class RepairDetailItemPage extends StatelessWidget {
  const RepairDetailItemPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (providerContext) =>
          PrivateRepairDetailItemStore(context, providerContext),
      child: _PageView(),
      lazy: false,
    );
  }
}

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

class _PageViewState extends State<_PageView> {
  // PrivateRepairDetailItemStore get store => Provider.of(context, listen: false);
  @override
  Widget build(BuildContext context) {
    final PrivateRepairDetailItemStore store = Provider.of(context);
    final colorScheme = WTheme.of(context).colorScheme;
    final theme = Theme.of(context);
    final textTheme = theme.textTheme;
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
        title: WisText('操作内容',
            size: 19.pt, weight: FontWeight.w600, color: colorScheme.mainTitle),
      ),
      body: WisScrollView(
        onInit: () => store.getData(),
        onRefresh: () => store.getData(),
        slivers: <Widget>[
          Wisdom(
            padding: EdgeInsets.all(15.pt),
            child: Text(
              store.data?.equipmentName ?? '',
              style: textTheme.titleMedium!.copyWith(
                fontWeight: FontWeight.bold,
              ),
            ),
          ).asSliver(),
          _MotifyComponent(),
          _RepairComponent(),
          _MaintainComponent(),
          _AntiCheatingComponent(),
        ],
      ),
    );
  }
}
