/*!
 *
 * Copyright (c) 2019-2020 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 NotificationDialog.qml
 * \author (last) Peter Lucia
 * \date (last) 26-Jun-2020
 * \author (original) Peter Lucia
 * \date (original) 02-Jun-2020
 *
 */

// Qt
import QtQuick 2.12

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

/*!
 * \brief   Contains the PowerOff Dialog Implementation
 */
ModalDialog { id : _root
    contentItem.objectName: "_NotificationDialog" // SquishQt

    property alias titleText : _title.text;
    property alias description : _desc.text;
    property alias titleBarForeground : _title.color
    property alias titleBarBackground : _titleBar.color;
    property alias okayBtn : _okay;
    property alias dismissBtn : _dismiss;
    property bool  isSilenced : false;
    property int   alarmID : -1

    visible: description

    signal clickedSilence();
    signal clickedOkay();

    // Placeholder animation
    Timer {
        id: _timer
        interval: 1000;
        running: false;
        onTriggered: {
            _root.visible = !_root.visible;
        }
    }

    function setFlashing(enable) {
        _timer.running = enable;
    }

    radius: 0;
    Rectangle {
        id: _titleBar;
        color: Colors.alarmTopBarHighBg;
        height: _root.height / 4;
        width: _root.width;
        radius: _root.radius;

        Image {
            id: _icon
            source: "qrc:/images/alarm.svg"
            anchors.horizontalCenter: _title.horizontalCenter
            anchors.verticalCenter: _title.verticalCenter;
            anchors.horizontalCenterOffset: -_title.width + Variables.dialogSVGIconOffset;
            sourceSize.height: Variables.dialogSVGHeight;
            sourceSize.width: Variables.dialogSVGWidth;
        }

        Text { id: _title
            color: Colors.textMain
            font.pixelSize: Fonts.fontPixelTitle
            text: qsTr("Notification")
            anchors.centerIn: _titleBar;
        }
    }

    Text { id: _desc
        objectName: "_NotificationDialog_Description"
        color: Colors.textMain
        font.pixelSize: Fonts.fontPixelButton
        anchors {
            horizontalCenter: parent.horizontalCenter;
            verticalCenter: parent.verticalCenter;
        }
    }

    Row {
        id: _buttons
        spacing: Variables.buttonSpacing;
        anchors {
            horizontalCenter: parent.horizontalCenter;
            bottom: parent.bottom;
            bottomMargin: Variables.dialogMargin / 2;
        }

        TouchRect { id : _okay
            width: _root.width / 3;
            text.text: qsTr("OKAY")
            borderColor: _root.textColor;
            button.onPressed: {
                clickedOkay();

            }
        }

        TouchRect { id : _dismiss
            width: _root.width / 3;
            text.text: qsTr("SILENCE")
            borderColor: _root.textColor;
            button.onPressed: {
                clickedSilence()
            }
        }
    }
}
