-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeatherView.qml
90 lines (77 loc) · 2.14 KB
/
WeatherView.qml
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
import QtQuick 2.15
import QtQuick.Controls 2.15
Item {
id:cnt
CBtn {
id:btnLeft
setIcon: "qrc:/images/right-arrow.png"
backgroundColor: constColors[0]
imageRotation: 180
onBtnClicked: {
listViewId.decrementCurrentIndex()
}
z:5
implicitWidth: 25
radius:2
anchors {
leftMargin: width*.1
left:parent.left
verticalCenter: parent.verticalCenter
}
}
CBtn {
id:btnRight
setIcon: btnLeft.setIcon
backgroundColor: btnLeft.backgroundColor
z:btnLeft.z
implicitWidth:btnLeft.implicitWidth
radius:btnLeft.radius
onBtnClicked: {
listViewId.incrementCurrentIndex()
}
anchors {
right:parent.right
verticalCenter: parent.verticalCenter
rightMargin: width*.1
}
}
ListView {
id:listViewId
anchors.fill: parent
cacheBuffer:1
orientation: ListView.Horizontal
spacing: 11
clip:true
onCurrentIndexChanged: {
if (currentIndex >= 0 && currentIndex < count) {
positionViewAtIndex(currentIndex, contentY)
}
}
boundsBehavior: Flickable.StopAtBounds
Behavior on currentIndex {
NumberAnimation {
duration: 100
}
}
model:weatherModel
delegate: WeatherItem {
height: listViewId.height
width:isActive ?
varCardWidthSelected:varCardWidthNormal
varDate:model.day
varMaxTemp: Math.ceil(parseFloat(model.maxTemp))
varMinTemp: Math.ceil(parseFloat(model.minTemp))
varTypeWeather:model.weatherType.split(', ')[0]
isActive: index === listViewId.currentIndex
MouseArea {
anchors.fill: parent
onClicked: listViewId.currentIndex = index
}
Behavior on width {
NumberAnimation {
duration: 200
}
}
}
}
}