/*!
 *
 * Copyright (c) 2020-2024 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    TreatmentAdjustmentUltrafiltrationStart.qml
 * \author  (last)      Vy
 * \date    (last)      16-Mar-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  12-May-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   TreatmentAdjustmentUltrafiltrationStart.qml is the screen
 *          To adjust the treatment ultrafiltration
 */
Item { id: _root
    objectName: "_TreatmentAdjustmentUltrafiltrationStart"  // SquishQt testability

    QtObject { id: _private
        objectName: "_private"
        readonly property real minimum  : vTreatmentRanges.treatmentRanges_Ultrafiltration_Volume_Min
        readonly property real maximum  : vTreatmentRanges.treatmentRanges_Ultrafiltration_Volume_Max
        property real setVolume         : vTreatmentUltrafiltration.setVolume
        property real volumeRemoved     : vTreatmentUltrafiltration.volumeRemoved
    }

    signal editClicked()
    signal isolatedUfClicked()
    signal pauseClicked()
    signal resumeClicked()

    TreatmentAdjustmentUltrafiltrationMetrics { id: _ufMetrics
        objectName: "_ufMetrics"
        anchors {
            top             : parent.top
            topMargin       : Variables.defaultMargin
            horizontalCenter: parent.horizontalCenter
        }
        setVolume       : _private.setVolume
        volumeRemoved   : _private.volumeRemoved
    }

    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
            }
            width   : Variables.ultrafiltrationProgressBarWidth
            height  : Variables.ultraFiltrationProgressBarHeight
            decimal : Variables.ultrafiltrationPrecision
            minimum : _private.minimum
            maximum : _private.setVolume
            value   : _private.volumeRemoved
            valueEx : 0
            color   : Colors.ufProgressBarFill
            bgColor : Colors.ufAdjustmentDeltaFill
            radius  : Variables.ultrafiltrationProgressBarRadius
            minText {
                font {
                    pixelSize   : Fonts.fontPixelUltrafiltrationMinMaxLabel
                    weight      : Font.Normal
                }
                color           : Colors.progressBarMinMax
                text            : minimum.toFixed(Variables.ultrafiltrationPrecision) + " " + Variables.unitVolume
            }
            maxText {
                font {
                    pixelSize   : minText.font.pixelSize
                    weight      : minText.font.weight
                }
                color           : Colors.progressBarMinMax
                text            : _private.setVolume.toFixed(Variables.ultrafiltrationPrecision) + " " + Variables.unitVolume
            }
            marker {
                width           : Variables.ultrafiltrationRangeMarkerWidth
                hasHandle       : false
                valueOnTop      : true
                text {
                    anchors.bottomMargin: Variables.ultrafiltrationRangeMarkerTextMargin
                    font {
                        pixelSize: Fonts.fontPixelUltrafiltrationRangeMarker
                        weight   : Font.DemiBold
                    }
                }
            }
        }
    }

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

        TouchRect { id: _pauseResumeButton
            objectName  : "_pauseResumeButton"
            width       : Variables.defaultButtonWidth
            height      : Variables.defaultButtonHeight
            text {
                text        : isUFPaused ? qsTr("Resume UF") : qsTr("Pause UF")
                font.weight : Font.Medium
            }
            isDefault   : true
            onClicked   : isUFPaused ? _root.resumeClicked() : _root.pauseClicked()
        }

        TouchRect { id: _editButton
            objectName  : "_editButton"
            width       : Variables.defaultButtonWidth
            height      : Variables.defaultButtonHeight
            text {
                text        : qsTr("Edit UF")
                font.weight : Font.Medium
            }
            isDefault   : true
            onClicked   : _root.editClicked()
        }

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