/*!
 *
 * 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    TreatmentAdjustmentUltrafiltrationConfirm.qml
 * \author  (last)      Stephen Quong
 * \date    (last)      08-Oct-2025
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  18-May-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   TreatmentAdjustmentUltrafiltrationConfirm.qml is the screen
 *          to confirm requested changes to the treatment ultrafiltration setting.
 */
TreatmentAdjustmentBase { id: _root
    contentItem.objectName: "TreatmentAdjustmentUltrafiltrationConfirm"  //SquishQt testability

    property real ultrafiltrationVolume : 0.000
    property real ultrafiltrationRate   : 0.000

    signal confirmVolumeClicked(real vVolume)

      closeVisible  : false
    confirmVisible  : false
       backVisible  : true

   information {
        visible         : true && information.text && ! notification.visible
        imageSource     : ufInfoImageSource
        text            : ufInfoText
        color           : Colors.ufNotificationBarBg
        textColor       : Colors.ufVolumeGoalText
        textfontSize    : Fonts.fontPixelUltrafiltrationAdjustmentNotification
        textfontWeight  : Font.Medium
    }

    titleText   : qsTr("Confirm Ultrafiltration Volume ") + Variables.unitTextUltrafiltrationVolume

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

        Row { id: _contentRow
            anchors.centerIn: parent
            spacing         : 150

            Column { id: _leftContent
                spacing: 20
                Text {
                    font {
                        pixelSize   : Fonts.fontPixelUltrafiltrationAdjustmentNotification
                        weight      : Font.Medium
                    }
                    color   : "white"
                    text    : qsTr("New UF Volume:")
                }

                Item {
                    width   : childrenRect.width
                    height  : childrenRect.height

                    Text { id: _newUfVolumeValue
                        width: contentWidth
                        font {
                            pixelSize       : Fonts.fontPixelUltrafiltrationAdjustmentConfirmation
                            weight          : Font.DemiBold
                        }
                        horizontalAlignment : Text.AlignVBottom
                        color               : Colors.ufVolumeGoalText
                        text                : _root.ultrafiltrationVolume.toFixed(Variables.ultrafiltrationPrecision)
                    }

                    Text { id: _newUfVolumeUnit
                        anchors { 
                            left                : _newUfVolumeValue.right
                            verticalCenter      : _newUfVolumeValue.verticalCenter
                            verticalCenterOffset: (_newUfVolumeValue.height - height) * 0.25
                        }
                        font {
                            pixelSize       : _newUfVolumeValue.font.pixelSize * 0.6
                            weight          : Font.Medium
                        }
                        horizontalAlignment : Text.AlignVBottom
                        color               : _newUfVolumeValue.color
                        text                : " " + Variables.unitVolume
                    }
                }
            }

            Column { id: _rightContent
                spacing: _leftContent.spacing
                Text {
                    font {
                        pixelSize   : Fonts.fontPixelUltrafiltrationAdjustmentNotification
                        weight      : Font.Medium
                    }
                    color   : "white"
                    text    : qsTr("New UF Rate:")
                }

                Item {
                    width   : childrenRect.width
                    height  : childrenRect.height

                    Text { id: _newUfRateValue
                        width: contentWidth
                        font {
                            pixelSize   : Fonts.fontPixelUltrafiltrationAdjustmentConfirmation
                            weight      : Font.DemiBold
                        }
                        horizontalAlignment : Text.AlignVCenter
                        color               : Colors.ufVolumeGoalText
                        text                : _root.ultrafiltrationRate.toFixed(Variables.ultrafiltrationPrecision)
                    }

                    Text { id: _newUfRateUnit
                        anchors {
                            left                : _newUfRateValue.right
                            verticalCenter      : _newUfRateValue.verticalCenter
                            verticalCenterOffset: (_newUfRateValue.height - height) * 0.25
                        }
                        font {
                            pixelSize   : _newUfVolumeUnit.font.pixelSize
                            weight      : _newUfVolumeUnit.font.weight
                        }
                        horizontalAlignment : Text.AlignVCenter
                        color               : _newUfVolumeValue.color
                        text                : " " + Variables.unitTextRate
                    }
                }
            }
        }
    }

    TouchRect { id: _confirmButton
        anchors {
            bottom          : information.top
            bottomMargin    : Variables.ultrafiltrationButtonBottomMargin
            horizontalCenter: parent.horizontalCenter
        }
        width       : Variables.ultrafiltrationButtonWidth
        height      : Variables.ultrafiltrationButtonHeight
        isDefault   : true
        text  {
            text            : qsTr("Confirm")
            font.weight     : Font.Medium
        }

        onClicked: confirmVolumeClicked(_root.ultrafiltrationVolume.toFixed(Variables.ultrafiltrationPrecision))
    }
}
