local UI = {}

--print("hallo")

--orientations = { horizontal = 0, vertical = 1 }

function merge(into, from)
	for k, v in pairs(from) do
		into[k] = v
	end
	return into
end

-- TODO margin, border, padding?

function UI.View(options)
	return {
		id = options.id,
		type = options.type
	}
end


function UI.TextView(options)
	return merge(UI.View(merge(options, { type = "TextView" })), {
		text = options.text or "TextView"
	})
end

function UI.ImageView(options)
	return merge(UI.View(merge(options, { type = "ImageView" })), {
		src = options.src -- or "ImageView"
	})
end


function UI.ContentView(options)
	return merge(UI.View(options), {
		content = options.content
	})
end

function UI.Button(options)
	return UI.ContentView(merge(options, {
		type = "Button",
		content = options.content or "Button",
	}))
end


function UI.ViewGroup(options)
	--return merge(UI.View(options), {
	--	children = options.children
	--})
	local t = UI.View(options)
	for i = 1, #options do
		t[i] = options[i]
	end
	return t
end

function UI.LinearLayout(options)
	return merge(UI.ViewGroup(merge(options, { type = "LinearLayout" })), {
		orientation = options.orientation or "horizontal"
	})
end

return UI
