import 'package:flyinsono/lab/color/lab_colors.dart';
import 'package:flyinsono/lab/components/classify_data_selector/classify_data_selector.dart';
import 'package:flyinsono/lab/components/lab_loading_wrapper.dart';
import 'package:flyinsono/lab/pages/lab_export/controller.dart';
import 'package:flyinsono/lab/style/lab_box_decoration.dart';
import 'package:flutter/material.dart';
import 'classify_multiple_list.dart';

class ClassifyDataMultipeSelector extends StatelessWidget {
  const ClassifyDataMultipeSelector({
    Key? key,
    required this.selectedClassifyIndex,
    required this.selectedItemIndex,
    required this.onItemClick,
    required this.onMultipleItemClick,
    required this.classifyData,
    required this.multipleCheckList,
    this.loading = false,
  }) : super(key: key);

  final int selectedClassifyIndex;
  final int selectedItemIndex;
  final Function(int classifyIndex, int itemIndex) onItemClick;
  final Function(int classifyIndex, int itemIndex) onMultipleItemClick;
  final List<ClassifyData> classifyData;
  final bool loading;
  final List<MultipleCheckModel> multipleCheckList;

  @override
  Widget build(BuildContext context) {
    final bool hasData = classifyData.isNotEmpty;
    return Container(
      // decoration: LabBoxDecoration.base,
      child: LabLoadingWrapper(
        margin: EdgeInsets.only(bottom: 80),
        decoration: LabBoxDecoration.base,
        loading: loading,
        child: Padding(
          padding: const EdgeInsets.all(5),
          child: hasData
              ? ListView(
                  children: [
                    for (var i = 0; i < classifyData.length; i++)
                      ClassifyMultipleList(
                        title: classifyData[i].classifyName,
                        projects: classifyData[i].data,
                        multipleCheckList: multipleCheckList,
                        selectedProjectIndex:
                            i == selectedClassifyIndex ? selectedItemIndex : -1,
                        onProjectClick: (index) {
                          onItemClick(i, index);
                        },
                        onMultipleItemClick: (index) {
                          onMultipleItemClick(i, index);
                        },
                      ),
                  ],
                )
              : Center(
                  child: Text(
                    '暂无数据',
                    style: TextStyle(
                      color: LabColors.text600,
                    ),
                  ),
                ),
        ),
      ),
    );
  }
}
