use nightshade::prelude::*;

pub fn render_drop_overlay_with_category(
    ui_context: &egui::Context,
    category: Option<&str>,
    messages: &[(&str, &str)],
    default_message: &str,
) {
    let message = category
        .and_then(|category| {
            messages
                .iter()
                .find(|(name, _)| *name == category)
                .map(|(_, message)| *message)
        })
        .unwrap_or(default_message);

    egui::Area::new(egui::Id::new("drop_indicator"))
        .anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
        .show(ui_context, |ui| {
            ui.with_layout(egui::Layout::top_down(egui::Align::Center), |ui| {
                let frame = egui::Frame::default()
                    .fill(egui::Color32::from_rgba_premultiplied(30, 30, 30, 200))
                    .corner_radius(10.0)
                    .stroke(egui::Stroke::new(
                        2.0,
                        egui::Color32::from_rgb(100, 150, 250),
                    ))
                    .inner_margin(30.0);

                frame.show(ui, |ui| {
                    ui.heading(message);
                });
            });
        });
}
