2022-03-07 22:59:38 +00:00
import QtQuick 2.13
import QtQuick . Layouts 1.12
2022-05-23 11:29:58 +00:00
import QtQuick . Controls 2.14
import QtQuick . Dialogs 1.3
2022-03-07 22:59:38 +00:00
import StatusQ . Components 0.1
import StatusQ . Controls 0.1
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
2022-05-23 11:29:58 +00:00
import StatusQ . Popups 0.1
2022-03-07 22:59:38 +00:00
import shared . panels 1.0
2022-05-23 11:29:58 +00:00
import shared 1.0
import shared . popups 1.0
2022-03-07 22:59:38 +00:00
import shared . controls 1.0
2022-07-14 11:03:36 +00:00
import utils 1.0
2022-03-07 22:59:38 +00:00
import "../popups"
import "../stores"
2022-05-23 11:29:58 +00:00
import "../shared"
2022-03-07 22:59:38 +00:00
Item {
id: root
property string pubKey
property string address
property string displayName
signal createPassword ( )
state: "username"
2022-03-29 19:15:42 +00:00
Component.onCompleted: {
2022-03-15 22:27:36 +00:00
if ( ! ! OnboardingStore . onboardingModuleInst . importedAccountPubKey ) {
root . address = OnboardingStore . onboardingModuleInst . importedAccountAddress ;
2022-03-29 19:15:42 +00:00
root . pubKey = OnboardingStore . onboardingModuleInst . importedAccountPubKey ;
}
2022-05-10 15:42:35 +00:00
nameInput . input . edit . forceActiveFocus ( ) ;
2022-03-29 19:15:42 +00:00
}
Loader {
2022-03-15 22:27:36 +00:00
active: ! OnboardingStore . onboardingModuleInst . importedAccountPubKey
2022-07-14 11:03:36 +00:00
sourceComponent: StatusListView {
2022-03-29 19:15:42 +00:00
model: OnboardingStore . onboardingModuleInst . accountsModel
delegate: Item {
Component.onCompleted: {
if ( index === 0 ) {
root . address = model . address ;
2022-03-15 22:27:36 +00:00
root . pubKey = model . pubKey ;
2022-03-29 19:15:42 +00:00
}
}
2022-03-07 22:59:38 +00:00
}
}
}
ColumnLayout {
2022-05-25 15:24:01 +00:00
height: 461
2022-06-20 09:50:57 +00:00
anchors.centerIn: parent
2022-03-07 22:59:38 +00:00
StyledText {
id: usernameText
text: qsTr ( "Your profile" )
font.weight: Font . Bold
font.pixelSize: 22
Layout.alignment: Qt . AlignHCenter
}
StyledText {
id: txtDesc
Layout.preferredWidth: ( root . state === "username" ) ? 338 : 643
2022-06-01 15:52:23 +00:00
Layout.preferredHeight: 44
Layout.alignment: Qt . AlignTop | Qt . AlignHCenter
Layout.topMargin: Style . current . padding
2022-03-07 22:59:38 +00:00
color: Style . current . secondaryText
text: qsTr ( "Longer and unusual names are better as they are less likely to be used by someone else." )
horizontalAlignment: Text . AlignHCenter
wrapMode: Text . WordWrap
font.pixelSize: 15
}
Item {
2022-06-01 15:52:23 +00:00
implicitWidth: 80
implicitHeight: 80
Layout.alignment: Qt . AlignTop | Qt . AlignHCenter
Layout.topMargin: 27
2022-03-07 22:59:38 +00:00
StatusSmartIdenticon {
2022-06-01 15:52:23 +00:00
anchors.left: parent . left
2022-03-07 22:59:38 +00:00
id: userImage
2022-04-06 11:12:11 +00:00
image {
2022-05-25 15:24:01 +00:00
width: 86
height: 86
2022-04-06 11:12:11 +00:00
isIdenticon: false
}
icon {
2022-05-25 15:24:01 +00:00
width: 86
height: 86
2022-04-06 11:12:11 +00:00
letterSize: 32
color: Theme . palette . miscColor5
charactersLen: 2
}
ringSettings {
ringSpecModel: Utils . getColorHashAsJson ( root . pubKey )
}
2022-03-07 22:59:38 +00:00
}
StatusRoundButton {
id: updatePicButton
width: 40
height: 40
anchors.top: parent . top
anchors.right: parent . right
2022-06-01 15:52:23 +00:00
anchors.rightMargin: - 20
2022-03-07 22:59:38 +00:00
type: StatusFlatRoundButton . Type . Secondary
icon.name: "add"
onClicked: {
2022-06-01 15:52:23 +00:00
cropperModal . chooseImageToCrop ( ) ;
2022-03-07 22:59:38 +00:00
}
}
}
2022-06-01 15:52:23 +00:00
Item {
id: nameInputItem
2022-03-07 22:59:38 +00:00
implicitWidth: 328
2022-06-01 15:52:23 +00:00
Layout.preferredHeight: 69
Layout.alignment: Qt . AlignHCenter | Qt . AlignTop
Layout.topMargin: 37
StatusInput {
id: nameInput
width: parent . width
input.placeholderText: qsTr ( "Display name" )
input.rightComponent: RoundedIcon {
width: 14
height: 14
iconWidth: 14
iconHeight: 14
visible: ( nameInput . input . text . length > 0 )
color: "transparent"
source: Style . svg ( "close-filled" )
onClicked: {
nameInput . input . edit . clear ( ) ;
}
2022-03-07 22:59:38 +00:00
}
2022-06-01 15:52:23 +00:00
errorMessageCmp.wrapMode: Text . NoWrap
errorMessageCmp.horizontalAlignment: Text . AlignHCenter
validators: Constants . validators . displayName
onTextChanged: {
userImage . name = text ;
}
input.acceptReturn: true
onKeyPressed: {
if ( input . edit . keyEvent === Qt . Key_Return || input . edit . keyEvent === Qt . Key_Enter ) {
event . accepted = true
2022-06-20 08:04:48 +00:00
if ( nextBtn . enabled ) {
nextBtn . clicked ( null )
}
2022-06-01 15:52:23 +00:00
}
2022-05-10 15:42:35 +00:00
}
}
2022-03-07 22:59:38 +00:00
}
StyledText {
id: chatKeyTxt
2022-05-25 15:24:01 +00:00
Layout.preferredHeight: 44
2022-03-07 22:59:38 +00:00
color: Style . current . secondaryText
2022-03-30 07:09:39 +00:00
text: qsTr ( "Chatkey:" ) + " " + Utils . getCompressedPk ( root . pubKey )
2022-03-07 22:59:38 +00:00
horizontalAlignment: Text . AlignHCenter
wrapMode: Text . WordWrap
2022-06-01 15:52:23 +00:00
Layout.alignment: Qt . AlignHCenter | Qt . AlignTop
Layout.topMargin: 13
2022-03-07 22:59:38 +00:00
font.pixelSize: 15
}
Item {
id: chainsChatKeyImg
Layout.alignment: Qt . AlignHCenter
2022-06-01 15:52:23 +00:00
Layout.topMargin: Style . current . padding
Layout.preferredWidth: 215
Layout.preferredHeight: 77
2022-03-07 22:59:38 +00:00
Image {
2022-06-01 15:52:23 +00:00
id: imgChains
2022-03-07 22:59:38 +00:00
anchors.horizontalCenter: parent . horizontalCenter
2022-06-01 15:52:23 +00:00
source: Style . svg ( "onboarding/chains" )
2022-03-07 22:59:38 +00:00
}
EmojiHash {
2022-04-14 08:26:46 +00:00
anchors {
bottom: parent . bottom
left: parent . left
}
2022-03-07 22:59:38 +00:00
publicKey: root . pubKey
}
StatusSmartIdenticon {
id: userImageCopy
2022-04-14 08:26:46 +00:00
anchors {
bottom: parent . bottom
right: parent . right
2022-06-01 15:52:23 +00:00
rightMargin: 25
2022-04-14 08:26:46 +00:00
}
2022-03-07 22:59:38 +00:00
icon.width: 44
icon.height: 44
icon.color: "transparent"
ringSettings { ringSpecModel: Utils . getColorHashAsJson ( root . pubKey ) }
}
}
2022-06-01 15:52:23 +00:00
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
2022-03-07 22:59:38 +00:00
StatusButton {
2022-05-10 15:42:35 +00:00
id: nextBtn
2022-06-01 15:52:23 +00:00
Layout.alignment: Qt . AlignHCenter | Qt . AlignBottom
2022-04-01 08:06:39 +00:00
enabled: ! ! nameInput . text && nameInput . valid
2022-03-07 22:59:38 +00:00
text: qsTr ( "Next" )
onClicked: {
if ( root . state === "username" ) {
if ( OnboardingStore . accountCreated ) {
OnboardingStore . updatedDisplayName ( nameInput . text ) ;
}
2022-06-01 15:52:23 +00:00
OnboardingStore . displayName = nameInput . text ;
2022-03-07 22:59:38 +00:00
root . displayName = nameInput . text ;
root . state = "chatkey" ;
} else {
createPassword ( ) ;
}
}
}
2022-06-01 14:00:57 +00:00
ImageCropWorkflow {
2022-05-23 11:29:58 +00:00
id: cropperModal
2022-05-31 09:07:45 +00:00
imageFileDialogTitle: qsTr ( "Choose an image for profile picture" )
title: qsTr ( "Profile picture" )
acceptButtonText: qsTr ( "Make this my profile picture" )
2022-05-23 11:29:58 +00:00
onImageCropped: {
const croppedImg = OnboardingStore . generateImage ( image ,
2022-06-01 15:52:23 +00:00
cropRect . x . toFixed ( ) ,
cropRect . y . toFixed ( ) ,
( cropRect . x + cropRect . width ) . toFixed ( ) ,
( cropRect . y + cropRect . height ) . toFixed ( ) ) ;
userImage . image . source = croppedImg ;
2022-04-04 12:45:27 +00:00
}
2022-03-07 22:59:38 +00:00
}
}
states: [
State {
name: "username"
PropertyChanges {
target: usernameText
text: qsTr ( "Your profile" )
}
PropertyChanges {
target: txtDesc
text: qsTr ( "Longer and unusual names are better as they are less likely to be used by someone else." )
}
PropertyChanges {
target: chatKeyTxt
visible: false
}
PropertyChanges {
target: chainsChatKeyImg
2022-05-25 15:24:01 +00:00
opacity: 0.0
2022-03-07 22:59:38 +00:00
}
PropertyChanges {
target: userImageCopy
2022-05-25 15:24:01 +00:00
opacity: 0.0
2022-03-07 22:59:38 +00:00
}
PropertyChanges {
target: updatePicButton
2022-05-25 15:24:01 +00:00
opacity: 1.0
2022-03-07 22:59:38 +00:00
}
PropertyChanges {
2022-06-01 15:52:23 +00:00
target: nameInputItem
2022-03-07 22:59:38 +00:00
visible: true
}
} ,
State {
name: "chatkey"
PropertyChanges {
target: usernameText
text: qsTr ( "Your emojihash and identicon ring" )
}
PropertyChanges {
target: txtDesc
text: qsTr ( "This set of emojis and coloured ring around your avatar are unique and represent your chat key, so your friends can easily distinguish you from potential impersonators." )
}
PropertyChanges {
target: chatKeyTxt
visible: true
}
PropertyChanges {
target: chainsChatKeyImg
2022-05-25 15:24:01 +00:00
opacity: 1.0
2022-03-07 22:59:38 +00:00
}
PropertyChanges {
target: userImageCopy
2022-05-25 15:24:01 +00:00
opacity: 1.0
2022-03-07 22:59:38 +00:00
}
PropertyChanges {
target: updatePicButton
2022-05-25 15:24:01 +00:00
opacity: 0.0
2022-03-07 22:59:38 +00:00
}
PropertyChanges {
2022-06-01 15:52:23 +00:00
target: nameInputItem
2022-03-07 22:59:38 +00:00
visible: false
}
}
]
transitions: [
Transition {
from: "*"
to: "*"
SequentialAnimation {
PropertyAction {
target: root
property: "opacity"
value: 0.0
}
PropertyAction {
target: root
property: "opacity"
value: 1.0
}
}
}
]
}