/*!
 *
 * 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 TreatmentBegin.qml
 * \author (last) Peter Lucia
 * \date (last) 05-Oct-2020
 * \author (original) Peter Lucia
 * \date (original) 03-Aug-2020
 *
 */

// Qt
import QtQuick 2.12

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

/*!
 * \brief   ManagerHome is the screen
 * which is the default screen in the "Manager" stack
 */
ScreenItem { id: _root
    objectName: "_treatmentBegin"

    property alias  ufVolume    : _volumeSlider.value
    property alias  reasonText  : _notification.text

    signal backClicked ()
    signal startClicked()

    QtObject { id: _private
        property real minimum   : 0.000
        property real maximum   : 8.000
    }

    TopMenuBarCreateTreatment { id: _topMenuBar
        anchors.top: parent.top
        anchors.left: parent.left
        width: parent.width
        onClickedBack: {
            _root.backClicked();
        }
        state: "begin"
    }

    Text { id: _textTitle
        visible : true
        color   : "white"
        text    : qsTr("Begin Treatment")
        font.pixelSize  : Fonts.fontPixelTitle
        anchors {
            horizontalCenter: parent.horizontalCenter
            top             : parent.top
            topMargin       : 150
        }
    }

    Text { id: _textLabel
        visible : true
        color   : "white"
        text    : qsTr("Ultrafiltration Volume") + " " + Variables.unitTextUltrafiltrationVolume
        font {
            pixelSize  : Fonts.createTreatmentFontSize
        }
        anchors {
            left            : _volumeSlider.left
            bottom          : _volumeSlider.top
            bottomMargin    : 45
        }
    }

    Text { id: _textValue
        objectName: "_treatmentBeginUltrafiltrationValue"
        visible : true
        color   : "white"
        text    : _root.ufVolume.toFixed(vTreatmentUltrafiltration.precision)
        font {
            pixelSize  : Fonts.createTreatmentFontSize
        }
        anchors {
            right           : _volumeSlider.right
            bottom          : _volumeSlider.top
            bottomMargin    : 45
        }
    }

    Slider { id: _volumeSlider
        objectName: "_treatmentBeginUltrafiltrationSlider"
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: parent.top
            topMargin: 425
        }
        isActive: false
        width   : parent.width / 2
        height  : 5
        step    : 0.100
        stepSnap: true
        ticks   : false
        diameter: Variables.sliderCircleDiameter
        decimal : vTreatmentUltrafiltration.precision
        minimum : _private.minimum
        maximum : _private.maximum
        minText.font.pixelSize: Fonts.fontPixelFluidText
        maxText.font.pixelSize: Fonts.fontPixelFluidText
        onPressed: isActive = true
    }

    TouchRect { id: _startButton
        objectName: "_treatmentBeginStartButton"
        width   : 515
        height  :  70
        anchors {
            top: parent.top
            topMargin: 650
            horizontalCenter: parent.horizontalCenter
        }
        disabled: ! _volumeSlider.isActive
        backgroundColor: Colors.backgroundButtonSelect
        text {
            text: qsTr("START")
            font.weight   : Font .DemiBold
            font.pixelSize: Fonts.fontPixelUltrafiltrationAdjustmentButton
        }
        onClicked: {
            _root.startClicked()
        }
    }

    NotificationBar { id: _notification
        iconVisible: false
    }

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