/*
 * @Author       : WuWei
 * @LastEditors: wjc
 * @Date         : 2023-03-23 17:11:18
 * @LastEditTime: 2023-03-30 15:35:45
 * @Description  : Do not edit
 */

import 'package:flutter/material.dart';
import 'package:task_package/src/view_models/private_dash_board_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

part 'components/exponent.dart';
part 'components/task.dart';
part 'components/table.dart';
part 'components/statistics.dart';

class DashBoardPage extends StatelessWidget {
  const DashBoardPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (providerContext) =>
              PrivateDashBoardStore(context, providerContext),
          lazy: false,
        )
      ],
      child: _PageView(),
    );
  }
}

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

class _PageViewState extends State<_PageView> {
  PrivateDashBoardStore 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.routingArgs['appBarTitle'] ?? '任务仪表盘'}',
          size: 19.pt,
          weight: FontWeight.w600,
          color: colorScheme.mainTitle,
        ),
      ),
      body: WisScrollView(
        onInit: () => store.getData(),
        onRefresh: () => store.getData(),
        slivers: <Widget>[
          _ExponentComponent(),
          _TaskComponent(),
          _TableComponent(),
          _StatisticsComponent(),
        ],
      ),
    );
  }
}
