~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

Viewing changes to DayView.qml

  • Committer: Kunal Parmar
  • Date: 2014-10-03 04:15:55 UTC
  • mto: This revision was merged to the branch mainline in revision 498.
  • Revision ID: pkunal.parmar@gmail.com-20141003041555-fvk6rqflur745dlr
Dayview like iOS

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
            commonHeaderActions.reloadAction
50
50
        ]
51
51
 
52
 
        contents: Column{
53
 
            width: parent ? parent.width - units.gu(2) : undefined
54
 
 
55
 
            Label {
56
 
                fontSize: "medium"
57
 
                text: Qt.locale().standaloneDayName(currentDay.getDay())
58
 
                font.capitalization: Font.Capitalize
59
 
            }
60
 
 
61
 
            Label {
62
 
                id:cuurentDay
63
 
                objectName:"monthYearLabel"
64
 
                fontSize: "large"
65
 
                // TRANSLATORS: this is a time formatting string,
66
 
                // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
67
 
                // It's used in the header of the day view
68
 
                text:i18n.tr(currentDay.toLocaleString(Qt.locale(),i18n.tr("MMMM dd, yyyy")))
69
 
            }
 
52
        contents: Label {
 
53
            id:monthYear
 
54
            objectName:"monthYearLabel"
 
55
            fontSize: "x-large"
 
56
            text: i18n.tr(currentDay.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
 
57
            font.capitalization: Font.Capitalize
70
58
        }
71
59
    }
72
60
 
73
 
    PathViewBase{
74
 
        id: dayViewPath
75
 
        objectName: "dayViewPath"
76
 
 
77
 
        property var startDay: currentDay
78
 
        //This is used to scroll all view together when currentItem scrolls
79
 
        property var childContentY;
80
 
 
 
61
    Column {
81
62
        anchors.fill: parent
82
 
 
83
 
        onNextItemHighlighted: {
84
 
            //next day
85
 
            currentDay = currentDay.addDays(1);
86
 
        }
87
 
 
88
 
        onPreviousItemHighlighted: {
89
 
            //previous day
90
 
            currentDay = currentDay.addDays(-1);
91
 
        }
92
 
 
93
 
        delegate: TimeLineBaseComponent {
94
 
            id: timeLineView
95
 
            objectName: "DayComponent-"+index
96
 
 
 
63
        anchors.topMargin: units.gu(1)
 
64
        spacing: units.gu(1)
 
65
 
 
66
        TimeLineHeader{
 
67
            id: dayHeader
 
68
            objectName: "dayHeader"
97
69
            type: ViewType.ViewTypeDay
 
70
            currentDay: dayViewPage.currentDay
 
71
 
 
72
            Component.onCompleted: {
 
73
                date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
 
74
            }
 
75
 
 
76
            function nextDay() {
 
77
                if(currentDay >= date.addDays(7)) {
 
78
                    date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
 
79
                    dayHeader.incrementCurrentIndex();
 
80
                }
 
81
            }
 
82
 
 
83
            function previousDay() {
 
84
                if( currentDay < date) {
 
85
                    date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
 
86
                    dayHeader.decrementCurrentIndex();
 
87
                }
 
88
            }
 
89
        }
 
90
 
 
91
        PathViewBase{
 
92
            id: dayViewPath
 
93
            objectName: "dayViewPath"
 
94
 
 
95
            property var startDay: currentDay
 
96
            //This is used to scroll all view together when currentItem scrolls
 
97
            property var childContentY;
98
98
 
99
99
            width: parent.width
100
 
            height: parent.height
101
 
            z: index == dayViewPath.currentIndex ? 2 : 1
102
 
            isActive: true
103
 
 
104
 
            Connections{
105
 
                target: dayViewPage
106
 
                onIsCurrentPageChanged:{
107
 
                    if(dayViewPage.isCurrentPage){
108
 
                        timeLineView.scrollToCurrentTime();
 
100
            height: dayViewPage.height - dayViewPath.y
 
101
 
 
102
            onNextItemHighlighted: {
 
103
                //next day
 
104
                currentDay = currentDay.addDays(1);
 
105
                dayHeader.nextDay();
 
106
            }
 
107
 
 
108
            onPreviousItemHighlighted: {
 
109
                //previous day
 
110
                currentDay = currentDay.addDays(-1);
 
111
                dayHeader.previousDay();
 
112
            }
 
113
 
 
114
            delegate: TimeLineBaseComponent {
 
115
                id: timeLineView
 
116
                objectName: "DayComponent-"+index
 
117
 
 
118
                type: ViewType.ViewTypeDay
 
119
 
 
120
                width: parent.width
 
121
                height: parent.height
 
122
                z: index == dayViewPath.currentIndex ? 2 : 1
 
123
                isActive: true
 
124
 
 
125
                Connections{
 
126
                    target: dayViewPage
 
127
                    onIsCurrentPageChanged:{
 
128
                        if(dayViewPage.isCurrentPage){
 
129
                            timeLineView.scrollToCurrentTime();
 
130
                        }
109
131
                    }
110
132
                }
111
 
            }
112
 
 
113
 
            //get contentY value from PathView, if its not current Item
114
 
            Binding{
115
 
                target: timeLineView
116
 
                property: "contentY"
117
 
                value: dayViewPath.childContentY;
118
 
                when: !timeLineView.PathView.isCurrentItem
119
 
            }
120
 
 
121
 
            //set PathView's contentY property, if its current item
122
 
            Binding{
123
 
                target: dayViewPath
124
 
                property: "childContentY"
125
 
                value: contentY
126
 
                when: timeLineView.PathView.isCurrentItem
127
 
            }
128
 
 
129
 
            contentInteractive: timeLineView.PathView.isCurrentItem
130
 
 
131
 
            startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
 
133
 
 
134
                //get contentY value from PathView, if its not current Item
 
135
                Binding{
 
136
                    target: timeLineView
 
137
                    property: "contentY"
 
138
                    value: dayViewPath.childContentY;
 
139
                    when: !timeLineView.PathView.isCurrentItem
 
140
                }
 
141
 
 
142
                //set PathView's contentY property, if its current item
 
143
                Binding{
 
144
                    target: dayViewPath
 
145
                    property: "childContentY"
 
146
                    value: contentY
 
147
                    when: timeLineView.PathView.isCurrentItem
 
148
                }
 
149
 
 
150
                contentInteractive: timeLineView.PathView.isCurrentItem
 
151
 
 
152
                startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
 
153
            }
132
154
        }
133
155
    }
134
156
}
135