import { Gtk } from "ags/gtk4";
import { TileNetwork } from "./tiles/Network";
import { TileBluetooth } from "./tiles/Bluetooth";
import { TileDND } from "./tiles/DoNotDisturb";
import { TileRecording } from "./tiles/Recording";
import { TileNightLight } from "./tiles/NightLight";
import { Pages } from "./Pages";


export let TilesPages: Pages|undefined;
export const tileList: Array<() => JSX.Element|Gtk.Widget> = [
    TileNetwork,
    TileBluetooth,
    TileRecording,
    TileDND,
    TileNightLight
] as Array<() => Gtk.Widget>;

export function Tiles(): Gtk.Widget {
    return <Gtk.Box class={"tiles-container"} orientation={Gtk.Orientation.VERTICAL}
      onUnmap={() => TilesPages = undefined}>

        <Gtk.FlowBox orientation={Gtk.Orientation.HORIZONTAL} rowSpacing={6}
          columnSpacing={6} minChildrenPerLine={2} activateOnSingleClick
          maxChildrenPerLine={2} hexpand homogeneous>

            {tileList.map(t => t())}
        </Gtk.FlowBox>

	<Pages class={"tile-pages"} $={(self) => TilesPages = self} />
    </Gtk.Box> as Gtk.Box;
}
