/*!
 *
 * 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    TreatmentStack.qml
 * \date    2019/10/21
 * \author  Behrouz NematiPour
 *
 */

// Qt
import QtQuick 2.12

// Project
import VTreatmentRanges 0.1

//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/pages/treatment/adjustments"
/*!
 * \brief   TreatmentStack is the screen
 * which contains the main stack for all the Trearment screens
 * This is the screen which will be show up when "Treatment" option
 * is selected from the main menu.
 */
StackItem { id : _root
    stackView.initialItem   : _treatmentHome

    VTreatmentRanges        { id: vTreatmentRanges }

    MainMenu                { id: _treatmentMenu
        y               : -Variables.mainMenuHeight
        position        : MainMenu.Position.Top
        hidden          : true
        titles          : [ qsTr("Back") , qsTr("Treatment") , qsTr("Trending") , qsTr("Settings") ]
        spacing         :  20
        leftPdding      :  20
        partitionWidth  : 100 // Todo Important : max width should be the width for all
        hasRightText    : true
        hasLogo         : true
    }

    TreatmentHome               { id:       _treatmentHome
        onTreatmentStarted      : push( _treatmentStart )
        onTreatmentCreated      : push( _treatmentCreate)
    }

    TreatmentStart              { id:       _treatmentStart
        onBackPressed           : pop ()
        onSectionFlowClicked    : {
            _treatmentAdjustmentFlow.open()
        }
        onSectionTimeClicked    : {
            _treatmentAdjustmentDuration.open()
        }
    }

    TreatmentAdjustmentFlow     { id:       _treatmentAdjustmentFlow
        dialysateFlowRateMinimum: vTreatmentRanges.treatmentRanges_Dialysate_Flow_Min
        dialysateFlowRateMaximum: vTreatmentRanges.treatmentRanges_Dialysate_Flow_Max

        onCloseClicked          : close()
        onConfirmClicked        : _GuiView.doAdjustBloodDialysateFlows(bloodFlowRateValue, dialysateFlowRateValue)
    }

    TreatmentAdjustmentDuration { id:       _treatmentAdjustmentDuration
        // durationMinimum: vTreatmentRanges.treatmentRanges_Duration_Min
        // durationMaximum: vTreatmentRanges.treatmentRanges_Duration_Max
        onCloseClicked          : close()
        onConfirmClicked        : _GuiView.doAdjustDuration(durationValue)
    }

    TreatmentCreate             { id:       _treatmentCreate
        onBackPressed           : pop()
    }

}
