2
2
import Ubuntu.Components 0.1
3
3
import "DateLib.js" as DateLib
4
import "colorUtils.js" as Color
8
readonly property var monthStart: currentItem != null ? currentItem.monthStart : (new Date())
9
readonly property var monthStart: currentItem != null ? currentItem.monthStart : (new Date()).monthStart()
10
readonly property var monthEnd: currentItem != null ? currentItem.monthEnd : (new Date()).monthStart().addMonths(1)
11
readonly property var currentDayStart: intern.currentDayStart
13
signal incrementCurrentDay
14
signal decrementCurrentDay
10
16
signal gotoNextMonth(int month)
18
onCurrentItemChanged: {
19
if (currentItem == null) {
20
intern.currentDayStart = intern.currentDayStart
23
if (currentItem.monthStart <= intern.currentDayStart && intern.currentDayStart < currentItem.monthEnd)
25
if (currentItem.monthStart <= intern.today && intern.today < currentItem.monthEnd)
26
intern.currentDayStart = intern.today
28
intern.currentDayStart = currentItem.monthStart
31
onIncrementCurrentDay: {
32
var t = intern.currentDayStart.addDays(1)
34
intern.currentDayStart = t
36
else if (currentIndex < count - 1) {
37
intern.currentDayStart = t
38
currentIndex = currentIndex + 1
42
onDecrementCurrentDay: {
43
var t = intern.currentDayStart.addDays(-1)
44
if (t >= monthStart) {
45
intern.currentDayStart = t
47
else if (currentIndex > 0) {
48
intern.currentDayStart = t
49
currentIndex = currentIndex - 1
13
54
if (monthStart.getMonth() != month) {
14
55
var i = intern.monthIndex0, m = intern.today.getMonth()
28
73
property int monthCount: 49 // months for +-2 years
30
75
property var today: (new Date()).midnight() // TODO: update at midnight
76
property var currentDayStart: today
31
77
property int monthIndex0: monthCount / 2
32
78
property var monthStart0: today.monthStart()
70
116
property var dayStart: gridStart.addDays(index)
71
117
property bool isCurrentMonth: (monthStart <= dayStart) && (dayStart < monthEnd)
72
118
property bool isToday: dayStart.getTime() == intern.today.getTime()
73
// property int weekday: (index % 7 + intern.weekstartDay) % 7
74
// property bool isSunday: weekday == 0
119
property bool isCurrent: dayStart.getTime() == intern.currentDayStart.getTime()
120
property int weekday: (index % 7 + intern.weekstartDay) % 7
121
property bool isSunday: weekday == 0
75
122
width: intern.squareUnit
76
123
height: intern.squareUnit
77
Text { // FIXME: Label is seriously less performant than Text
127
color: Color.warmGrey
78
131
anchors.centerIn: parent
79
132
text: dayStart.getDate()
80
133
font: themeDummy.font
81
color: isToday ? "#DD4814" : themeDummy.color
82
// FIXME: need to get the colors from theme engine
83
scale: isToday ? 1.5 : 1.
134
color: isToday ? Color.ubuntuOrange : themeDummy.color
135
scale: isCurrent ? 1.5 : 1.
84
136
opacity: isCurrentMonth ? 1. : 0.3
138
NumberAnimation { duration: 100 }
86
// Component.onCompleted: console.log(dayStart, intern.today, isToday)
141
// Component.onCompleted: console.log(dayStart, intern.currentDayStart)