package ui

import (
	"os"

	"gioui.org/app"
	"gioui.org/unit"
	"github.com/rs/zerolog/log"
)

// Init initializes and runs the UI.
func Init() {
	go func() {
		window := new(app.Window)
		window.Option(app.Title("ICDB"))
		window.Option(app.MinSize(unit.Dp(700), unit.Dp(400)))
		window.Option(app.Size(unit.Dp(800), unit.Dp(600)))
		window.Option(app.Orientation.Option(app.LandscapeOrientation))
		err := run(window)
		if err != nil {
			log.Fatal().Err(err).Msg("UI loop exited with error")
		}
		os.Exit(1)
	}()
	app.Main()
}
