import 'package:flutter/material.dart';
import 'package:toolbox/data/res/ui.dart';

class PopupMenu<T> extends StatelessWidget {
  final List<PopupMenuEntry<T>> items;
  final void Function(T) onSelected;
  final Widget child;
  final EdgeInsetsGeometry padding;
  final T? initialValue;

  const PopupMenu({
    super.key,
    required this.items,
    required this.onSelected,
    this.child = popMenuChild,
    this.padding = const EdgeInsets.all(7),
    this.initialValue,
  });

  @override
  Widget build(BuildContext context) {
    return PopupMenuButton<T>(
      itemBuilder: (_) => items,
      onSelected: onSelected,
      initialValue: initialValue,
      padding: padding,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
      child: child,
    );
  }
}
