/*!
 *
 * Copyright (c) 2020-2025 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    TreatmentAdjustmentBolusVolume.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   TreatmentAdjustmentBolusVolume.qml is the screen
 *          To adjust the treatment saline
 */
TreatmentAdjustmentBase { id: _root
    objectName: "_TreatmentAdjustmentBolusVolume"  // SquishQt testability

    readonly property alias fluidBolusVolume: _fluidBolusVolume.value

    titleText           : qsTr("Fluid Delivery Settings")
    height              : Variables.smallDialogHeight
    width               : Variables.smallDialogWidth

    onAboutToShow: {
        _fluidBolusVolume.value = vTreatmentSaline.target
    }

    Item { id: _contentItem
        objectName: "_contentItem"
        anchors {
            top: parent.top
            bottom: notification.top
            left: parent.left
            right: parent.right
        }

        Item { id: _contentArea
            objectName: "_contentArea"
            anchors {
                top: parent.top
                bottom: _confirmButton.top
                left: parent.left
                right: parent.right
            }

            Column { id: _controlColumn
                objectName: "_controlColumn"
                anchors.centerIn: parent
                spacing: Variables.defaultMargin

                LabelUnitValueAdjuster { id: _fluidBolusVolume
                    objectName          : "_fluidBolusVolume"
                    text                : qsTr("Fluid Bolus Volume")
                    unitText            : Variables.unitTextSaline
                    isActive            : true
                    minimum             : vTreatmentRanges.salineBolusVolumeMin
                    maximum             : vTreatmentRanges.salineBolusVolumeMax
                    step                : vTreatmentRanges.salineBolusVolumeRes

                    onDidChange         : function(vValue) { value = vValue }
                }
            }
        }

        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()
            }
        }
    }
}
