import 'package:flutter/material.dart';
import 'package:qhd_prevention/http/ApiService.dart';
import 'package:qhd_prevention/pages/home/SafetyCommitment/safety_commitment_dh_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_dh_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_dl_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_dt_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_dz_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_gc_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_icon_grid.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_lsyd_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_mbcd_list.dart';
import 'package:qhd_prevention/pages/home/tap/tabList/work_tab_sxkj_list.dart';
import 'package:qhd_prevention/pages/my_appbar.dart';
import 'package:qhd_prevention/tools/tools.dart';

class SafetyCommitmentTabList extends StatefulWidget {
  const SafetyCommitmentTabList({super.key});

  @override
  State<SafetyCommitmentTabList> createState() => _SafetyCommitmentTabListState();
}

class _SafetyCommitmentTabListState extends State<SafetyCommitmentTabList> {
  late List<Map<String, dynamic>> buttonInfos = [];

  @override
  void initState() {
    super.initState();
    _getData();
  }
  Future<void> _getData() async {

    setState(() {

      buttonInfos = [
        {
          "icon": "assets/icon-apps/icon_101.png",
          "title": "公司安全承诺",
          "unreadCount": 0,
        },
        {
          "icon": "assets/icon-apps/icon_100.png",
          "title": "车间风险研判\n及安全承诺",
          "unreadCount": 0,
        },
        {
          "icon": "assets/icon-apps/icon_102.png",
          "title": "班组风险研判\n及安全承诺",
          "unreadCount": 0,
        },

      ];
    });
  }
  void _handleItemPressed(int index) async {
    switch (index) {
      case 0:await pushPage(SafetyCommitmentDhList(type:1,), context); break;
      case 1:await pushPage(SafetyCommitmentDhList(type:2,), context); break;
      case 2:await pushPage(SafetyCommitmentDhList(type:3,), context); break;

    }
    _getData();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: MyAppbar(title: '危化行业安全承诺'),
      body: SafeArea(
        child: WorkTabIconGrid(
          buttonInfos: buttonInfos,
          onItemPressed: _handleItemPressed,
        ),
      ),
    );
  }
}
