/*!
 *
 * 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    MainHome.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      30-Aug-2022
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  01-Mar-2021
 *
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   MainHome is the screen
 * which is the default screen in the "Treatment" stack
 */
ScreenItem { id: _root
    objectName: "_MainHome"

    property alias  reasonText  : _notification.text

    signal createTreatment(int modality)

    Image {
        anchors.fill: backgroundRect
        source: "qrc:/images/iHomeBackground"
    }

    // 2 - Header
    ImageLogoD { id: _headerLogo }

    // Definitions
    TitleText { id: _titleText
        anchors.top: parent.top
        anchors.topMargin: 200                                                  //// ----- @LEAHIZED: Move to Variables.qml
        width: parent.width
        text : vDateTime.greeting
        font.pixelSize: 40                                                      //// ----- @LEAHIZED: Move to Variables.qml
    }

    TouchRect { id : _createHDTreatment
        anchors {
            horizontalCenter    : parent.horizontalCenter
            verticalCenter      : parent.verticalCenter
            verticalCenterOffset: Variables.defaultMargin * -3
        }
        text.text       : qsTr("Hemodialysis")
        onClicked       : createTreatment(HeaderBar.Mode_HD)
        width           : 435                                                   //// ----- @LEAHIZED: Move to Variables.qml
        height          : 92                                                    //// ----- @LEAHIZED: Move to Variables.qml
        pixelSize       : 30                                                    //// ----- @LEAHIZED: Move to Variables.qml
        backgroundColor : Colors.panelBackgroundColor
        borderColor     : Colors.panelBorderColor
        selectColor     : Colors.backgroundButtonSelectDark
    }

    TouchRect { id : _createHDFTreatment
        anchors {
            top             : _createHDTreatment.bottom
            topMargin       : Variables.defaultMargin * 2
            horizontalCenter: _createHDTreatment.horizontalCenter
        }
        text.text       : qsTr("Hemodiafiltration")
        onClicked       : createTreatment(HeaderBar.Mode_HDF)
        width           : 435                                                   //// ----- @LEAHIZED: Move to Variables.qml
        height          : 92                                                    //// ----- @LEAHIZED: Move to Variables.qml
        pixelSize       : 30                                                    //// ----- @LEAHIZED: Move to Variables.qml
        backgroundColor : Colors.panelBackgroundColor
        borderColor     : Colors.panelBorderColor
        selectColor     : Colors.backgroundButtonSelectDark
    }

    NotificationBarSmall { id: _notification
        anchors.bottomMargin: Variables.mainMenuHeight
    }

    onVisibleChanged: {
        if (visible) {
            _headerBar.activeStack = null
            _mainMenu.hidden = false // initially our landing screen is _initialModeScreen which should not have the Main menu.
        }
        else {
            reasonText = ""
        }
    }
}
