Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bb.cascades 1.0
- import bb.system 1.0
- import QtQuick 1.0
- import bb.data 1.0
- import nemory.Snap2ChatAPI 1.0
- import org.labsquare 1.0
- import nemory.PhotoCamera 1.0
- //import bb.platform 1.0
- import bb.platform 1.0
- import "../sheets"
- import "../pages"
- import "../components"
- import "../js/globals.js" as Globals
- NavigationPane
- {
- id: navigationPane
- property variant tabbedPane;
- property string therecipient : "";
- property bool dataSourceLoading : false;
- property string dataSourceURL : _app.getSetting("server", Globals.hostname) + "?action=getfriendstories&username=" + username + "&auth_token=" + auth_token;
- onPopTransitionEnded:
- {
- loadStories();
- settingSheetClosed();
- titleBar.setTitleBarColor();
- }
- function setTitleBarColor()
- {
- titleBar.setTitleBarColor();
- }
- attachedObjects:
- [
- SendSnap
- {
- id: sendSnapSheet
- onClosed:
- {
- loadStories();
- }
- },
- Notification
- {
- id: notifications
- }
- ]
- function loadStories()
- {
- // loadingText.text = "";
- // loadingBox.visible = true;
- // listView.refreshHeader();
- }
- Page
- {
- id: page
- titleBar: Snap2ChatTitleBar
- {
- id: titleBar
- tab : "stories"
- }
- Container
- {
- layout: DockLayout {}
- horizontalAlignment: HorizontalAlignment.Fill
- Container
- {
- id: results
- horizontalAlignment: HorizontalAlignment.Fill
- Header
- {
- id: listViewHeader
- title: "STORIES (coming very soon :)"
- }
- PullToRefreshListView
- {
- id: listView
- dataModel: dataModel
- horizontalAlignment: HorizontalAlignment.Fill
- listItemComponents:
- [
- ListItemComponent
- {
- StoryItem
- {
- id: root
- }
- }
- ]
- attachedObjects:
- [
- ArrayDataModel
- {
- id: dataModel
- },
- DataSource
- {
- id: dataSource
- source: dataSourceURL
- type: DataSourceType.Json
- remote: true
- onDataLoaded:
- {
- console.log("LOADED STORIES: " + data.toString());
- dataSourceLoading = false;
- if(data != null)
- {
- listViewHeader.subtitle = data.length;
- listView.listItemComponents[0] = null;
- dataModel.clear();
- dataModel.ListItem.destroy();
- dataModel = null;
- dataModel.insert(0, data);
- if(data.length == 0)
- {
- loadingBox.visible = true;
- loadingText.text = "No stories to show yet. :(";
- }
- else
- {
- loadingText.text = "";
- loadingBox.visible = false;
- }
- listView.scroll();
- }
- else
- {
- loadingBox.visible = false;
- loadStories();
- }
- }
- onError:
- {
- _app.showToast("Retrying...");
- dataSourceLoading = false;
- loadingText.text = "";
- loadingBox.visible = false;
- source = "";
- source = dataSourceURL;
- listView.scroll();
- }
- },
- StoryItem
- {
- id: storyItem
- }
- ]
- function refreshTriggered()
- {
- if(!dataSourceLoading)
- {
- dataSourceLoading = true;
- dataSource.load();
- }
- }
- function getCurrentUser()
- {
- return _app.getSetting("username", "");
- }
- }
- }
- Container
- {
- id: loadingBox
- horizontalAlignment: HorizontalAlignment.Fill
- verticalAlignment: VerticalAlignment.Fill
- touchPropagationMode: TouchPropagationMode.None
- layout: DockLayout {}
- Container
- {
- horizontalAlignment: HorizontalAlignment.Right
- verticalAlignment: VerticalAlignment.Bottom
- rightPadding: 20
- bottomPadding: 20
- ActivityIndicator
- {
- id: loadingIndicator
- visible: (loadingText.text != "You have no stories. :(")
- running: loadingBox.visible && (loadingText.text != "You have no stories. :(")
- preferredHeight: 60
- }
- }
- Container
- {
- verticalAlignment: VerticalAlignment.Center
- horizontalAlignment: HorizontalAlignment.Center
- topPadding: 250
- Label
- {
- id: loadingText
- text: "Hang on for the next version 0.8.5 update :)"
- textStyle.fontStyle: FontStyle.Italic
- verticalAlignment: VerticalAlignment.Center
- horizontalAlignment: HorizontalAlignment.Center
- textStyle.fontSize: FontSize.XSmall
- multiline: true
- }
- }
- }
- }
- actions:
- [
- ActionItem
- {
- title: "Refresh"
- ActionBar.placement: ActionBarPlacement.OnBar
- imageSource: "asset:///images/snapchat/aa_action_bar_stories_refresh.png"
- onTriggered:
- {
- loadStories();
- }
- }
- ]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement