use bevy::prelude::*;
use bevy_egui::{EguiContexts, EguiPlugin, EguiPrimaryContextPass};
use egui_file::FileDialog;

fn main() {
  let mut dialog = FileDialog::open_file();
  dialog.open();

  let ui_example_system = move |mut contexts: EguiContexts| -> Result {
    dialog.show(contexts.ctx_mut()?);
    Ok(())
  };

  App::new()
    .add_plugins(DefaultPlugins)
    .add_plugins(EguiPlugin::default())
    .add_systems(Startup, setup_camera_system)
    .add_systems(EguiPrimaryContextPass, ui_example_system)
    .run();
}

fn setup_camera_system(mut commands: Commands) {
  commands.spawn(Camera2d);
}
