some more tinkering with qml

This commit is contained in:
Blue 2023-12-17 17:10:27 -03:00
parent ed1ed9fb49
commit 89aa830bfa
Signed by: blue
GPG Key ID: 9B203B252A63EE38
4 changed files with 44 additions and 38 deletions

View File

@ -6,7 +6,7 @@ import magpie.API
Column { Column {
signal register() signal register()
spacing: 10 spacing: 5
Label { Label {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter

View File

@ -6,7 +6,7 @@ import magpie.API
Column { Column {
signal login() signal login()
spacing: 10 spacing: 5
Label { Label {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter

View File

@ -6,13 +6,15 @@ import magpie.API
import "Forms" as Forms import "Forms" as Forms
Page { Page {
id: page
signal pickServer(address: string) signal pickServer(address: string)
title: qsTr("Welcome") title: qsTr("Welcome")
Column { Column {
id: column
anchors.centerIn: parent anchors.centerIn: parent
spacing: 10 spacing: 5
Label { Label {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -46,24 +48,31 @@ Page {
} }
} }
Row { Item {
id: forms
property bool registering: false
visible: API.state === API.NotAuthenticated visible: API.state === API.NotAuthenticated
anchors.horizontalCenter: parent.horizontalCenter
topPadding: 10
Forms.Login { width: page.width
id: login height: stack.currentItem ? stack.currentItem.implicitHeight: 0
visible: !forms.registering
onRegister: forms.registering = true
}
Forms.Register { StackView {
id: register id: stack
visible: forms.registering initialItem: loginForm
onLogin: forms.registering = false anchors.fill: parent
anchors.topMargin: 20
Component {
id: loginForm
Forms.Login {
onRegister: stack.replace(registerForm)
}
}
Component {
id: registerForm
Forms.Register {
onLogin: stack.replace(loginForm, StackView.PopTransition)
}
}
} }
} }
} }

View File

@ -10,7 +10,6 @@ ApplicationWindow {
property int counter: 0 property int counter: 0
property bool pickingServer: false property bool pickingServer: false
id: window
width: 640 width: 640
height: 480 height: 480
visible: true visible: true
@ -25,7 +24,23 @@ ApplicationWindow {
id: stack id: stack
initialItem: welcome initialItem: welcome
anchors.fill: parent anchors.fill: parent
StackView.onRemoved: pickingServer = false
Component {
id: welcome
Welcome {
onPickServer: stack.push(serverPick)
}
}
Component {
id: serverPick
ServerPick {
address: API.address
onBack: stack.pop()
StackView.onActivating: pickingServer = true;
StackView.onDeactivating: pickingServer = false;
}
}
} }
Connections { Connections {
@ -35,22 +50,4 @@ ApplicationWindow {
stack.pop() stack.pop()
} }
} }
Welcome {
id: welcome
onPickServer: function (address) {
const pick = pickComponent.createObject(stack);
pick.address = address;
stack.push(pick);
pickingServer = true;
}
}
Component {
id: pickComponent
ServerPick {
StackView.onRemoved: destroy()
onBack: stack.pop()
}
}
} }