/*!
 *
 * 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    TreatmentAdjustmentDurationConfirm.qml
 * \author  (last)      Stephen Quong
 * \date    (last)      11-Nov-2025
 * \author  (original)  Stephen Quong
 * \date    (original)  11-Nov-2025
 *
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   TreatmentAdjustmentDurationConfirm.qml is the screen
 *          to confirm the treatment duration
 */
Item { id: _root
    objectName: "_TreatmentAdjustmentDurationConfirm"

    property real   ufVolumeGoal            : 0
    property real   ufRate                  : 0
    property int    newTreatmentDuration    : 0

    signal confirmClicked(int vNewTreatmentDuration)

    Item { id: _infoArea
        objectName: "_infoArea"
        anchors {
            top: parent.top
            bottom: _confirmButton.top
            left: parent.left
            leftMargin: Variables.defaultMargin * 2
            right: parent.right
            rightMargin : anchors.leftMargin
        }

        Row { id: _infoRow
            objectName: "_infoRow"

            readonly property int cellWidth: (_infoRow.width - (_infoRow.spacing * 2)) / 3

            anchors {
                left            : parent.left
                right           : parent.right
                verticalCenter  : parent.verticalCenter
            }
            spacing: Variables.defaultMargin * 2

            LabelUnitText { id: _ufVolumeGoal
                objectName  : "_ufVolumeGoal"
                width       : _infoRow.cellWidth
                label       : qsTr("UF Volume Goal")
                unit        : Variables.unitVolume
                value       : _root.ufVolumeGoal.toFixed(Variables.ultrafiltrationPrecision)
                valueColor  : Colors.ufVolumeGoalText
            }

            LabelUnitText { id: _ufRate
                objectName  : "_ufRate"
                width       : _infoRow.cellWidth
                label       : qsTr("New UF Rate")
                unit        : Variables.unitTextRate
                value       : _root.ufRate.toFixed(Variables.ultrafiltrationPrecision)
                valueColor  : Colors.ufVolumeGoalText
            }

            LabelUnitText { id: _newTreatmentDuration
                objectName: "_newTreatmentDuration"
                width       : _infoRow.cellWidth
                label       : qsTr("New Treatment Duration")
                unit        : Variables.unitTextDuration
                value       : _root.newTreatmentDuration
                valueColor  : Colors.ufVolumeGoalText
            }
        }
    }

    TouchRect { id: _confirmButton
        objectName  : "_confirmButton"
        anchors {
            bottom          : parent.bottom
            bottomMargin    : Variables.defaultMargin
            horizontalCenter: parent.horizontalCenter
        }
        width       : Variables.defaultButtonWidth
        height      : Variables.defaultButtonHeight
        text {
            text        : qsTr("Confirm")
            font.weight : Font.Medium
        }
        isDefault   : true

        onClicked   : {
            _root.confirmClicked(_root.newTreatmentDuration)
        }
    }
}
