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') { if (result.status !== 'success') {
console.log("Failed to get purchases", result.message); console.log("Failed to get purchases", result.message);
} else { } else {
purchasesModel.clear();
purchasesModel.append(result.data.assets); purchasesModel.append(result.data.assets);
filteredPurchasesModel.clear();
filteredPurchasesModel.append(result.data.assets); filteredPurchasesModel.append(result.data.assets);
} }
} }

View file

@ -24,6 +24,7 @@ Item {
HifiConstants { id: hifi; } HifiConstants { id: hifi; }
id: root; id: root;
property bool historyReceived: false;
Hifi.QmlCommerce { Hifi.QmlCommerce {
id: commerce; id: commerce;
@ -41,9 +42,10 @@ Item {
} }
onHistoryResult : { onHistoryResult : {
historyReceived = true;
if (result.status === 'success') { if (result.status === 'success') {
var txt = result.data.history.map(function (h) { return h.text; }).join("<hr>"); transactionHistoryModel.clear();
transactionHistoryText.text = txt; transactionHistoryModel.append(result.data.history);
} }
} }
} }
@ -111,6 +113,7 @@ Item {
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
historyReceived = false;
commerce.balance(); commerce.balance();
commerce.history(); commerce.history();
} }
@ -233,24 +236,66 @@ Item {
// Style // Style
color: hifi.colors.faintGray; color: hifi.colors.faintGray;
} }
ListModel {
id: transactionHistoryModel;
}
Rectangle { Rectangle {
id: transactionHistory;
anchors.top: recentActivityText.bottom; anchors.top: recentActivityText.bottom;
anchors.topMargin: 4; anchors.topMargin: 4;
anchors.bottom: parent.bottom; anchors.bottom: parent.bottom;
anchors.left: parent.left; anchors.left: parent.left;
anchors.right: parent.right; anchors.right: parent.right;
color: "white";
// some placeholder stuff ListView {
TextArea { id: transactionHistory;
id: transactionHistoryText; anchors.centerIn: parent;
text: "<hr>history unavailable<hr>"; width: parent.width - 12;
textFormat: TextEdit.AutoText; height: parent.height - 12;
font.pointSize: 10; 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; anchors.fill: parent;
horizontalAlignment: Text.AlignLeft; horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignTop; verticalAlignment: Text.AlignVCenter;
} }
} }
} }

View file

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