Qt World Summit Conference App
           import QtQuick 2.0
 import Felgo 4.0
 import Qt5Compat.GraphicalEffects
 import "pages"
 import "common"
 import "common/social"
 Item {
   anchors.fill: parent
   
   property alias navigation: navigation
   
  
   Component.onCompleted: {
     if(system.publishBuild) {
 
 
 
 
 
     }
     notificationTimer.start() 
     checkFeedbackDialog() 
   }
   
   Connections {
     target: dataModel
     onLoadingFailed: NativeDialog.confirm("Failed to update conference data, please try again later.")
     onFavoriteAdded: talk => {
       console.debug("favorite added")
 
 
 
 
       
       scheduleNotificationForTalk(talk.id)
       amplitude.logEvent("Favor Talk",{"title" : talk.title, "talkId" : talk.id})
     }
     onFavoriteRemoved: talk => {
       console.debug("favorite removed")
 
 
 
 
       cancelNotificationForTalk(talk.id)
       amplitude.logEvent("Unfavor Talk",{"title" : talk.title, "talkId" : talk.id})
     }
     onFavoritesChanged: {
       
       
       
       
       
       
       console.debug("onFavoritesChanged")
       
       
     }
     onNotificationsEnabledChanged: {
        console.debug("onNotificationsEnabledChanged, reschedule notifications")
       scheduleNotificationsForFavorites()
     }
   }
   
   Timer {
     id: notificationTimer
     interval: 8000 
     
     onTriggered: {
       console.debug("notificationTimer.triggered", running)
       scheduleNotificationsForFavorites()
     }
   }
   Connections {
     target: notificationManager
     
     onNotificationFired: {
       if(notificationId >= 0) {
         
         if(dataModel.loaded && dataModel.talks && dataModel.talks[notificationId]) {
           var talk = dataModel.talks[notificationId]
           var text = talk["title"]+" starts "+talk.start+" at "+talk["room"]+"."
           var title = "Session Reminder"
           NativeDialog.confirm(title, text, function(){}, false)
         }
       }
       else {
         
         NativeDialog.confirm("The conference starts soon!", "Thanks for using our app, we wish you a great Qt World Summit 2019!", function(){}, false)
       }
     }
   }
   
   function scheduleNotificationsForFavorites() {
     console.debug("attempting scheduleNotificationsForFavorites()")
     if(notificationTimer.running) {
       console.debug("notificationTimer at initialization is currently running, dont update yet")
       return
     }
     
     if(typeof notificationManager === "undefined")
       return
     console.debug("scheduling notifications now")
     
     notificationManager.cancelAllNotifications()
     if(!dataModel.notificationsEnabled || !dataModel.favorites || !dataModel.talks)
       return
     for(var idx in dataModel.favorites) {
       var talkId = dataModel.favorites[idx]
       scheduleNotificationForTalk(talkId)
     }
     
     var nowTime = new Date().getTime()
     var eveningBeforeConferenceTime = new Date("2019-11-03T21:00.000"+dataModel.timeZone).getTime()
     if(nowTime < eveningBeforeConferenceTime) {
       var text = "Felgo wishes all the best for Qt World Summit 2019 tomorrow!"
       var notification = {
         notificationId: -1,
         message: text,
         timestamp: Math.round(eveningBeforeConferenceTime / 1000) 
       }
       notificationManager.schedule(notification)
     }
   }
   
   function scheduleNotificationForTalk(talkId) {
     if(dataModel.loaded && dataModel.talks && dataModel.talks[talkId]) {
       var talk = dataModel.talks[talkId]
       var text = talk["title"]+" starts "+talk.start+" at "+talk["room"]+"."
       var nowTime = new Date().getTime()
       var utcDateStr = talk.day+"T"+talk.start+".000"+dataModel.timeZone
       var notificationTime = new Date(utcDateStr).getTime()
       notificationTime = notificationTime - 10 * 60 * 1000 
       if(nowTime < notificationTime) {
         var notification = {
           notificationId: talkId,
           message: text,
           timestamp: Math.round(notificationTime / 1000) 
         }
         notificationManager.schedule(notification)
       }
     }
   }
   function cancelNotificationForTalk(talkId) {
     notificationManager.cancelNotification(talkId)
   }
   
   Navigation {
     id: navigation
     property string previousPageTitle: ""
     property string previousPagePlatform: ""
     property var currentPage: {
       if(!currentNavigationItem)
         return null
       if(currentNavigationItem.navigationStack)
         return currentNavigationItem.navigationStack.currentPage
       else
         return currentNavigationItem.page
     }
     
     onCurrentPageChanged: {
       if(previousPagePlatform !== Theme.platform && previousPageTitle !== "") {
         previousPagePlatform = Theme.platform
         
         restorePageTimer.previousPageTitle = previousPageTitle
         restorePageTimer.restart()
       }
       else if(!!currentPage) {
         previousPagePlatform = Theme.platform
         previousPageTitle = currentPage.title
       }
     }
     
     onCurrentIndexChanged: {
       if(currentIndex > 0 && currentIndex < 3) {
         if(!dataModel.loaded && isOnline)
           logic.loadData()
       }
     }
     onCurrentNavigationItemChanged: {
       amplitude.logEvent("Open Page",{"title" : currentNavigationItem.title})
     }
     
     headerView: AppImage {
       id: drawerImage
       width: parent.width
       source: "../assets/QtWS2019_web banner1.png"
       fillMode: AppImage.PreserveAspectFit
       MouseArea {
         anchors.fill: parent
         onClicked: {
           navigation.currentIndex = 0
           navigation.drawer.close()
         }
       }
     }
     NavigationItem {
       title: "About"
       iconComponent: Component {
         Item {
           height: !!parent ? parent.height : 0
           width: height
           property bool selected: parent && parent.selected
           AppIcon {
             anchors.centerIn: parent
             width: height
             height: parent.height
             iconType: IconType.home
             color: !parent.selected ? Theme.textColor  : Theme.tintColor
             visible: !felgoIcon.visible
           }
           Image {
             id: felgoIcon
             height: parent.height
             anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined
             fillMode: Image.PreserveAspectFit
             source: !parent.selected ? (Theme.isAndroid ? "../assets/Qt_logo_Android_off.png" : "../assets/Qt_logo_iOS_off.png") : "../assets/Qt_logo.png"
             visible: true
           }
         }
       }
       NavigationStack {
         navigationBarShadow: false
         MainPage {}
       }
     } 
     NavigationItem {
       title: "Agenda"
       iconType: IconType.calendaro
       NavigationStack {
         splitView: tablet && landscape
         
         onTransitionFinished: {
           if(depth === 1)
             leftColumnIndex = 0
         }
         TimetablePage {
         }
       }
     } 
     NavigationItem {
       title: "Favorites"
       iconType: IconType.star
 
       tabContentComponent: favoritesComponent
     } 
     NavigationItem {
       title: "Speakers"
       iconType: IconType.microphone
 
       tabContentComponent: speakersComponent
     } 
     NavigationItem {
       title: "More"
       iconType: IconType.ellipsish
       showItem: !Theme.isAndroid
       tabContentComponent: moreComponent
       
     }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
     NavigationItem {
       title: "Tracks"
       iconType: IconType.tag
       showItem: Theme.isAndroid
       
       tabContentComponent: tracksComponent
     } 
     NavigationItem {
       title: "Venue"
       iconType: IconType.building
       showItem: Theme.isAndroid
       tabContentComponent: venueComponent
       
     } 
 
 
 
 
 
 
 
     NavigationItem {
       title: "Settings"
       iconType: IconType.gears
       showItem: Theme.isAndroid
       tabContentComponent: settingsComponent
       
     } 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   } 
   Component {
     id: favoritesComponent
     NavigationStack {
       splitView: tablet && landscape
       
       FavoritesPage {
       }
     }
   }
   Component {
     id: speakersComponent
     NavigationStack {
       splitView: landscape && tablet
       SpeakersPage {
       }
       
     }
   }
   Component {
     id: moreComponent
     NavigationStack {
       splitView: tablet && landscape
       Component.onCompleted: push(Qt.resolvedUrl("pages/MorePage.qml"))
     }
   }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   Component {
     id: tracksComponent
     NavigationStack {
       splitView: landscape && tablet
       
       TracksPage {
       }
     }
   }
   Component {
     id: venueComponent
     NavigationStack {
       
       VenuePage {
       }
     }
   }
 
 
 
 
 
 
 
   Component {
     id: settingsComponent
     NavigationStack {
       
       SettingsPage {
       }
     }
   }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   Timer {
     id: restorePageTimer
     interval: 5
     property string previousPageTitle: ""
     onTriggered: {
       var activeTitle = restorePageTimer.previousPageTitle
       
       if(Theme.isAndroid) {
 
 
         if(activeTitle === "Settings")
           navigation.currentIndex = 10
 
 
         else if(activeTitle === "Venue")
           navigation.currentIndex = 9
         else if(activeTitle === "Tracks")
           navigation.currentIndex = 8
         else if(activeTitle === "Highscores")
           navigation.currentIndex = 7
         else if(activeTitle === "Inbox")
           navigation.currentIndex = 6
         else if(activeTitle === "User Profile")
           navigation.currentIndex = 5
         else if(activeTitle === "Business Meet")
           navigation.currentIndex = 4
       }
       else {
         
         var target = ""
         if(activeTitle === "Highscores")
           target = socialView.leaderboardPage
         else if(activeTitle === "Inbox")
           target = socialView.inboxPage
         else if(activeTitle === "User Profile")
           target = socialView.profilePage
         else if(activeTitle === "Business Meet")
           target = socialView.businessMeetPage
         else if(activeTitle === "About Felgo")
           target = Qt.resolvedUrl("pages/AboutFelgoPage.qml")
         else if(activeTitle === "Settings")
           target = Qt.resolvedUrl("pages/SettingsPage.qml")
         else if(activeTitle === "Contacts")
           target = Qt.resolvedUrl("pages/ContactsPage.qml")
         else if(activeTitle === "Venue")
           target = Qt.resolvedUrl("pages/VenuePage.qml")
         else if(activeTitle === "Tracks")
           target = Qt.resolvedUrl("pages/TracksPage.qml")
         if (target != "") {
           navigation.currentIndex = navigation.countVisible - 1 
           navigation.currentPage.navigationStack.push(target)
         }
       }
     }
   }
   
   function openInbox() {
     if(Theme.isAndroid)
       navigation.currentIndex = 6 
     else {
       navigation.currentIndex = navigation.count - 1 
       if(!navigation.currentPage || navigation.currentPage.title === "Inbox")
         return
       navigation.currentPage.navigationStack.push(socialView.inboxPage) 
     }
   }
   
   function checkFeedbackDialog() {
     if(!dataModel.feedBackSent) {
       
       likeDialog.open()
     }
   }
   Component {
     id: searchPageComponent
     SearchPage {
     }
   }
   Component {
     id: detailPageComponent
     DetailPage {
     }
   }
   Component {
     id: speakerDetailPageComponent
     SpeakerDetailPage {
     }
   }
   Component {
     id: trackDetailPageComponent
     TrackDetailPage {
     }
   }
   FeedbackDialog {
     id: feedbackDialog
   }
   RatingDialog {
     id: ratingDialog
   }
   LikeDialog {
     id: likeDialog
     onCanceled: {
       
       likeDialog.close()
       feedbackDialog.open()
       amplitude.logEvent("Dislike App")
     }
     onAccepted: {
       
       likeDialog.close()
       
       ratingDialog.open()
       amplitude.logEvent("Like App")