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

CustomRect {
	id: root

	property bool first
	property bool last
	property string settingAnchor

	function flashHighlight(): void {
		flash.restart();
	}

	bottomLeftRadius: last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
	bottomRightRadius: last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
	color: Colors.tPalette.m3surfaceContainer
	opacity: enabled && parent.enabled ? 1 : 0.5
	topLeftRadius: first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
	topRightRadius: first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall

	Behavior on opacity {
		Anim {
		}
	}

	CustomRect {
		id: highlight

		anchors.fill: parent
		bottomLeftRadius: parent.bottomLeftRadius
		bottomRightRadius: parent.bottomRightRadius
		color: Colors.palette.m3primary
		opacity: 0
		radius: parent.radius
		topLeftRadius: parent.topLeftRadius
		topRightRadius: parent.topRightRadius

		SequentialAnimation {
			id: flash

			Anim {
				duration: Tokens.anim.durations.small
				property: "opacity"
				target: highlight
				to: 0.2
			}

			Anim {
				duration: Tokens.anim.durations.normal
				property: "opacity"
				target: highlight
				to: 0.08
			}

			Anim {
				duration: Tokens.anim.durations.small
				property: "opacity"
				target: highlight
				to: 0.2
			}

			Anim {
				duration: Tokens.anim.durations.extraLarge
				property: "opacity"
				target: highlight
				to: 0
			}
		}
	}
}
