added back button

added colorAnimation on Progressbar in calculator
This commit is contained in:
Max 2018-11-27 20:58:27 +01:00
parent 2cd966e53c
commit 5e5d8f954a
3 changed files with 64 additions and 47 deletions

View file

@ -120,12 +120,12 @@ Item {
} }
function start(min, max) { function start(min, max) {
calculator.reset()
calculator.nextNumber() calculator.nextNumber()
calculator.state = "running" calculator.state = "running"
} }
function reset() { function reset() {
calculator.state = "starting"
calculator.sum = 0 calculator.sum = 0
calculator.actualNumCount = 0 calculator.actualNumCount = 0
calculator.endPageLabelText = "You Lose!" calculator.endPageLabelText = "You Lose!"
@ -135,9 +135,11 @@ Item {
} }
function checkSum(sumInputText) { function checkSum(sumInputText) {
if (calculator.sum === parseInt(sumInputText)) { if (sumInputText !== "") {
calculator.endPageLabelText = "You Won!" if (calculator.sum === parseInt(sumInputText)) {
calculator.endPageLabelText = "You Won!"
}
calculator.endPageVisibility = true
} }
calculator.endPageVisibility = true
} }
} }

View file

@ -26,7 +26,7 @@ Page {
width: height width: height
text: "check" text: "check"
font.pixelSize: parent.width * 0.03 font.pixelSize: parent.width * 0.03
visible: !endPageVisibility visible: !calculator.endPageVisibility
anchors { anchors {
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
top: parent.top top: parent.top
@ -45,24 +45,37 @@ Page {
anchors { anchors {
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
top: parent.top top: parent.top
topMargin: parent.height * 0.2 topMargin: parent.height * 0.05
}
}
Label {
id: sum
text: "Sum: " + calculator.sum
font.pixelSize: parent.width * 0.1
visible: calculator.endPageVisibility ? ( won.text==="You Lose!" ? true:false):false
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: parent.height * 0.4
} }
} }
/*
Row { Row {
id: buttonRow
anchors { anchors {
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
bottom: parent.bottom bottom: parent.bottom
bottomMargin: parent.height * 0.2 bottomMargin: parent.height * 0.15
} }
height: childrenRect.height height: childrenRect.height
width: childrenRect.width width: childrenRect.width
spacing: root.height * 0.1 spacing: parent.width * 0.1
visible: calculator.endPageVisibility ? true:false
RoundButton { RoundButton {
id: homeButton id: homeButton
height: parent.width * 0.2 height: root.width * 0.2
width: height width: height
text: "home" text: "home"
onClicked: { onClicked: {
@ -73,34 +86,22 @@ Page {
RoundButton { RoundButton {
id: startButtons id: startButtons
height: parent.width * 0.2 height: root.width * 0.2
width: height width: height
text: "start" text: "start"
onClicked: { onClicked: {
calculator.reset()
calculator.state = "starting" calculator.state = "starting"
} }
} }
}
*/
RoundButton { RoundButton {
id: homeButton id: restart
height: parent.width * 0.2 height: root.width * 0.2
width: height width: height
text: "home" text: "restart"
font.pixelSize: parent.width * 0.03 onClicked: {
visible: endPageVisibility calculator.start()
anchors { }
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: parent.height * 0.1
}
onClicked: {
calculator.reset()
calculator.state = "starting"
} }
} }
} }

View file

@ -30,7 +30,7 @@ Page {
ProgressBar { ProgressBar {
id: prog id: prog
property int progress: 0 property int progress: 0
//property string col: "green" property string color: "green"
value: progress/100 value: progress/100
anchors { anchors {
bottom: parent.bottom bottom: parent.bottom
@ -41,12 +41,13 @@ Page {
rightMargin: parent.width * 0.01 rightMargin: parent.width * 0.01
} }
contentItem: Item {
/* Rectangle {
progress: Rectangle { width: prog.visualPosition * parent.width
color: col height: parent.height
color: prog.color
}
} }
*/
NumberAnimation { NumberAnimation {
id: progNumAnim id: progNumAnim
@ -57,17 +58,30 @@ Page {
duration: tick.interval duration: tick.interval
easing.type: Easing.Linear easing.type: Easing.Linear
} }
/*
ColorAnimation { SequentialAnimation {
id: progColAnim id: progColAnim
target: prog loops: 1
property: "color" ColorAnimation {
from: "green" id: progColAnim1
to: "red" target: prog
duration: tick.interval property: "color"
easing.type: Easing.Linear from: "green"
to: "goldenrod"
duration: tick.interval/2
easing.type: Easing.Linear
}
ColorAnimation {
id: progColAnim2
target: prog
property: "color"
from: "goldenrod"
to: "darkRed"
duration: tick.interval/2
easing.type: Easing.Linear
}
} }
*/
} }
Timer { Timer {
@ -89,7 +103,7 @@ Page {
onRunningChanged: { onRunningChanged: {
if(running){ if(running){
progNumAnim.start() progNumAnim.start()
//progColAnim.start() progColAnim.start()
} }
} }
} }