/*!
 *
 * 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    PostTreatmentRinsebackComplete.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      09-Feb-2021
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  03-Feb-2021
 *
 */

// Qt
import QtQuick 2.12

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

/*!
 * \brief   the post treatment rinseback complete screen
 */
ScreenItem { id: _root
    objectName: "_PostTreatmentRinsebackComplete"

    property alias  reasonText  : _notification.text

    signal additionalClicked    ()
    signal confirmClicked       ()
    signal treatmentEndClicked  ()

    QtObject { id: _private
        property int sectionSpace : 30
        property int sectionWidth : _root.width  * 2/3 - sectionSpace * 1.5
        property int sectionHeight: _root.width  * 1/3 - sectionSpace * 1.5
    }
    Text { id: _title
        anchors {
            top: parent.top
            topMargin: 65
            horizontalCenter: parent.horizontalCenter
        }
        color: Colors.white
        text: qsTr("Rinseback Complete")
        font.pixelSize: Fonts.fontPixelTitle
    }

    TimeText { id: timeout
        visible         : vTreatmentRinseback.timeoutTotal
        anchors {
            horizontalCenter: parent.horizontalCenter
            top             : _title.bottom
            topMargin       : 15
        }
        textPixelSize   : 30
        textWeight      : Font.Normal
        // the TimeText component works with hour and minute mainly
        // so changing the seconds to minuts was easier than changing the component
        secondsVisible  : false
        seconds         : vTreatmentRinseback.timeoutCountDown * 60
    }

    Rectangle {
        color   : Colors.backgroundDialog
        width   : _private.sectionWidth
        height  : _private.sectionHeight
        border.width: 2
        border.color: Colors.borderDisableButton
        radius: 10
        anchors {
            verticalCenter: parent.verticalCenter
            left: parent.left
            leftMargin: _private.sectionSpace
        }
        Column {
            spacing : 10
            anchors.fill: parent
            anchors.margins: _private.sectionSpace
            Text { id: _titleSteps
                anchors.left: parent.left
                color: Colors.white
                text: qsTr("Please Disconnet")
                font.pixelSize: Fonts.fontPixelButton
            }

            Text { id: _steps
                anchors.left: parent.left
                anchors.leftMargin: _private.sectionSpace
                color: Colors.white
                text: qsTr("First Step\nSecond Step\nThird Step\n")
                font.pixelSize: Fonts.fontPixelButton
            }
        }
    }

    Rectangle {
        color   : Colors.backgroundDialog
        width   : _private.sectionHeight
        height  : _private.sectionHeight
        border.width: 2
        border.color: Colors.borderDisableButton
        radius: 10
        anchors {
            verticalCenter: parent.verticalCenter
            right: parent.right
            rightMargin: _private.sectionSpace
        }
        Text { id: _visualAID
            anchors.centerIn: parent
            color: Colors.white
            text: qsTr("Visual AID\nplaceholder")
            font.pixelSize: Fonts.fontPixelButton
        }
    }

    Row { id: _buttonGroup
        property int buttonsWidth   : 300
        spacing: 75

        anchors {
            bottom          : parent.bottom
            horizontalCenter: parent.horizontalCenter
            rightMargin     : spacing
            leftMargin      : spacing
            bottomMargin    : spacing
        }

        TouchRect { id : _backTreatmentTouchRect
            visible         : true
            text.text       : qsTr("ADDITIONAL")
            width           : _buttonGroup.buttonsWidth
            onClicked       : additionalClicked()
        }

        TouchRect { id : _beginRinsebackTouchRect
            visible         : true
            text.text       : qsTr("CONFIRM")
            width           : _buttonGroup.buttonsWidth
            color           : borderColor
            onClicked       : confirmClicked()
        }

        TouchRect { id : _endTreatmentTouchRect
            visible         : vTreatmentTime.time_Total > 0
            text.text       : qsTr("END TREATMENT")
            width           : _buttonGroup.buttonsWidth
            onClicked       : treatmentEndClicked()
        }
    }

    NotificationBar { id: _notification
        iconVisible: false
    }

    onVisibleChanged: {
        _notification.text = ""
        if (visible) {
            _mainMenu     .hidden = true
            _treatmentMenu.hidden = true
        }
    }
}
