Merge pull request #11276 from zfox23/commerce_polishTxnHistory

Polish transaction history and prepare for whatever new design
This commit is contained in:
Zach Fox 2017-08-30 13:25:55 -07:00 committed by GitHub
commit 500427010d
3 changed files with 60 additions and 20 deletions

View file

@ -74,7 +74,9 @@ Rectangle {
if (result.status !== 'success') {
console.log("Failed to get purchases", result.message);
} else {
purchasesModel.clear();
purchasesModel.append(result.data.assets);
filteredPurchasesModel.clear();
filteredPurchasesModel.append(result.data.assets);
}
}

View file

@ -24,6 +24,7 @@ Item {
HifiConstants { id: hifi; }
id: root;
property bool historyReceived: false;
Hifi.QmlCommerce {
id: commerce;
@ -41,9 +42,10 @@ Item {
}
onHistoryResult : {
historyReceived = true;
if (result.status === 'success') {
var txt = result.data.history.map(function (h) { return h.text; }).join("<hr>");
transactionHistoryText.text = txt;
transactionHistoryModel.clear();
transactionHistoryModel.append(result.data.history);
}
}
}
@ -111,6 +113,7 @@ Item {
onVisibleChanged: {
if (visible) {
historyReceived = false;
commerce.balance();
commerce.history();
}
@ -233,24 +236,66 @@ Item {
// Style
color: hifi.colors.faintGray;
}
ListModel {
id: transactionHistoryModel;
}
Rectangle {
id: transactionHistory;
anchors.top: recentActivityText.bottom;
anchors.topMargin: 4;
anchors.bottom: parent.bottom;
anchors.left: parent.left;
anchors.right: parent.right;
color: "white";
// some placeholder stuff
TextArea {
id: transactionHistoryText;
text: "<hr>history unavailable<hr>";
textFormat: TextEdit.AutoText;
font.pointSize: 10;
ListView {
id: transactionHistory;
anchors.centerIn: parent;
width: parent.width - 12;
height: parent.height - 12;
visible: transactionHistoryModel.count !== 0;
clip: true;
model: transactionHistoryModel;
delegate: Item {
width: parent.width;
height: transactionText.height + 30;
RalewayRegular {
id: transactionText;
text: model.text;
// Style
size: 18;
width: parent.width;
height: paintedHeight;
anchors.verticalCenter: parent.verticalCenter;
color: "black";
wrapMode: Text.WordWrap;
// Alignment
horizontalAlignment: Text.AlignLeft;
verticalAlignment: Text.AlignVCenter;
}
HifiControlsUit.Separator {
anchors.left: parent.left;
anchors.right: parent.right;
anchors.bottom: parent.bottom;
}
}
onAtYEndChanged: {
if (transactionHistory.atYEnd) {
console.log("User scrolled to the bottom of 'Recent Activity'.");
// Grab next page of results and append to model
}
}
}
// This should never be visible (since you immediately get 100 HFC)
RalewayRegular {
id: emptyTransationHistory;
size: 24;
visible: !transactionHistory.visible && root.historyReceived;
text: "Recent Activity Unavailable";
anchors.fill: parent;
horizontalAlignment: Text.AlignLeft;
verticalAlignment: Text.AlignTop;
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
}
}
}

View file

@ -24,7 +24,7 @@ Rectangle {
HifiConstants { id: hifi; }
id: root;
property string lastPage: "securityImage";
property string lastPage: "initialize";
// Style
color: hifi.colors.baseGray;
@ -58,16 +58,9 @@ Rectangle {
//
Item {
id: securityImageContainer;
visible: false;
// Anchors
anchors.fill: parent;
onVisibleChanged: {
if (visible) {
commerce.getSecurityImage();
}
}
Item {
id: securityImageTitle;
// Size