/*!
 *
 * 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    TreatmentAdjustmentBase.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      04-Oct-2022
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  22-Mar-2020
 
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   TreatmentAdjustmentBase.qml is the base screen
 *          For all adjustment screens in treatment
 */
ModalDialog { id: _root
    contentItem.objectName: "TreatmentAdjustmentBase"  //SquishQt testability

    property string titleText       : ""
    property alias titlePixelSize   : _titleText.font.pixelSize

    property bool   closeVisible: true
    property bool confirmVisible: false
    property bool    backVisible: false
    property alias   information: _information

    signal   closeClicked()
    signal confirmClicked()
    signal    backClicked()

    width   : Variables.adjustmentDialogWidth
    height  : Variables.adjustmentDialogHeight
    y       : Math.round((Variables.applicationHeight - height) / 2) - Variables.headerHeight
    radius  : Variables.adjustmentDialogRadius

    onVisibleChanged: {
        notificationText = ""
    }

    header: Item { id : _headerRect
        implicitHeight: Variables.adjustmentHeaderHeight
        // TODO: remove ConfirmButton later once it is moved out into screens that inherit this
        ConfirmButton { id : _confirmButton
            anchors {
                right           : parent.right
                verticalCenter  : _backButton.verticalCenter
                margins         : Variables.adjustmentButtonMargin
            }
            visible: _root.confirmVisible
            onClicked : confirmClicked()
        }

        BackButton { id : _backButton
            anchors {
                top     : parent.top
                left    : parent.left
                margins : Variables.adjustmentButtonMargin
            }
            visible: _root.backVisible
            onClicked : backClicked()
        }

        TitleText { id : _titleText
            text: titleText
            font {
                pixelSize   : Fonts.fontPixelTitle
                weight      : Font.Medium
            }
            color   : Colors.textMain
            width   : contentWidth
            height  : contentHeight
            anchors {
                bottom              : parent.bottom
                horizontalCenter    : parent.horizontalCenter
                margins             : Variables.defaultMargin
            }
        }

        CloseButton { id : _closeButton
            anchors {
                right           : parent.right
                verticalCenter  : _backButton.verticalCenter
                margins         : Variables.adjustmentButtonMargin
            }
            visible: _root.closeVisible
            onClicked : {
                closeClicked()
                close()
            }
        }
    }

    // this notification shall not be confused with the _notification in the parent ModalDailog
    // this meant to be used specifically as current state notification like paused/off in UF
    // it is also available in TreatmentAdjustmentFlow and TreatmentAdjustmentDuration but not used.
    NotificationBarSmall { id: _information
        height              : notification.height
        visible             : false
        radius              : notification.radius
        imageSource         : ""
        imageDiameter       : 26
        imageVerticalCenter : true
        imageFillMode       : Image.PreserveAspectFit
        textfontSize        : 30
        textfontWeight      : Font.Medium
        text                : ""
    }
}
