feat(Storybook): LoginView - initial setup

Closes: #7865
This commit is contained in:
Michał Cieślak 2022-10-12 11:42:51 +02:00 committed by Iuri Matias
parent 4cfa4e5451
commit d5a4ab5967
11 changed files with 165 additions and 44 deletions

View File

@ -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 += ", "

View File

@ -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);
}
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -1,14 +1,15 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>pages/CommunitiesPortalLayoutPage.qml</file>
<file>pages/CommunitiesPortalDummyModel.qml</file>
<file>pages/CommunitiesPortalModelEditor.qml</file>
<file>Storybook/LogsView.qml</file>
<file>Storybook/qmldir</file>
<file>Storybook/LogsAndControlsPanel.qml</file>
<file>Storybook/ImageSelectPopup.qml</file>
<file>Storybook/StorybookUtils.qml</file>
<file>Storybook/Logs.qml</file>
<file>Storybook/LogsAndControlsPanel.qml</file>
<file>Storybook/LogsView.qml</file>
<file>Storybook/StorybookUtils.qml</file>
<file>Storybook/qmldir</file>
<file>main.qml</file>
<file>pages/CommunitiesPortalDummyModel.qml</file>
<file>pages/CommunitiesPortalLayoutPage.qml</file>
<file>pages/CommunitiesPortalModelEditor.qml</file>
<file>pages/LoginViewPage.qml</file>
</qresource>
</RCC>

View File

@ -1,3 +1,3 @@
import QtQuick 2.13
import QtQuick 2.14
QtObject {}

View File

@ -0,0 +1,3 @@
import QtQuick 2.14
QtObject {}

View File

@ -0,0 +1 @@
StartupStore 1.0 StartupStore.qml

View File

@ -0,0 +1 @@
StartupStore 1.0 StartupStore.qml

View File

@ -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

View File

@ -0,0 +1 @@
LoginView 1.0 LoginView.qml