/*
 * @Author: XianKaiQun
 * @LastEditors  : WuWei
 * @Date: 2020-10-26 09:50:35
 * @LastEditTime : 2023-05-19 10:58:51
 */

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:oa_package/src/components/item.dart';
import 'package:oa_package/src/view_models/management_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
// import 'store.dart';
part 'components/tabbar.dart';

class ManagementPageView extends StatelessWidget {
  const ManagementPageView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<ManagementStore>(context, listen: false);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        title: WisText(
          '审批管理',
          size: 19.pt,
          weight: FontWeight.w600,
          color: colorScheme.mainTitle,
        ),
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
      ),
      body: Column(
        children: [
          _TabbarComponent(),
          IndexedStack(
            children: [
              WisScrollView(
                key: store.taskScrollViewKey,
                controller: store.viewController,
                emptyWidget: SliverToBoxAdapter(
                  child: WisCard(
                    margin: EdgeInsets.all(15.pt),
                    child: Wisdom.column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      margin: EdgeInsets.only(top: 10.pt),
                      padding: EdgeInsets.symmetric(vertical: 50.pt),
                      color: Colors.white,
                      children: [
                        WEmptyWidget(
                          text: Text(
                            '没有事项哦！',
                            style: TextStyle(
                              fontSize: 14.pt,
                              fontWeight: FontWeight.w300,
                              color: colorScheme.minor,
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                onInit: () => store.setindexStack(
                    store.names[store.arguments.indexStack ?? 0]['type']!),
                onLoad: () => store.onGetTaskTypeList(),
                slivers: [
                  Observer(builder: (_) {
                    return WisSliverList.childBuilder(
                      childCount: store.taskTypeList.length,
                      builder: (_, i) {
                        /// 列表元素
                        return new ItemComponent(
                          item: store.taskTypeList[i],
                        );
                      },
                    );
                  })
                ],
              )
            ],
            //   );
            // },
          ).asExpanded()
        ],
      ),
    );
  }
}
