-
Notifications
You must be signed in to change notification settings - Fork 1
/
WorkoutView.qml
130 lines (108 loc) · 3.73 KB
/
WorkoutView.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import QtQuick 2.0
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.1
Rectangle {
id: workoutViewRootRect
anchors.fill: parent
property int postIndex: -1;
property int imageIndex;
property string title;
property string category;
property var photos: []
property string preparation;
property string execution;
CustomToolbar {
id: mainToolBar
Layout.preferredWidth: parent.width
ToolImageButton {
id: goBackButton
anchors.right: parent.right
imgSrc: "icons/back_black.png"
onClicked: mainStack.pop()
}
}
Rectangle {
id: contentWrapper
width: parent.width > 1200 ? 1080: parent.width * 0.9
anchors.top: mainToolBar.bottom
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.leftMargin: 10
anchors.rightMargin: 10
clip: true
Flickable {
anchors.fill: parent
contentWidth: parent.width
contentHeight: mainColumn.height + 40 // TODO
interactive: true
boundsBehavior: Flickable.StopAtBounds
Column {
id: mainColumn
width: parent.width
spacing: 20
Image {
id: postCoverImage
fillMode: Image.PreserveAspectFit
anchors.horizontalCenter: parent.horizontalCenter
height: 300
width: parent.width
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
padding: 10
spacing: 5
Button {
iconSource: "icons/left_black_small.png"
onClicked: {
imageIndex = (imageIndex-1) < 0 ? photos.length - 1: imageIndex-1;
postCoverImage.source = "workouts/" + photos[imageIndex].image;
}
}
Button {
iconSource: "icons/right_black_small.png"
onClicked: {
imageIndex = (imageIndex+1) % photos.length;
postCoverImage.source = "workouts/" + photos[imageIndex].image;
}
}
}
Text {
text: title
width: parent.width * 0.8
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: 24
wrapMode: Text.WordWrap
font.weight: Font.Bold
horizontalAlignment: Text.AlignHCenter
}
HighlightedText {
text: "preparation"
}
Text {
text: workoutViewRootRect.preparation
wrapMode: Text.Wrap
width: parent.width
horizontalAlignment: Text.AlignHCenter
}
HighlightedText {
text: "execution"
}
Text {
text: workoutViewRootRect.execution
width: parent.width
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
}
}
}
}
Component.onCompleted: {
if (postIndex < 0)
return mainStack.pop();
imageIndex = 0;
postCoverImage.source = "workouts/" + photos[imageIndex].image;
}
}