// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   TreatmentAdjustmentEndIsolatedUf.qml is the screen
 *          To adjust the treatment ultrafiltration
 */
Item { id: _root

    readonly property real volumeGoal       : vTreatmentIsolatedUF.setVolume
    readonly property real volumeRemoved    : vTreatmentIsolatedUF.volumeDelivered

    signal endIsoUfClicked()

    TreatmentAdjustmentUltrafiltrationMetrics { id: _ufMetrics
        objectName: "_ufMetrics"
        anchors {
            top             : parent.top
            topMargin       : Variables.defaultMargin
            horizontalCenter: parent.horizontalCenter
        }
        leftLabel   : qsTr("Isolated UF Volume Removed")
        leftUnit    : Variables.unitVolume
        leftValue   : _root.volumeRemoved.toFixed(Variables.ultrafiltrationPrecision)
        rightLabel  : qsTr("Isolated UF Volume Goal")
        rightUnit   : Variables.unitVolume
        rightValue  : _root.volumeGoal.toFixed(Variables.ultrafiltrationPrecision)
    }

    Item { id: _contentArea
        objectName: "_contentArea"
        anchors {
            top         : _ufMetrics.bottom
            bottom      : _buttonArea.top
            left        : parent.left
            right       : parent.right
        }

        ProgressBarEx { id: _progressBarEx
            objectName  : "_progressBarEx"
            anchors {
                centerIn    : parent
            }
            decimal     : Variables.ultrafiltrationPrecision
            minimum     : vTreatmentRanges.treatmentRanges_Ultrafiltration_Volume_Min
            maximum     : _root.volumeGoal
            value       : _root.volumeRemoved
            valueEx     : _root.volumeRemoved
        }
    }

    Row { id: _buttonArea
        objectName: "_buttonArea"
        anchors {
            bottom          : parent.bottom
            bottomMargin    : Variables.defaultMargin
            horizontalCenter: parent.horizontalCenter
        }
        spacing             : Variables.defaultMargin

        TouchRect { id: _endIsolatedUfButton
            objectName  : "_endIsolatedUfButton"
            width       : Variables.defaultButtonWidth
            height      : Variables.defaultButtonHeight
            text {
                text        : qsTr("End Isolated UF")
                font.weight : Font.Medium
            }
            isDefault   : true
            onClicked   : _root.endIsoUfClicked()
        }
    }
}
