2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../Base"
|
2019-04-28 08:54:33 +10:00
|
|
|
|
|
|
|
Item {
|
|
|
|
property string loginWith: "username"
|
2019-07-03 03:59:52 +10:00
|
|
|
onFocusChanged: idField.forceActiveFocus()
|
2019-04-28 08:54:33 +10:00
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HInterfaceBox {
|
2019-04-28 08:54:33 +10:00
|
|
|
id: signInBox
|
|
|
|
title: "Sign in"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
enterButtonTarget: "login"
|
|
|
|
|
|
|
|
buttonModel: [
|
2019-07-19 10:39:13 +10:00
|
|
|
{ name: "register", text: qsTr("Register"), enabled: false },
|
|
|
|
{ name: "login", text: qsTr("Login"), enabled: true },
|
|
|
|
{ name: "forgot", text: qsTr("Forgot?"), enabled: false }
|
2019-04-28 08:54:33 +10:00
|
|
|
]
|
|
|
|
|
2019-07-18 18:17:35 +10:00
|
|
|
buttonCallbacks: ({
|
|
|
|
register: button => {},
|
2019-04-28 08:54:33 +10:00
|
|
|
|
2019-07-18 18:17:35 +10:00
|
|
|
login: button => {
|
2019-07-03 03:59:52 +10:00
|
|
|
button.loading = true
|
2019-07-18 19:18:13 +10:00
|
|
|
let args = [idField.text, passwordField.text]
|
2019-07-03 03:59:52 +10:00
|
|
|
|
2019-07-18 18:46:37 +10:00
|
|
|
py.callCoro("login_client", args, userId => {
|
|
|
|
pageStack.showPage("RememberAccount", {loginWith, userId})
|
2019-07-03 03:59:52 +10:00
|
|
|
button.loading = false
|
2019-04-28 11:07:20 +10:00
|
|
|
})
|
2019-04-28 08:54:33 +10:00
|
|
|
},
|
|
|
|
|
2019-07-18 18:17:35 +10:00
|
|
|
forgot: button => {}
|
|
|
|
})
|
2019-04-28 08:54:33 +10:00
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HRowLayout {
|
2019-04-28 08:54:33 +10:00
|
|
|
spacing: signInBox.margins * 1.25
|
|
|
|
Layout.margins: signInBox.margins
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: ["username", "email", "phone"]
|
|
|
|
|
2019-07-11 05:03:05 +10:00
|
|
|
HUIButton {
|
2019-04-28 08:54:33 +10:00
|
|
|
iconName: modelData
|
|
|
|
circle: true
|
|
|
|
checked: loginWith == modelData
|
2019-07-25 08:41:40 +10:00
|
|
|
enabled: modelData == "username"
|
2019-04-28 08:54:33 +10:00
|
|
|
autoExclusive: true
|
2019-05-14 00:52:26 +10:00
|
|
|
checkedLightens: true
|
2019-04-28 08:54:33 +10:00
|
|
|
onClicked: loginWith = modelData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HTextField {
|
2019-07-03 03:59:52 +10:00
|
|
|
id: idField
|
2019-04-28 08:54:33 +10:00
|
|
|
placeholderText: qsTr(
|
|
|
|
loginWith === "email" ? "Email" :
|
|
|
|
loginWith === "phone" ? "Phone" :
|
|
|
|
"Username"
|
|
|
|
)
|
|
|
|
onAccepted: signInBox.clickEnterButtonTarget()
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: signInBox.margins
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HTextField {
|
2019-04-28 08:54:33 +10:00
|
|
|
id: passwordField
|
|
|
|
placeholderText: qsTr("Password")
|
2019-04-29 05:36:43 +10:00
|
|
|
echoMode: HTextField.Password
|
2019-04-28 08:54:33 +10:00
|
|
|
onAccepted: signInBox.clickEnterButtonTarget()
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: signInBox.margins
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|