/*!
 *
 * Copyright (c) 2019-2020 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 TreatmentFluid.qml
 * \author (last) Behrouz NematiPour
 * \date (last) 13-Aug-2020
 * \author (original) Behrouz NematiPour
 * \date (original) 27-Jan-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   Treatment Screen Fluid Management section
 */
TouchArea { id: _root
    property string buttonText          : ""
    property bool   cumulativeVisible   : true

    property int    rowTextSpacing      : 10
    property int    volumeTextWidth     : 60

    property string unit                : ""
    property alias  valueTarget         : _fluidTarget      .value
    property alias  valueCumulative     : _cumulativeValue  .value
    property alias  valueDelivered      : _fluidProgressBar .value

    x       : 0
    y       : 0
    width   : 200
    height  : 200
    isTouchable: false
    title: qsTr("FLUID MANAGEMENT")

    TouchRect { id: _startFluidButton
        enabled : _root.isTouchable
        y       : 45
        width   : 340
        height  : 55
        text.text: buttonText
        textColor: enabled ? Colors.textButton : Colors.textDisableButton
        text.font {
            weight: Font.DemiBold
            pixelSize       : 20
            letterSpacing   :  3
        }
        animated: true
        duration: 100
        onClicked: {
            if (enabled)
                _root.clicked()
        }
    }

    ProgressBar { id: _fluidProgressBar
        anchors {
            top: _startFluidButton.bottom
            topMargin: 50
        }
        width   : parent.width
        height  : Variables.progressbarFluidHeight
        minText.visible : false
        maxText.visible : false
        marker.visible  : false

        value   : 0

        Text { id: _fluidText
            anchors {
                left        : parent.left
                bottom      : parent.bottom
                bottomMargin: 15
            }
            width: parent.width
            text: qsTr("Volume Delivered")
            font.pixelSize: Fonts.fontPixelFluidText
            color: Colors.fluidText
            Text { id: _fluidTarget
                property real value: 0
                width: volumeTextWidth
                anchors {
                    right: parent.right
                    baseline: parent.baseline
                }
                text: qsTr("(%1 %2)").arg(value).arg(_root.unit)
                font.pixelSize: Fonts.fontPixelFluidVolume
                color: Colors.fluidUnit
            }
            Text { id: _fluidUnit
                anchors {
                    right: parent.right
                    rightMargin: volumeTextWidth + rowTextSpacing
                    baseline: parent.baseline
                }
                text: _root.unit
                font.pixelSize: Fonts.fontPixelFluidUnit
                color: Colors.fluidUnit
            }
            Text { id: _fluidValue
                anchors  {
                    right: _fluidUnit.left
                    rightMargin: rowTextSpacing
                    baseline: parent.baseline
                }
                horizontalAlignment: Text.AlignRight
                text: _fluidProgressBar.value
                width: 60
                font.pixelSize: Fonts.fontPixelFluidValue
                color: Colors.fluidText
            }
        }
    }
    Text { id: _cumulativeText
        visible: cumulativeVisible
        anchors {
            left        : parent.left
            top         : _fluidProgressBar.bottom
            topMargin   : 15
        }
        width: parent.width
        text: qsTr("Cumulative Delivery")
        font.pixelSize: Fonts.fontPixelFluidText
        color: Colors.fluidText
        Text { id: _cumulativeUnit
            anchors {
                right: parent.right
                rightMargin: volumeTextWidth + rowTextSpacing
                baseline: parent.baseline
            }
            text: _root.unit
            font.pixelSize: Fonts.fontPixelFluidUnit
            color: Colors.fluidUnit
        }
        Text { id: _cumulativeValue
            property real value : 0
            anchors  {
                right: _cumulativeUnit.left
                rightMargin: rowTextSpacing
                baseline: parent.baseline
            }
            horizontalAlignment: Text.AlignRight
            text: value
            width: 60
            font.pixelSize: Fonts.fontPixelFluidValue
            color: Colors.fluidText
        }
    }
}
