diff --git a/storybook/Storybook/Logs.qml b/storybook/Storybook/Logs.qml index 953b6b3aa3..0a01f73e7e 100644 --- a/storybook/Storybook/Logs.qml +++ b/storybook/Storybook/Logs.qml @@ -15,13 +15,19 @@ QtObject { function createLog(name, argumentNames, args) { let log = (new Date()).toLocaleTimeString(Qt.locale(), "h:mm:ss") + ": " + name - if (args.length === 0) + if (!args || args.length === 0) return log log += ": [" for (let i = 0; i < args.length; i++) { - log += argumentNames[i] + ": " + JSON.stringify(args[i]) + + const argName = argumentNames[i] + + if (!!argName) + log +=argName + ": " + + log += JSON.stringify(args[i]) if (i !== args.length - 1) log += ", " diff --git a/storybook/main.qml b/storybook/main.qml index ce3041e522..2c900b6b4a 100644 --- a/storybook/main.qml +++ b/storybook/main.qml @@ -47,6 +47,12 @@ ApplicationWindow { selected: viewLoader.source.toString().includes(title) onClicked: mainPageView.page(title); } + + StatusNavigationListItem { + title: "LoginView" + selected: viewLoader.source.toString().includes(title) + onClicked: mainPageView.page(title); + } } } diff --git a/storybook/pages/CommunitiesPortalLayoutPage.qml b/storybook/pages/CommunitiesPortalLayoutPage.qml index 43701c6bc8..b2548171af 100644 --- a/storybook/pages/CommunitiesPortalLayoutPage.qml +++ b/storybook/pages/CommunitiesPortalLayoutPage.qml @@ -20,48 +20,43 @@ SplitView { orientation: Qt.Vertical SplitView.fillWidth: true - ColumnLayout { + CommunitiesPortalLayout { SplitView.fillWidth: true SplitView.fillHeight: true - CommunitiesPortalLayout { - Layout.fillWidth: true - Layout.fillHeight: true + communitiesStore: CommunitiesStore { + readonly property string locale: "" + readonly property int unreadNotificationsCount: 42 + readonly property string communityTags: + JSON.stringify({"Activism":"✊","Art":"🎨","Blockchain":"🔗","Books & blogs":"📚","Career":"💼"}) + readonly property var curatedCommunitiesModel: SortFilterProxyModel { - communitiesStore: CommunitiesStore { - readonly property string locale: "" - readonly property int unreadNotificationsCount: 42 - readonly property string communityTags: - JSON.stringify({"Activism":"✊","Art":"🎨","Blockchain":"🔗","Books & blogs":"📚","Career":"💼"}) - readonly property var curatedCommunitiesModel: SortFilterProxyModel { + sourceModel: CommunitiesPortalDummyModel { id: mockedModel } - sourceModel: CommunitiesPortalDummyModel { id: mockedModel } - - filters: IndexFilter { - inverted: true - minimumIndex: Math.floor(slider.value) - } - } - - function setActiveCommunity() { - logs.logEvent("CommunitiesStore::setActiveCommunity", ["communityId"], arguments) + filters: IndexFilter { + inverted: true + minimumIndex: Math.floor(slider.value) } } - // TODO: onCompleted handler and localAccountSensitiveSettings are here to allow opening - // "Import Community" and "Create New Community" popups. However those popups shouldn't - // be tightly coupled with `CommunitiesPortalLayout` so it should be refactored in the next step. - // Pressing buttons "Import using key" and "Create new community" should only request for opening - // dialogs, and in Storybook it should be logged in the same way as calls to stores. - // Mentioned popups should have their own pages in the Storybook. - Component.onCompleted: { - Global.appMain = this + function setActiveCommunity() { + logs.logEvent("CommunitiesStore::setActiveCommunity", ["communityId"], arguments) } + } - QtObject { - id: localAccountSensitiveSettings - readonly property bool isDiscordImportToolEnabled: false - } + // TODO: onCompleted handler and localAccountSensitiveSettings are here to allow opening + // "Import Community" and "Create New Community" popups. However those popups shouldn't + // be tightly coupled with `CommunitiesPortalLayout` so it should be refactored in the next step. + // Pressing buttons "Import using key" and "Create new community" should only request for opening + // dialogs, and in Storybook it should be logged in the same way as calls to stores. + // Mentioned popups should have their own pages in the Storybook. + Component.onCompleted: { + Global.appMain = this + } + + QtObject { + id: localAccountSensitiveSettings + readonly property bool isDiscordImportToolEnabled: false } } diff --git a/storybook/pages/LoginViewPage.qml b/storybook/pages/LoginViewPage.qml new file mode 100644 index 0000000000..b4627d1958 --- /dev/null +++ b/storybook/pages/LoginViewPage.qml @@ -0,0 +1,107 @@ +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.14 + +import AppLayouts.Onboarding.views 1.0 +import AppLayouts.Onboarding.stores 1.0 + +import SortFilterProxyModel 0.2 + +import Storybook 1.0 + +import utils 1.0 + +SplitView { + Logs { id: logs } + + SplitView { + orientation: Qt.Vertical + SplitView.fillWidth: true + + LoginView { + SplitView.fillWidth: true + SplitView.fillHeight: true + + startupStore: StartupStore { + readonly property QtObject startupModuleInst: QtObject { + signal accountLoginError + signal obtainingPasswordSuccess + signal obtainingPasswordError + + readonly property ListModel loginAccountsModel: ListModel { + ListElement { + keycardCreatedAccount: false + colorId: 1 + colorHash: "0xAB34" + username: "Bob" + thumbnailImage: "" + keyUid: "uid_1" + } + ListElement { + keycardCreatedAccount: false + colorId: 2 + colorHash: "0xAB34" + username: "John" + thumbnailImage: "" + keyUid: "uid_2" + } + } + } + + readonly property QtObject selectedLoginAccount: QtObject { + readonly property bool keycardCreatedAccount: false + readonly property int colorId: 0 + readonly property string username: "Alice" + readonly property string thumbnailImage: "" + readonly property string keyUid: "uid_3" + } + + readonly property QtObject currentStartupState: QtObject { + readonly property string stateType: Constants.startupState.welcome + } + + function setPassword() { + logs.logEvent("StartupStore::setPassword", ["password"], arguments) + } + + function doPrimaryAction() { + logs.logEvent("StartupStore::doPrimaryAction") + } + + function doSecondaryAction() { + logs.logEvent("StartupStore::doSecondaryAction") + } + + function doTertiaryAction() { + logs.logEvent("StartupStore::doTertiaryAction") + } + + function setSelectedLoginAccountByIndex() { + logs.logEvent("StartupStore::setSelectedLoginAccountByIndex", ["index"], arguments) + } + } + + QtObject { + id: localAccountSettings + } + } + + LogsAndControlsPanel { + id: logsAndControlsPanel + + SplitView.minimumHeight: 100 + SplitView.preferredHeight: 200 + + logsView.logText: logs.logText + } + } + + Control { + SplitView.minimumWidth: 300 + SplitView.preferredWidth: 300 + + font.pixelSize: 13 + + // model editor will go here + } +} diff --git a/storybook/qml.qrc b/storybook/qml.qrc index 8767f64dff..13c506527d 100644 --- a/storybook/qml.qrc +++ b/storybook/qml.qrc @@ -1,14 +1,15 @@ - main.qml - pages/CommunitiesPortalLayoutPage.qml - pages/CommunitiesPortalDummyModel.qml - pages/CommunitiesPortalModelEditor.qml - Storybook/LogsView.qml - Storybook/qmldir - Storybook/LogsAndControlsPanel.qml Storybook/ImageSelectPopup.qml - Storybook/StorybookUtils.qml Storybook/Logs.qml + Storybook/LogsAndControlsPanel.qml + Storybook/LogsView.qml + Storybook/StorybookUtils.qml + Storybook/qmldir + main.qml + pages/CommunitiesPortalDummyModel.qml + pages/CommunitiesPortalLayoutPage.qml + pages/CommunitiesPortalModelEditor.qml + pages/LoginViewPage.qml diff --git a/storybook/stubs/AppLayouts/CommunitiesPortal/stores/CommunitiesStore.qml b/storybook/stubs/AppLayouts/CommunitiesPortal/stores/CommunitiesStore.qml index 23496483cb..e847d327b2 100644 --- a/storybook/stubs/AppLayouts/CommunitiesPortal/stores/CommunitiesStore.qml +++ b/storybook/stubs/AppLayouts/CommunitiesPortal/stores/CommunitiesStore.qml @@ -1,3 +1,3 @@ -import QtQuick 2.13 +import QtQuick 2.14 QtObject {} diff --git a/storybook/stubs/AppLayouts/Onboarding/stores/StartupStore.qml b/storybook/stubs/AppLayouts/Onboarding/stores/StartupStore.qml new file mode 100644 index 0000000000..e847d327b2 --- /dev/null +++ b/storybook/stubs/AppLayouts/Onboarding/stores/StartupStore.qml @@ -0,0 +1,3 @@ +import QtQuick 2.14 + +QtObject {} diff --git a/storybook/stubs/AppLayouts/Onboarding/stores/qmldir b/storybook/stubs/AppLayouts/Onboarding/stores/qmldir new file mode 100644 index 0000000000..d6535da60c --- /dev/null +++ b/storybook/stubs/AppLayouts/Onboarding/stores/qmldir @@ -0,0 +1 @@ +StartupStore 1.0 StartupStore.qml diff --git a/ui/app/AppLayouts/Onboarding/stores/qmldir b/ui/app/AppLayouts/Onboarding/stores/qmldir new file mode 100644 index 0000000000..d6535da60c --- /dev/null +++ b/ui/app/AppLayouts/Onboarding/stores/qmldir @@ -0,0 +1 @@ +StartupStore 1.0 StartupStore.qml diff --git a/ui/app/AppLayouts/Onboarding/views/LoginView.qml b/ui/app/AppLayouts/Onboarding/views/LoginView.qml index ed668ac183..9becbd3b81 100644 --- a/ui/app/AppLayouts/Onboarding/views/LoginView.qml +++ b/ui/app/AppLayouts/Onboarding/views/LoginView.qml @@ -20,8 +20,8 @@ import shared.controls 1.0 import shared.controls.chat 1.0 import "../panels" import "../popups" -import "../stores" +import AppLayouts.Onboarding.stores 1.0 import utils 1.0 diff --git a/ui/app/AppLayouts/Onboarding/views/qmldir b/ui/app/AppLayouts/Onboarding/views/qmldir new file mode 100644 index 0000000000..a4726027c3 --- /dev/null +++ b/ui/app/AppLayouts/Onboarding/views/qmldir @@ -0,0 +1 @@ +LoginView 1.0 LoginView.qml