import QtQuick 2.0
import Sailfish.Silica 1.0
import "../items"

Page {
    id: page
    property bool closePanel: false
    onClosePanelChanged: if (closePanel) mediaPlayerPanel.open = false
  //  property int sleepTime: 0

    //allowedOrientations: Orientation.All

    SilicaFlickable {
        anchors.fill: parent
        clip: true
        anchors.bottomMargin: mediaPlayerPanel.visibleSize
        VerticalScrollDecorator {}
            PageHeader {title: "Sleep timer";description: ((sleepTime > 0) ? (qsTr("Remaning time: ") + (sleepTime) + qsTr(" minutes")) : qsTr("choose time: ") + minutes.value )}

            ValuePicker {
                id: minutes
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
                max: 121
                min: 1
                value: sleepTime
            }
            Label {
                text: minutes.value
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
                color: Theme.secondaryHighlightColor
                font.family: Theme.fontFamilyHeading
                font.pixelSize: Theme.fontSizeHuge
            }
            Row {
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 40
                spacing: Theme.paddingLarge

                Button {
                        text: ((sleepTime > 0) ? (qsTr("Change")) : (qsTr("Start")))
                        onPressed: sleepTime = minutes.value
                    }
                Button {
                        text: qsTr("Stop")
                        onPressed: sleepTime = 0;
                    }
            }
    }
    Component.onCompleted: if (mediaPlayerPanel.open) closePanel = true; else closePanel = false;
    Component.onDestruction: if (closePanel) mediaPlayerPanel.open = true
}
