summaryrefslogtreecommitdiff
path: root/qml/pages/WatchView.qml
blob: a5d755efd08d52aa8925999363de7083db01f0ee (plain)
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
import QtQuick 2.0
import "../watch"

Flickable {
	id: watchView
	width: 96
	height: 96
	clip: true
	flickableDirection: Flickable.HorizontalFlick

	property int curPage: 0

	WidgetView {
		id: widgetView
		model: curWidgets
		editMode: true
		onEmptyWidgetClicked: {
			pageStack.push(Qt.resolvedUrl("AddWidget.qml"), {
							   'addToPage': page,
							   'addToPos': pos
						   });
		}
	}

	contentWidth: widgetView.width
	contentHeight: widgetView.height

	NumberAnimation {
		id: pivotAnim
		targets: watchView
		property: "contentX"
		to: curPage * watchView.width
		duration: 100
		easing.type: Easing.InOutQuad
	}

	onMovementStarted: {
		pivotAnim.stop()
	}

	onMovementEnded: {
		curPage = Math.round(watchView.contentX / watchView.width)
		pivotAnim.start()
	}

	function switchToPage(page) {
		curPage = page;
		pivotAnim.start();
	}
}