MVC Architecture Demo App
import Felgo 4.0
import QtQuick 2.0
import "model"
import "logic"
import "pages"
App {
Component.onCompleted: {
if(isOnline) {
logic.clearCache()
}
logic.fetchTodos()
logic.fetchDraftTodos()
}
Logic {
id: logic
}
DataModel {
id: dataModel
dispatcher: logic
onFetchTodosFailed: error => nativeUtils.displayMessageBox("Unable to load todos", error, 1)
onFetchTodoDetailsFailed: (id, error) => nativeUtils.displayMessageBox("Unable to load todo " + id, error, 1)
onStoreTodoFailed: (todo, error) => nativeUtils.displayMessageBox("Failed to store " + viewHelper.formatTitle(todo))
}
ViewHelper {
id: viewHelper
}
Navigation {
id: navigation
enabled: dataModel.userLoggedIn
NavigationItem {
title: qsTr("Todo List")
iconType: IconType.list
NavigationStack {
splitView: tablet
initialPage: TodoListPage { }
}
}
NavigationItem {
title: qsTr("Profile")
iconType: IconType.circle
NavigationStack {
initialPage: ProfilePage {
onLogoutClicked: {
logic.logout()
navigation.currentIndex = 0
navigation.currentNavigationItem.navigationStack.popAllExceptFirst()
}
}
}
}
}
LoginPage {
visible: opacity > 0
enabled: visible
opacity: dataModel.userLoggedIn ? 0 : 1
Behavior on opacity { NumberAnimation { duration: 250 } }