moment/src/qml/Pages/SignIn.qml

84 lines
2.2 KiB
QML
Raw Normal View History

2019-07-08 13:52:41 +10:00
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
Item {
property string loginWith: "username"
onFocusChanged: idField.forceActiveFocus()
HInterfaceBox {
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: ({
register: button => {},
login: button => {
button.loading = true
2019-07-18 19:18:13 +10:00
let args = [idField.text, passwordField.text]
py.callCoro("login_client", args, userId => {
pageStack.showPage("RememberAccount", {loginWith, userId})
button.loading = false
2019-04-28 11:07:20 +10:00
})
},
forgot: button => {}
})
HRowLayout {
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 {
iconName: modelData
circle: true
checked: loginWith == modelData
autoExclusive: true
checkedLightens: true
onClicked: loginWith = modelData
}
}
}
HTextField {
id: idField
placeholderText: qsTr(
loginWith === "email" ? "Email" :
loginWith === "phone" ? "Phone" :
"Username"
)
onAccepted: signInBox.clickEnterButtonTarget()
Layout.fillWidth: true
Layout.margins: signInBox.margins
}
HTextField {
id: passwordField
placeholderText: qsTr("Password")
2019-04-29 05:36:43 +10:00
echoMode: HTextField.Password
onAccepted: signInBox.clickEnterButtonTarget()
Layout.fillWidth: true
Layout.margins: signInBox.margins
}
}
}