/*!
 *
 * Copyright (c) 2020-2025 Diality Inc. - All Rights Reserved.
 * \copyright
 * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
 * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
 *
 * \file    TreatmentAdjustmentUltrafiltrationMetrics.qml
 * \author  (last)      Stephen Quong
 * \date    (last)      19-Aug-2025
 * \author  (original)  Stephen Quong
 * \date    (original)  19-Aug-2025
 *
 */

// Qt
import QtQuick 2.12

// Project

//  Qml imports
import "qrc:/globals"

/*!
 * \brief   TreatmentAdjustmentUltrafiltrationMetrics contains components
 *          that display the ultrafiltration volume removed and goal.
 */
Item { id: _root
    property real   setVolume           : 0
    property real   volumeRemoved       : 0
    property color  volumeRemovedColor  : Colors.fluidText

    implicitWidth   : (_ufVolumeRemovedItem.width * 2) + Variables.columnSpacing
    implicitHeight  : _ufVolumeRemovedItem.height

    component ValueItem: Rectangle { id: _valueItem
        property alias label        : _label.text
        property alias value        : _value.text
        property color textColor    : Colors.offWhite
        anchors.centerIn    : parent
        width               : 425
        height              : Variables.adjustmentLabelUnitContainerHeight
        radius              : 5
        color               : Colors.panelBackgroundColor
        border {
            width   : Variables.panelBorderWidth
            color   : Colors.panelBorderColor
        }

        Item { id: _contentItem
            anchors.centerIn: parent
            width           : childrenRect.width
            height          : parent.height

            Text { id: _label
                anchors {
                    left            : parent.left
                    verticalCenter  : parent.verticalCenter
                }
                width   : contentWidth
                color   : _valueItem.textColor
                font {
                    pixelSize   : 23
                    weight      : Font.Medium
                }
            }

            Text { id: _unit
                anchors {
                    left        : _label.right
                    leftMargin  : 5
                    baseline    : _label.baseline
                }
                width   : contentWidth
                text    : ("(%1) :").arg(Variables.unitVolume)
                color   : _valueItem.textColor
                font {
                    pixelSize   : 20
                }
            }

            Text { id: _value
                anchors{
                    left        : _unit.right
                    leftMargin  : 5
                    baseline    : _label.baseline
                }
                width               : 60
                horizontalAlignment : Text.AlignLeft
                color               : _valueItem.textColor
                font {
                    pixelSize       : Fonts.fontPixelUltrafiltrationAdjustmentMetrics
                    weight          : Font.DemiBold
                }
            }
        }
    }

    ValueItem { id: _ufVolumeRemovedItem
        anchors {
            horizontalCenter        : parent.horizontalCenter
            horizontalCenterOffset  : -(width + Variables.columnSpacing)/2
            verticalCenter          : parent.verticalCenter
        }
        label   : qsTr("UF Volume Removed")
        value   : _root.volumeRemoved.toFixed(Variables.ultrafiltrationPrecision)
    }

    ValueItem { id: _ufVolumeGoalItem
        anchors {
            horizontalCenter        : parent.horizontalCenter
            horizontalCenterOffset  : -(_ufVolumeRemovedItem.anchors.horizontalCenterOffset)
            verticalCenter          : parent.verticalCenter
        }
        textColor   : _root.volumeRemovedColor
        label       : qsTr("UF Volume Goal")
        value       : _root.setVolume.toFixed(Variables.ultrafiltrationPrecision)
    }
}
