2019-07-08 13:52:41 +10:00
|
|
|
// Copyright 2019 miruka
|
|
|
|
// This file is part of harmonyqml, licensed under LGPLv3.
|
|
|
|
|
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: [
|
|
|
|
{ name: "register", text: qsTr("Register") },
|
|
|
|
{ name: "login", text: qsTr("Login") },
|
|
|
|
{ name: "forgot", text: qsTr("Forgot?") }
|
|
|
|
]
|
|
|
|
|
|
|
|
buttonCallbacks: {
|
2019-07-18 17:13:34 +10:00
|
|
|
"register": button => {},
|
2019-04-28 08:54:33 +10:00
|
|
|
|
2019-07-18 17:13:34 +10:00
|
|
|
"login": button => {
|
2019-07-03 03:59:52 +10:00
|
|
|
button.loading = true
|
|
|
|
var args = [idField.text, passwordField.text]
|
|
|
|
|
2019-07-18 17:13:34 +10:00
|
|
|
py.callCoro("login_client", args, user_id => {
|
2019-04-28 11:07:20 +10:00
|
|
|
pageStack.showPage(
|
|
|
|
"RememberAccount",
|
2019-07-03 03:59:52 +10:00
|
|
|
{"loginWith": loginWith, "userId": user_id}
|
2019-04-28 11:07:20 +10:00
|
|
|
)
|
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 17:13:34 +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
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|