/*!
 *
 * 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    PreTreatmentPrime.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      12-Jan-2021
 * \author  (original)  Peter Lucia
 * \date    (original)  03-Aug-2020
 *
 */

// Qt
import QtQuick 2.12

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

/*!
 * \brief   Pre-Treatment priming screen
 * \details which contains the priming timer and steps to let user know about the priming status.
 */
PreTreatmentBase { id: _root
    objectName: "_PreTreatmentPrime"

    signal continueClicked()

    header.stepName        : Variables.preTreatmentStepLabelPriming

    Text { id: _titleText
        anchors {
            top: _root.top
            topMargin: 150
            horizontalCenter: parent.horizontalCenter
        }
        text: qsTr("Priming")
        color: Colors.textMain
        font.pixelSize: Fonts.fontPixelTitle
    }

    ProgressCircle { id: _circle
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: _titleText.bottom
        anchors.topMargin: 25
        minimum: 0
        maximum: vPriming.secondsTotal
        diameter: 100
        value: vPriming.primingComplete ? vPriming.secondsTotal : vPriming.secondsRemaining

        PrimingTimer { id: _timeText
            anchors.centerIn: parent
            seconds : vPriming.secondsRemaining
            completed: vPriming.primingComplete
        }
    }

    Column { id: _checklist
        spacing: 20
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: _circle.bottom
        anchors.topMargin: 30

        CheckListItem { id: _checking_installation
            anchors.horizontalCenter: parent.horizontalCenter
            color   : Colors.transparent
            text: qsTr("Checking installation")
            completed: vPriming.checkingInstallationComplete
        }

        CheckListItem { id: _creating_dialysate
            anchors.horizontalCenter: parent.horizontalCenter
            color   : Colors.transparent
            text    : qsTr("Creating dialysate")
            completed: vPriming.creatingDialysateComplete
        }

        CheckListItem { id: _priming_lines
            anchors.horizontalCenter: parent.horizontalCenter
            color   : Colors.transparent
            text    : qsTr("Priming lines")
            completed: vPriming.primingLinesComplete
        }
    }

    Text { id: _priming_complete
        objectName: "_primingCompleteText"
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: _checklist.bottom
        anchors.topMargin: 45
        text: qsTr("Priming Complete!")
        color: vPriming.primingComplete ? Colors.textMain : Colors.transparent
        font.pixelSize: Fonts.fontPixelPriming
    }

    TouchRect { id : _continueRect
        objectName: "_treatmentPrimeContinueButton"
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: _priming_complete.bottom
        anchors.topMargin: 50
        width: 490
        height: 60
        text.text:   vPriming.continueBtnText
        disabled : false  // it has not been implemeted in the FW so it is enabled always.
        // /*! vPriming.primingComplete // */vPriming.continueEnabled
        onEnabledChanged: {
            if (enabled) {
                borderColor = Colors.primingReady
                textColor = Colors.primingReady
            } else {
                borderColor = Colors.primingNotReady
                textColor = Colors.primingNotReady
            }
        }

        button.onClicked: {
            _root.continueClicked()
        }
    }
}
