import QtQuick 2.10
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15

Row {
    id: control

    property bool active: (parseInt(widgetData[ "route_order" ]) === 0) && (widgetData["discipline"] === "speed") && (thisData["result_l"] !== undefined || thisData["result_r"] !== undefined)
    property var thisData: widgetData["participants"][partDel.thisIndex]

    height: parent.height
    width:  active ? parent.width - resultLa.width:0

    enabled: active

    Repeater {
        id: generalResRep

        model: 2

        delegate: Item {
            id: boulderGenResItm

            anchors.verticalCenter: parent.verticalCenter

            width: parent.width / ( generalResRep.model )
            height: parent.height

            visible: control.active

            Rectangle {

                anchors {
                    left: parent.left
                }

                width: 1
                height: parent.height

                visible: index === 0

                color: Material.primaryTextColor
            }

            Rectangle {
                anchors {
                    right: parent.right
                }

                width: 1
                height: parent.height

                color: Material.primaryTextColor
            }

            Label {
                id: boulderGenResLa

                property string thisKey: "result_"+(["l", "r"][index])

                anchors.centerIn: parent

                height: parent.height
                width: parent.width * 0.9

                fontSizeMode: Text.Fit
                font.pixelSize: Math.abs( height * 0.6 )
                minimumPixelSize: 1
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                font.bold: thisData["result_l"] !== undefined && thisData["result_r"] !== undefined && thisData[thisKey] === thisData["result"]

                text: control.thisData[thisKey] ?? ""
            }

        }

    }
}
