pragma ComponentBehavior: Bound

import QtQuick
import ZShell.Config
import qs.Helpers
import qs.Components
import qs.Services

TimeDialogRow {
	id: root

	required property int start
	required property int end
	property int endCurrent
	property int startCurrent
	openColor: Colors.palette.m3surfaceContainer
	openHeight: Math.min(rootParent.height * 0.8, contentItem?.implicitHeight ?? 0)
	openWidth: Math.min(rootParent.width * 0.8, contentItem?.implicitWidth ?? 0)

	function keyFor(item: var): string {
		return item.id;
	}

	function labelFor(item: var): string {
		return item.label;
	}

	horizontalContentMargin: -Tokens.padding.extraSmall

	content: Component {
		TimeInput {
			id: timeContent
			start: root.start
			end: root.end

			onEndEdit: value => root.endCurrent = value
			onStartEdit: value => root.startCurrent = value
		}
	}

	onOpenChanged: {
		if (open) {
			root.rootParent.interactive = false;
			root.z = 5;
		} else {
			root.rootParent.interactive = true;
			root.z = 1;
		}
	}
}
