/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-03-23 17:11:18
 * @LastEditTime : 2023-03-30 14:48:43
 * @Description  : Do not edit
 */

import 'package:app_package/app_package.dart';
import 'package:flutter/material.dart';
import 'package:qrcode_package/src/view_models/private_repair_handle_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

part 'components/desc.dart';
part 'components/norm.dart';
part 'components/form.dart';
part 'components/prevent_cheating.dart';

///巡检、保养页
class RepairHandlePage extends StatelessWidget {
  const RepairHandlePage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (providerContext) =>
          PrivateRepairHandleStore(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> {
  PrivateRepairHandleStore get store => Provider.of(context, listen: false);
  @override
  Widget build(BuildContext context) {
    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.title,
            size: 19.pt, weight: FontWeight.w600, color: colorScheme.mainTitle),
      ),
      body: WisForm(
        formKey: null,
        child: WisScrollView(
          onInit: () => store.getData(),
          slivers: <Widget>[
            _DescComponent(),
            _NormComponent(),
            _FormComponent(),
            _PreventCheatingComponent(),
            WLoadingButton(
              onPressed: () => store.submit(),
              margin: EdgeInsets.all(15.pt),
              height: 44.pt,
              child: Text('完成'),
            ).asSliver(),
          ],
        ),
      ),
    );
  }
}
