~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import QtQuick 2.0
import Ubuntu.Components 0.1

MainView {
    id: mainView
    width: units.gu(45)
    height: units.gu(80)
        // FIXME: 80/45 = aspect ration of Galaxy Nexus

    Tabs { // preliminary HACK, needs rewrite when NewTabBar is finalized!
        id: tabs
        anchors.fill: parent

        Tab { id: pageArea; title: i18n.tr("January"); page: Item { anchors.fill: parent } }
        Tab { title: i18n.tr("February") }
        Tab { title: i18n.tr("March") }
        Tab { title: i18n.tr("April") }
        Tab { title: i18n.tr("May") }
        Tab { title: i18n.tr("June") }
        Tab { title: i18n.tr("July") }
        Tab { title: i18n.tr("August") }
        Tab { title: i18n.tr("September") }
        Tab { title: i18n.tr("October") }
        Tab { title: i18n.tr("November") }
        Tab { title: i18n.tr("December") }

        onSelectedTabIndexChanged: monthView.gotoNextMonth(selectedTabIndex)
    }

    MonthView {
        id: monthView
        onMonthStartChanged: tabs.selectedTabIndex = monthStart.getMonth()
        y: pageArea.y
    }

    EventView {
        id: eventView
        property real minY: pageArea.y + monthView.compressedHeight
        property real maxY: pageArea.y + monthView.height
        y: maxY
        width: mainView.width
        height: parent.height - monthView.compressedHeight
        currentDayStart: monthView.currentDayStart
        Component.onCompleted: {
            incrementCurrentDay.connect(monthView.incrementCurrentDay)
            decrementCurrentDay.connect(monthView.decrementCurrentDay)
        }
        MouseArea {
            id: drawer
            property bool compression: true
            anchors.fill: parent
            drag {
                axis: Drag.YAxis
                target: eventView
                minimumY: monthView.y + monthView.compressedHeight
                maximumY: monthView.y + monthView.height
                onActiveChanged: {
                    if (compression) {
                        if (drag.active) {
                            monthView.compressed = true
                        }
                        else {
                            yBehavior.enabled = true
                            eventView.y =  Qt.binding(function() { return eventView.minY })
                            compression = false
                        }
                    }
                    else {
                        if (drag.active) {}
                        else{
                            eventView.y =  Qt.binding(function() { return eventView.maxY })
                            monthView.compressed = false
                            compression = true
                        }
                    }
                }
            }
        }
        Behavior on y {
            id: yBehavior
            enabled: false
            NumberAnimation { duration: 100 }
        }
    }

    tools: ToolbarActions {
        Action {
            iconSource: Qt.resolvedUrl("avatar.png")
            text: i18n.tr("To-do")
            onTriggered:; // FIXME
        }
        Action {
            iconSource: Qt.resolvedUrl("avatar.png")
            text: i18n.tr("New Event")
            onTriggered:; // FIXME
        }
        Action {
            iconSource: Qt.resolvedUrl("avatar.png")
            text: i18n.tr("Timeline")
            onTriggered:; // FIXME
        }
    }
}