Advertisement
Guest User

Untitled

a guest
Dec 30th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import bb.cascades 1.0
  2. import bb.system 1.0
  3. import QtQuick 1.0
  4. import bb.data 1.0
  5. import nemory.Snap2ChatAPI 1.0
  6. import org.labsquare 1.0
  7. import nemory.PhotoCamera 1.0
  8. //import bb.platform 1.0
  9. import bb.platform 1.0
  10.  
  11. import "../sheets"
  12. import "../pages"
  13. import "../components"
  14. import "../js/globals.js" as Globals
  15.  
  16. NavigationPane
  17. {
  18.     id: navigationPane
  19.     property variant tabbedPane;
  20.     property string therecipient : "";
  21.     property bool dataSourceLoading : false;
  22.     property string dataSourceURL : _app.getSetting("server", Globals.hostname) + "?action=getfriendstories&username=" + username + "&auth_token=" + auth_token;
  23.    
  24.     onPopTransitionEnded:
  25.     {
  26.         loadStories();
  27.        
  28.         settingSheetClosed();
  29.        
  30.         titleBar.setTitleBarColor();
  31.     }
  32.  
  33.     function setTitleBarColor()
  34.     {
  35.         titleBar.setTitleBarColor();
  36.     }
  37.    
  38.     attachedObjects:
  39.     [
  40.         SendSnap
  41.         {
  42.             id: sendSnapSheet
  43.             onClosed:
  44.             {
  45.                 loadStories();
  46.             }
  47.         },
  48.         Notification
  49.         {
  50.             id: notifications
  51.         }
  52.     ]
  53.    
  54.     function loadStories()
  55.     {
  56. //        loadingText.text = "";
  57. //        loadingBox.visible = true;
  58. //        listView.refreshHeader();
  59.     }
  60.    
  61.     Page
  62.     {
  63.         id: page
  64.         titleBar: Snap2ChatTitleBar
  65.         {
  66.             id: titleBar
  67.             tab : "stories"
  68.         }
  69.        
  70.         Container
  71.         {
  72.             layout: DockLayout {}
  73.             horizontalAlignment: HorizontalAlignment.Fill
  74.  
  75.             Container
  76.             {
  77.                 id: results
  78.                 horizontalAlignment: HorizontalAlignment.Fill
  79.                
  80.                 Header
  81.                 {
  82.                     id: listViewHeader
  83.                     title: "STORIES (coming very soon :)"
  84.                 }
  85.                
  86.                 PullToRefreshListView
  87.                 {
  88.                     id: listView
  89.                     dataModel: dataModel
  90.                     horizontalAlignment: HorizontalAlignment.Fill
  91.                    
  92.                     listItemComponents:
  93.                     [
  94.                         ListItemComponent
  95.                         {
  96.                             StoryItem
  97.                             {
  98.                                 id: root
  99.                             }
  100.                         }
  101.                     ]
  102.                    
  103.                     attachedObjects:
  104.                     [
  105.                         ArrayDataModel
  106.                         {
  107.                             id: dataModel
  108.                         },
  109.                         DataSource
  110.                         {
  111.                             id: dataSource
  112.                             source: dataSourceURL
  113.                             type: DataSourceType.Json
  114.                             remote: true
  115.                             onDataLoaded:
  116.                             {  
  117.                                 console.log("LOADED STORIES: " + data.toString());
  118.                                
  119.                                 dataSourceLoading = false;              
  120.                                
  121.                                 if(data != null)
  122.                                 {
  123.                                     listViewHeader.subtitle = data.length;
  124.                                    
  125.                                     listView.listItemComponents[0] = null;
  126.                                    
  127.                                     dataModel.clear();
  128.                                     dataModel.ListItem.destroy();
  129.                                     dataModel = null;
  130.                                     dataModel.insert(0, data);
  131.                                    
  132.                                     if(data.length == 0)
  133.                                     {
  134.                                         loadingBox.visible = true;
  135.                                         loadingText.text = "No stories to show yet. :(";
  136.                                     }
  137.                                     else
  138.                                     {
  139.                                         loadingText.text = "";
  140.                                         loadingBox.visible = false;
  141.                                     }
  142.                                    
  143.                                     listView.scroll();
  144.                                 }
  145.                                 else
  146.                                 {
  147.                                     loadingBox.visible = false;
  148.                                     loadStories();
  149.                                 }
  150.                             }
  151.                             onError:
  152.                             {
  153.                                 _app.showToast("Retrying...");
  154.                                 dataSourceLoading = false;
  155.                                 loadingText.text = "";
  156.                                 loadingBox.visible = false;
  157.                                 source = "";
  158.                                 source = dataSourceURL;
  159.                                 listView.scroll();
  160.                             }
  161.                         },
  162.                         StoryItem
  163.                         {
  164.                             id: storyItem
  165.                         }
  166.                     ]
  167.                    
  168.                     function refreshTriggered()
  169.                     {
  170.                         if(!dataSourceLoading)
  171.                         {
  172.                             dataSourceLoading = true;
  173.                             dataSource.load();
  174.                         }
  175.                     }
  176.                    
  177.                     function getCurrentUser()
  178.                     {
  179.                         return _app.getSetting("username", "");
  180.                     }
  181.                 }
  182.             }
  183.            
  184.             Container
  185.             {
  186.                 id: loadingBox
  187.                 horizontalAlignment: HorizontalAlignment.Fill
  188.                 verticalAlignment: VerticalAlignment.Fill
  189.                 touchPropagationMode: TouchPropagationMode.None
  190.                 layout: DockLayout {}
  191.                
  192.                 Container
  193.                 {
  194.                     horizontalAlignment: HorizontalAlignment.Right
  195.                     verticalAlignment: VerticalAlignment.Bottom
  196.                     rightPadding: 20
  197.                     bottomPadding: 20
  198.                    
  199.                     ActivityIndicator
  200.                     {
  201.                         id: loadingIndicator
  202.                         visible: (loadingText.text != "You have no stories. :(")
  203.                         running: loadingBox.visible && (loadingText.text != "You have no stories. :(")
  204.                         preferredHeight: 60
  205.                     }
  206.                 }
  207.                
  208.                 Container
  209.                 {
  210.                     verticalAlignment: VerticalAlignment.Center
  211.                     horizontalAlignment: HorizontalAlignment.Center
  212.                     topPadding: 250
  213.                    
  214.                     Label
  215.                     {
  216.                         id: loadingText
  217.                         text: "Hang on for the next version 0.8.5 update :)"
  218.                         textStyle.fontStyle: FontStyle.Italic
  219.                         verticalAlignment: VerticalAlignment.Center
  220.                         horizontalAlignment: HorizontalAlignment.Center
  221.                         textStyle.fontSize: FontSize.XSmall
  222.                         multiline: true
  223.                     }
  224.                 }
  225.             }
  226.         }
  227.        
  228.         actions:
  229.         [
  230.             ActionItem
  231.             {
  232.                 title: "Refresh"
  233.                 ActionBar.placement: ActionBarPlacement.OnBar
  234.                 imageSource: "asset:///images/snapchat/aa_action_bar_stories_refresh.png"
  235.                 onTriggered:
  236.                 {
  237.                     loadStories();
  238.                 }
  239.             }
  240.         ]
  241.     }
  242. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement