import 'package:flutter/material.dart';
import 'package:hub/features/menu/index.dart';

enum EnumMenuItem {
  button,
  card,
  tile;

  MenuItem getInstance(
      final Function() action, final String title, final IconData icon) {
    switch (this) {
      case EnumMenuItem.button:
        return ButtonMenuItem(action: action, title: title, icon: icon);
      case EnumMenuItem.card:
        return CardMenuItem(action: action, title: title, icon: icon);
      case EnumMenuItem.tile:
        return CardMenuItem(action: action, title: title, icon: icon);
    }
  }
}

abstract class MenuItem extends StatefulWidget {
  const MenuItem({
    super.key,
    required this.action,
    required this.title,
    required this.icon,
  });

  final Function() action;
  final String title;
  final IconData icon;

  factory MenuItem.create(
    EnumMenuItem type, {
    Key? key,
    required Function() action,
    required String title,
    required IconData icon,
  }) {
    return type.getInstance(action, title, icon);
  }
}
