/*!
 *
 * Copyright (c) 2021-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    EndTreatmentBase.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      15-May-2021
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  15-May-2021
 *
 */

// Qt
import QtQuick 2.12

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

/*!
 * \brief   the parent page of the End-treatment screens
 */
TreatmentFlowBase { id: _root
    objectName: "_EndTreatmentBase"

    property bool   hasTimeout      : false
    property alias  timeout         : _timeoutLoader.item
    property int    timeoutValue    : 0
    property string headerTitle     : ""
    property string descriptionText : ""

    onVisibleChanged: if ( visible ) { _root.updateModel() }

    // update model for instruction based steps
    function updateModel () {
        let group = vSettings.groupModalityFormat(_root.headerTitle, vTreatmentCreate.treatmentModality)

        let instructionsGroup    = vSettings.instructions[group]

        if ( instructionsGroup !== undefined ) {
            instructionTitle      = instructionsGroup.title
            instructionStepNames  = instructionsGroup.keys
            instructionStepImages = instructionsGroup.values
        }
    }

    Loader { id: _timeoutLoader
        active              : _root.hasTimeout
        anchors {
            horizontalCenter: parent.horizontalCenter
            top             : parent.top
            topMargin       : Variables.defaultMargin * 3
        }
        sourceComponent     : Item { id: _timeoutItem
            Text { id: _description
                objectName      : "_description"
                anchors.centerIn: parent
                width           : implicitWidth
                height          : implicitHeight
                text            : _root.descriptionText
                color           : Colors.offWhite
                font.pixelSize  : Fonts.fontPixelContainerTitle
            }

            TimeText { id: _timeout
                anchors {
                    left    : _description.right
                    bottom  : _description.bottom
                }
                textPixelSize   : 30
                textWeight      : Font.DemiBold
                secondsVisible  : false
                seconds         : _root.timeoutValue
                textColor       : Colors.ufVolumeGoalText
            }
        }
    }
}
