/*!
 *
 * 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    TreatmentAdjustmentUltrafiltrationConfirm.qml
 * \author  (last)      Stephen Quong
 * \date    (last)      08-Oct-2025
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  18-May-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/compounds"

/*!
 * \brief   TreatmentAdjustmentUltrafiltrationConfirm.qml is the screen
 *          to confirm requested changes to the treatment ultrafiltration setting.
 */
Item { id: _root
    objectName: "_TreatmentAdjustmentUltrafiltrationConfirm"  // SquishQt testability

    property real ultrafiltrationVolume : 0.000
    property real ultrafiltrationRate   : 0.000

    signal confirmVolumeClicked(real vVolume)

    Item { id: _newValuesItem
        objectName: "_newValuesItem"
        anchors {
            top         : parent.top
            bottom      : _confirmButton.top
            left        : parent.left
            right       : parent.right
        }

        TreatmentAdjustmentUltrafiltrationMetrics { id: _newValues
            objectName          : "_newValues"
            anchors {
                top             : parent.top
                topMargin       : Variables.defaultMargin * 2
                horizontalCenter: parent.horizontalCenter
            }

            leftLabel           : qsTr("UF Volume Removed")
            leftUnit            : Variables.unitVolume
            leftValue           :  vTreatmentUltrafiltration.volumeRemoved.toFixed(Variables.ultrafiltrationPrecision)
            rightLabel          : qsTr("UF Volume Goal")
            rightUnit           : Variables.unitVolume
            rightValue          : _root.ultrafiltrationVolume.toFixed(Variables.ultrafiltrationPrecision)
            rightColor          : Colors.ufVolumeGoalText
        }

        Rectangle { id: _divider
            objectName: "_divider"
            anchors {
                top:         _newValues.bottom
                topMargin   : Variables.defaultMargin * 3
                left        : parent.left
                leftMargin  : 50
                right       : parent.right
                rightMargin : anchors.leftMargin
            }
            height  : 2
            color   : Colors.panelBorderColor
        }

        Text { id: _description
            objectName  : "_description"
            anchors {
                top             : _divider.bottom
                topMargin       : _divider.anchors.topMargin
                horizontalCenter: parent.horizontalCenter
            }
            text            : qsTr("A new UF rate will be applied to achieve the ultrafiltration volume goal.")
            color           : Colors.offWhite
            font.pixelSize  : Fonts.fontPixelContainerTitleSmall
        }


        LabelUnitText { id: _newUfRate
            objectName  : "_newUfRate"
            anchors {
                top             : _description.bottom
                topMargin       : _description.anchors.topMargin
                horizontalCenter: parent.horizontalCenter
            }
            width       : 420
            label       : qsTr("UF Rate")
            unit        : Variables.unitTextRate
            value       : _root.ultrafiltrationRate.toFixed(Variables.ultrafiltrationPrecision)
            valueColor  : Colors.ufVolumeGoalText
        }

    }

    TouchRect { id: _confirmButton
        objectName  : "_confirmButton"
        anchors {
            bottom          : parent.bottom
            bottomMargin    : Variables.defaultMargin
            horizontalCenter: parent.horizontalCenter
        }
        width       : Variables.ultrafiltrationButtonWidth
        height      : Variables.ultrafiltrationButtonHeight
        isDefault   : true
        text  {
            text            : qsTr("Confirm")
            font.weight     : Font.Medium
        }

        onClicked: confirmVolumeClicked(_root.ultrafiltrationVolume.toFixed(Variables.ultrafiltrationPrecision))
    }
}
