/*!
 *
 * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved.
 * \copyright                                                       \n
 *          THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM,  \n
 *          IN PART OR IN WHOLE,                                    \n
 *          WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n
 *
 * \file    NotificationBar.qml
 * \date    2020/03/30
 * \author  Behrouz NematiPour
 *
 */

// Qt
import QtQuick 2.12

// Project
import Gui.Actions 0.1
//  Qml imports
import "qrc:/globals"

Rectangle { id: _root
    objectName: "NotificationBar" // SquishQt

    property alias  imageSource     : _image.source
    property bool   imageAutoSize   : false
    property alias  text            : _text.text
    property alias  textColor       : _text.color
    property alias  textfontSize    : _text.font.pixelSize
    property alias  rowAnchors      : _row.anchors

    property int    level           : 0


    visible : _text.text

    height  : Variables.notificationHeight
    color   : Colors.textNotificationNoneBg
    //radius  : Variables.dialogRadius
    anchors {
        bottom  : parent.bottom
        left    : parent.left
        right   : parent.right
    }

    Row { id: _row
        anchors.centerIn: parent
        spacing: 10
        Image { id: _image
            anchors.verticalCenter: parent.verticalCenter
            width : imageAutoSize ? Math.min(_root.height, _root.width) : Variables.notificationIconSize
            height: imageAutoSize ? Math.min(_root.height, _root.width) : Variables.notificationIconSize
        }
        Text { id: _text
            color               : Colors.textNotificationNoneFg
            font.pixelSize      : Fonts.fontPixelNotification
            horizontalAlignment : Text.AlignHCenter
            verticalAlignment   : Text.AlignVCenter
        }
    }

    onLevelChanged: {
        switch (level) {
        case GuiActions.ALARM_PRIORITY_HIGH:
            _root.color = Colors.textNotificationHighBg;
            _text.color = Colors.textNotificationHighFg;
            break;
        case GuiActions.ALARM_PRIORITY_MEDIUM:
            _root.color = Colors.textNotificationMedBg;
            _text.color = Colors.textNotificationMedFg;
            break;
        case GuiActions.ALARM_PRIORITY_LOW:
            _root.color = Colors.textNotificationLowBg;
            _text.color = Colors.textNotificationLowFg;
            break;
        default : // GuiActions.ALARM_PRIORITY_NONE
            _root.color = Colors.textNotificationNoneBg;
            _text.color = Colors.textNotificationNoneFg;
            break;
        }
    }
}
