package ui

import (
	"icdb/internal/ui/routing"
	"icdb/internal/ui/views"
	t_ui "icdb/pkg/types/ui"

	"gioui.org/layout"
	"gioui.org/widget/material"
)

// renderView dynamically loads the selected view
func renderView(th *material.Theme) layout.Widget {
	return func(gtx layout.Context) layout.Dimensions {
		switch routing.Current() {
		case t_ui.UIViewHome:
			return views.HomeView(gtx, th)
		case t_ui.UIViewParts:
			return views.PartsView(gtx, th)
		case t_ui.UIViewCategories:
			return views.CategoriesView(gtx, th)
		case t_ui.UIViewLocations:
			return views.LocationsView(gtx, th)
		case t_ui.UIViewSettings:
			return views.SettingsView(gtx, th)
		default:
			return views.HomeView(gtx, th)
		}
	}
}
