Skip to content

Instantly share code, notes, and snippets.

@Nevon
Created December 25, 2014 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nevon/ecf0e99fe189b2c38b22 to your computer and use it in GitHub Desktop.
Save Nevon/ecf0e99fe189b2c38b22 to your computer and use it in GitHub Desktop.
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.ListItems 1.0 as ListItem
import "../components/JSONListModel"
Page {
id: tickerPage
anchors.fill: parent
title: i18n.tr("Dota 2 Match Ticker")
UbuntuListView {
id: matchList
anchors.fill: parent
model: tickerFeed.model
visible: model.count > 0
JSONListModel {
id: tickerFeed
source: "http://dailydota2.com/match-apis"
query: "$.matches[*]"
}
PullToRefresh {
enabled: true
refreshing: tickerFeed.status == tickerFeed.loadingStatus
onRefresh: tickerFeed.reload()
}
delegate: ListItem.Subtitled {
id: matchItemDelegate
text: model.team1.team_name + " " + i18n.tr("vs") + " " + model.team2.team_name
subText: (model.status === 1 || model.timediff < 0) ? i18n.tr("LIVE") : model.starttime
}
}
Label {
visible: matchList.model.count === 0 && tickerFeed.status === tickerFeed.readyStatus
anchors.centerIn: parent
text: i18n.tr("No upcoming matches")
fontSize: "medium"
}
Label {
visible: tickerFeed.status === tickerFeed.errorStatus
anchors.centerIn: parent
text: i18n.tr("Something went wrong")
}
tools: ToolbarItems {
ToolbarButton {
action: {
text: i18n.tr("Refresh")
iconName: "refresh"
onTriggered: tickerFeed.reload()
}
}
locked: true
opened: true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment