// Qt
import QtQuick 2.12

// Project

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

EndTreatmentBase { id: _root
    headerTitle                                 : qsTr("Recirculate In Progress")
    footer.anchors.bottomMargin: Variables.notificationHeight + Variables.defaultMargin

    readonly property bool  timeoutTotal        : vTreatmentRecirculate .timeoutTotal
    readonly property int   timeoutCountdown    : vTreatmentRecirculate .timeoutCountDown
    readonly property int   bloodFlowRate       : vTreatmentParametersSetPoint.bloodFlow
    readonly property string recirculationImage : "qrc:/images/iRecirculate"

    Row { id: _infoRow
        objectName: "_infoRow"

        readonly property int cellWidth: _root.width / 3.5

        anchors {
            top             : parent.top
            topMargin       : Variables.defaultMargin * 2
            horizontalCenter: parent.horizontalCenter
        }
        spacing: Variables.defaultMargin * 2

        LabelUnitText { id: _timeElapsed
            objectName  : "_timeElapsed"
            width       : _infoRow.cellWidth
            label       : qsTr("Recirculation Time Elapsed:")
            labelWeight : Font.Medium
            TimeText { id: _timeText
                objectName: "timeText"

                anchors {
                    right               : parent.right
                    rightMargin         : Variables.defaultMargin * 3
                    verticalCenter      : parent.verticalCenter
                    verticalCenterOffset: -2
                }
                seconds             : _root.timeoutCountdown
                textWeight          : Font.Normal
                textPixelSize       : Fonts.fontPixelContainerTitle
                secondsLeftMargin   : 5
            }
        }

        LabelUnitText { id: _bloodFlowRate
            objectName  : "_bloodFlowRate"
            width       : _infoRow.cellWidth
            label       : qsTr("Blood Flow Rate:")
            unit        : Variables.unitTextFlowRate
            value       : _root.bloodFlowRate.toFixed(Variables.bloodFlowPrecision)
            labelWeight : Font.Medium
        }
    }

    Image { id: _image
        anchors {
            top             : _infoRow.bottom
            topMargin       : Variables.defaultMargin * 2
            horizontalCenter: parent.horizontalCenter
        }

        source: _root.recirculationImage

        Image { id: _rotatingImage
           source: "qrc:/images/iBloodpump"

           // DO NOT CHANGE COORDINATE - unless image has been updated
           x: 190
           y: 287

           RotationAnimator on rotation {
               running : _root.visible
               from    : 0
               to      : 360
               loops   : Animation.Infinite
               duration: 7200
           }
        }
    }
}
