Merge lp:~rpadovani/ubuntu-calculator-app/favouritesScreenBlank into lp:ubuntu-calculator-app

Proposed by Riccardo Padovani
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 128
Merged at revision: 137
Proposed branch: lp:~rpadovani/ubuntu-calculator-app/favouritesScreenBlank
Merge into: lp:ubuntu-calculator-app
Diff against target: 151 lines (+75/-1)
4 files modified
app/engine/CalculationHistory.qml (+16/-1)
app/ui/FavouritePage.qml (+9/-0)
app/upstreamcomponents/EmptyState.qml (+44/-0)
app/upstreamcomponents/ubuntu_component_store.json (+6/-0)
To merge this branch: bzr merge lp:~rpadovani/ubuntu-calculator-app/favouritesScreenBlank
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Bartosz Kosiorek Approve
Review via email: mp+252155@code.launchpad.net

Commit message

Use EmptyState from UCS to have a text in favourite page when is empty

Description of the change

Use EmptyState from UCS to have a text in favourite page when is empty

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

How I could get this empty state?
I delete all calculations and favourites and I'm still can't get Empty State.

review: Needs Information
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Sorry, my bad, now should work

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

It is not working with following case:
- create some favourite.
- swipe bottom edge to display to display all favourites
- uncheck star, to remove favourites

Expected:
  It should display empty state.

Current:
  Nothing is displayed.

review: Needs Fixing
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Should be ok now, sorry again

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Looks ok to me.
Thanks

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/engine/CalculationHistory.qml'
2--- app/engine/CalculationHistory.qml 2015-02-26 20:13:40 +0000
3+++ app/engine/CalculationHistory.qml 2015-03-13 18:20:28 +0000
4@@ -19,6 +19,7 @@
5 Item {
6 property var calculationHistoryDatabase: null
7 readonly property int lastDatabaseVersion: 1
8+ property int numberOfFavourites: 0
9
10 ListModel {
11 id: history
12@@ -30,6 +31,7 @@
13 // the history
14 if (calc.isFavourite === 1) {
15 calc.isFavourite = true;
16+ numberOfFavourites++;
17 } else {
18 calc.isFavourite = false;
19 }
20@@ -117,6 +119,9 @@
21 // addCalculationToDatabase the job to add it to the database
22 // that is called only after the element has been added to the
23 // model
24+ if (isFavourite) {
25+ numberOfFavourites++;
26+ }
27 var date = Date.now();
28 history.append({"formula": formula,
29 "result": result,
30@@ -157,6 +162,12 @@
31 WHERE dbId=?',
32 [isFavourite, favouriteText, dbId]
33 );
34+ if (!history.get(listIndex).isFavourite && isFavourite) {
35+ numberOfFavourites++;
36+ }
37+ if (history.get(listIndex).isFavourite && !isFavourite) {
38+ numberOfFavourites--;
39+ }
40 history.setProperty(listIndex, "isFavourite", isFavourite);
41 history.setProperty(listIndex, "favouriteText", favouriteText);
42 }
43@@ -169,7 +180,9 @@
44
45 function deleteCalc(dbId, id) {
46 openDatabase();
47-
48+ if (history.get(id).isFavourite) {
49+ numberOfFavourites--;
50+ }
51 history.setProperty(id, "dbId", -1);
52
53 timer.execute.push(function () {
54@@ -188,8 +201,10 @@
55 var removed = removedFavourites[0];
56 history.setProperty(removedFavourites[0], "isFavourite", false);
57 removedFavourites.splice(0, 1);
58+ numberOfFavourites--;
59
60 for (var index in removedFavourites) {
61+ numberOfFavourites--;
62 history.setProperty(removedFavourites[index], "isFavourite", false);
63 removed += "," + removedFavourites[index];
64 }
65
66=== modified file 'app/ui/FavouritePage.qml'
67--- app/ui/FavouritePage.qml 2015-03-02 21:11:20 +0000
68+++ app/ui/FavouritePage.qml 2015-03-13 18:20:28 +0000
69@@ -21,6 +21,7 @@
70 import Ubuntu.Components.ListItems 1.0 as ListItem
71
72 import "../engine"
73+import "../upstreamcomponents"
74
75 Page {
76 anchors.fill: parent
77@@ -37,6 +38,14 @@
78 }
79 }
80
81+ EmptyState {
82+ title: i18n.tr("No favourites")
83+ subTitle: i18n.tr("Swipe calculations to the left\nto mark as favourites")
84+ iconName: "starred"
85+ anchors.centerIn: parent
86+ visible: calculationHistory.numberOfFavourites == 0;
87+ }
88+
89 ListView {
90 id: favouriteListview
91 anchors.fill: parent
92
93=== added file 'app/upstreamcomponents/EmptyState.qml'
94--- app/upstreamcomponents/EmptyState.qml 1970-01-01 00:00:00 +0000
95+++ app/upstreamcomponents/EmptyState.qml 2015-03-13 18:20:28 +0000
96@@ -0,0 +1,44 @@
97+import QtQuick 2.0
98+import Ubuntu.Components 1.1
99+
100+/*
101+ Component which displays an empty state (approved by design). It offers an
102+ icon, title and subtitle to describe the empty state.
103+*/
104+
105+Item {
106+ id: emptyState
107+
108+ // Public APIs
109+ property alias iconName: emptyIcon.name
110+ property alias iconSource: emptyIcon.source
111+ property alias iconColor: emptyIcon.color
112+ property alias title: emptyLabel.text
113+ property alias subTitle: emptySublabel.text
114+
115+ height: childrenRect.height
116+
117+ Icon {
118+ id: emptyIcon
119+ anchors.horizontalCenter: parent.horizontalCenter
120+ height: units.gu(10)
121+ width: height
122+ color: "#BBBBBB"
123+ }
124+
125+ Label {
126+ id: emptyLabel
127+ anchors.top: emptyIcon.bottom
128+ anchors.topMargin: units.gu(5)
129+ anchors.horizontalCenter: parent.horizontalCenter
130+ fontSize: "large"
131+ font.bold: true
132+ }
133+
134+ Label {
135+ id: emptySublabel
136+ anchors.top: emptyLabel.bottom
137+ anchors.horizontalCenter: parent.horizontalCenter
138+ horizontalAlignment: Text.AlignHCenter
139+ }
140+}
141
142=== added file 'app/upstreamcomponents/ubuntu_component_store.json'
143--- app/upstreamcomponents/ubuntu_component_store.json 1970-01-01 00:00:00 +0000
144+++ app/upstreamcomponents/ubuntu_component_store.json 2015-03-13 18:20:28 +0000
145@@ -0,0 +1,6 @@
146+{
147+ "name": "EmptyState",
148+ "description": "This widget provides a standardized way to show an empty state (approved by Canonical designers) to improve the user experience and avoid showing a blank page.",
149+ "version": "1.0",
150+ "documentation_url": "http://ubuntu-component-store.readthedocs.org/en/latest/_components/emptystate.html"
151+}

Subscribers

People subscribed via source and target branches