import 'package:fis_measure/interfaces/process/items/item_metas.dart';
import 'package:fis_measure/interfaces/process/items/types.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/lab/color/lab_colors.dart';

import 'rvsp.dart';
import 'pisa.dart';

abstract class LabCustomComboItemConfig {
  static final types = <String, List<String>>{
    MeasureTypes.RVSP: ["Rap"],
    MeasureTypes.PISA: ["AlsVel"],
  };
}

class LabCustomComboItemButton extends StatelessWidget {
  final String typeName;
  final String itemName;

  const LabCustomComboItemButton(
      {super.key, required this.typeName, required this.itemName});

  @override
  Widget build(BuildContext context) {
    return _SpecialChildItemWidget(itemName: itemName);
    return Container(
      width: double.infinity,
      margin: const EdgeInsetsDirectional.all(5),
      child: ElevatedButton(
        onPressed: () {
          _SpecialChildItemWidget(itemName: itemName);
        },
        child: Text(
          itemName,
          style: TextStyle(color: LabColors.text700),
        ),
        style: ElevatedButton.styleFrom(
          elevation: 0,
          backgroundColor: LabColors.base200,
          side: BorderSide(
            color: LabColors.buttonColor,
          ),
        ),
      ),
    );
  }
}

class _SpecialChildItemWidget extends StatelessWidget {
  late final Map<String, WidgetBuilder> _specialWidgetMap = {
    "Rap": buildRap,
    "AlsVel": buildAlsVel,
  };

  final String itemName;

  _SpecialChildItemWidget({required this.itemName});

  @override
  Widget build(BuildContext context) {
    final builder = _specialWidgetMap[itemName]!;
    final widget = builder(context);
    return widget;
  }

  Widget buildRap(BuildContext context) {
    return const RapItemButton();
  }

  Widget buildAlsVel(BuildContext context) {
    return const AlsVelItemButton();
  }
}
