summaryrefslogtreecommitdiff
path: root/qml/watch/WatchView.qml
blob: ca880ebf1383fc4ea18d07952250fee0edae08e7 (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
import QtQuick 2.0

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("../pages/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();
	}
}