/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2022-11-02 10:26:38
 * @LastEditTime : 2023-03-30 14:49:25
 * @Description  : Do not edit
 */
import 'package:app_package/app_package.dart';
import 'package:flutter/material.dart';
import 'package:qrcode_package/src/view_models/private_security_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

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

class SecurityPage extends StatelessWidget {
  const SecurityPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (providerContext) =>
          PrivateSecurityStore(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> {
  PrivateSecurityStore get store => Provider.of(context, listen: false);
  @override
  Widget build(BuildContext context) {
    final colorScheme = WTheme.of(context).colorScheme;
    final formKey = GlobalKey<FormState>();
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
        title: WisText('安保巡检'),
      ),
      body: WisForm(
        formKey: formKey,
        child: WisScrollView(
          onInit: () => store.getData(),
          slivers: <Widget>[
            _DescComponent(),
            _FormComponent(),
            SliverToBoxAdapter(
              child: WLoadingButton(
                onPressed: () => store.submit(),
                margin: EdgeInsets.all(15.pt),
                height: 44.pt,
                child: Text('完成'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
