/*
 * @Author: XianKaiQun
 * @Date: 2020-07-28 17:44:28
 * @LastEditors: ,: XianKaiQun
 * @LastEditTime: ,: 2020-10-20 11:02:36
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:qrcode_package/src/view_models/private_clean_list_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

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

class CleanListPage extends StatelessWidget {
  const CleanListPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (providerContext) =>
          PrivateCleanListStore(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> {
  PrivateCleanListStore 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('保洁位置详情',
            size: 19.pt, weight: FontWeight.w600, color: colorScheme.mainTitle),
      ),
      body: WisScrollView(
        key: store.scrollViewKey,
        onInit: () => store.onInit(),
        onRefresh: () => store.onInit(),
        onLoad: () => store.getList(isLoad: true),
        slivers: <Widget>[
          _DescComponent(),
          SliverToBoxAdapter(
            child: WButton(
              onPressed: () => store.route2Form(),
              margin: EdgeInsets.fromLTRB(15.pt, 15.pt, 15.pt, 0),
              height: 44.pt,
              child: Text('保洁'),
            ),
          ),
          _ListComponent(),
        ],
      ),
    );
  }
}
