import { Close, Minimize, WebAssetOutlined } from "@mui/icons-material";
import { Box, IconButton, Stack } from "@mui/material";
import { getCurrentWindow } from "@tauri-apps/api/window";

export const WindowButtons = () => {
  const minimize = () => {
    const appWindow = getCurrentWindow();
    appWindow.minimize();
  };

  const toggleMaximize = () => {
    const appWindow = getCurrentWindow();
    appWindow.toggleMaximize();
  };

  const close = async () => {
    const appWindow = getCurrentWindow();
    appWindow.close();
  };

  return (
    <Box
      sx={{
        alignItems: "center",
        display: "flex",
        flexDirection: "row",
      }}
    >
      <Stack direction="row" spacing={1}>
        <IconButton onClick={minimize} size="small">
          <Minimize fontSize="inherit" />
        </IconButton>
        <IconButton onClick={toggleMaximize} size="small">
          <WebAssetOutlined fontSize="inherit" />
        </IconButton>
        <IconButton onClick={close} size="small">
          <Close fontSize="inherit" />
        </IconButton>
      </Stack>
    </Box>
  );
};
