blob: cb400db96546f3a5d18d4a1d7c87b3546e12e88c (
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Basic
import QtQuick.Effects
// Height, width and any other size related properties containing odd looking float or other dividers
// that do not seem to have any logical origin are just arbitrary and based on original design
// and/or personal preference on what looks nice.
Column {
id: root
spacing: -coffeeCardCircle.height / 2
rotation: 180
property alias button: button
property alias coffeeCardRectangle: coffeeCardRectangle
property alias innerCoffeeCardRectangle: innerCoffeeCardRectangle
property alias coffeeCardCircle: coffeeCardCircle
property alias coffeeText: coffeeText
property alias ingredientText: ingredientText
property alias timeText: timeText
property alias actualTimeText: actualTimeText
property alias cupsLeftText: cupsLeftText
property alias box: box
property string coffeeName: ""
property string ingredients: ""
property int time: 4
property int cupsLeft: 0
states: [
State {
name: "portrait"
when: applicationFlow.mode == "portrait"
PropertyChanges {
target: coffeeCardRectangle
implicitHeight: (applicationFlow.stack.height / 2) - 20
- (coffeeCardCircle.height / 2)
implicitWidth: applicationFlow.width / 2.4
}
},
State {
name: "landscape"
when: applicationFlow.mode == "landscape"
PropertyChanges {
target: coffeeCardRectangle
implicitHeight: applicationFlow.height / 2
implicitWidth: applicationFlow.width / 5
}
}
]
Rectangle {
id: coffeeCardRectangle
radius: 8
gradient: Colors.invertedGreyBorder
//! [AbstractButton]
AbstractButton {
width: parent.width - 2
height: parent.height - 2
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
id: button
hoverEnabled: true
checkable: true
enabled: (cupsLeft != 0) ? true : false
transitions: Transition {
NumberAnimation {
properties: "scale"
duration: 50
easing.type: Easing.InOutQuad
}
}
//! [AbstractButton]
contentItem: Rectangle {
id: innerCoffeeCardRectangle
anchors.fill: parent
color: Colors.currentTheme.cardColor
radius: 8
ColumnLayout {
rotation: 180
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 1.19
height: parent.height - (coffeeCardCircle.height / 2)
Text {
id: coffeeText
text: coffeeName
color: Colors.currentTheme.textColor
font.weight: 700
font.pixelSize: 18
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
}
Text {
id: ingredientText
text: ingredients
color: Colors.currentTheme.caption
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width
wrapMode: Text.Wrap
}
Text {
id: timeText
text: "Time"
font.pointSize: 12
color: Colors.currentTheme.caption
wrapMode: Text.Wrap
}
RowLayout {
Layout.bottomMargin: 12
Layout.alignment: Qt.AlignBottom
Text {
id: actualTimeText
Layout.fillWidth: true
text: time + " Mins"
font.pixelSize: 14
color: Colors.currentTheme.textColor
}
Rectangle {
id: box
Layout.preferredHeight: 24
Layout.preferredWidth: 24
color: Colors.currentTheme.cardColor
border.color: Colors.border
border.width: 1
radius: 8
Text {
id: cupsLeftText
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: cupsLeft
font.pixelSize: 12
font.weight: 600
color: Colors.green
}
}
}
}
Rectangle {
id: outOfDialog
width: coffeeCardRectangle.width / 1.5
height: coffeeCardRectangle.height / 5
visible: (cupsLeft != 0) ? false : true
radius: 8
color: (Colors.currentTheme
== Colors.dark) ? Colors.light.cardColor : Colors.dark.cardColor
rotation: 180
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: "Out of " + coffeeName
color: (Colors.currentTheme
== Colors.dark) ? Colors.light.textColor : Colors.dark.textColor
}
}
}
MultiEffect {
source: innerCoffeeCardRectangle
anchors.fill: innerCoffeeCardRectangle
shadowEnabled: true
shadowColor: Colors.shadow
shadowOpacity: (cupsLeft != 0) ? 0.5 : 0.0
}
}
}
Rectangle {
id: coffeeCardCircle
anchors.horizontalCenter: parent.horizontalCenter
implicitHeight: implicitWidth
implicitWidth: coffeeCardRectangle.implicitWidth / 1.36
radius: width * 0.5
gradient: Colors.invertedGreyBorder
Rectangle {
id: innerCoffeeCardCircle
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
height: width
width: parent.width - 2
radius: width * 0.5
color: Colors.currentTheme.cardColor
Image {
source: (Colors.currentTheme == Colors.dark) ? "./images/Cups/card_cup_dark.svg" : "./images/Cups/card_cup_light.svg"
sourceSize.width: coffeeCardCircle.width / 2.2
sourceSize.height: coffeeCardCircle.height / 1.9
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
rotation: 180
}
}
MultiEffect {
source: innerCoffeeCardCircle
anchors.fill: innerCoffeeCardCircle
shadowEnabled: true
shadowColor: Colors.shadow
shadowOpacity: (cupsLeft != 0) ? 0.5 : 0.0
}
}
}
|