Skip to content

Commit

Permalink
Added title for Inputs. Updated Switch design. (#2921)
Browse files Browse the repository at this point in the history
  • Loading branch information
iiLubos authored Nov 28, 2023
1 parent b80b90e commit 09aa8f2
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 95 deletions.
65 changes: 36 additions & 29 deletions app/qmlV2/component/MMButtonInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import QtQuick.Controls
import QtQuick.Controls.Basic
import ".."

Item {
Column {
id: control

property alias title: titleItem.text
property alias text: textField.text
property alias placeholderText: textField.placeholderText
property url iconSource: ""
Expand All @@ -24,38 +25,16 @@ Item {

signal clicked

spacing: 6 * __dp
width: 280 * __dp
height: rect.height + messageItem.height

Item {
id: messageItem
Text {
id: titleItem

width: parent.width
anchors.left: parent.left
anchors.top: rect.bottom
anchors.topMargin: 6 * __dp
height: msgRow.height

Row {
id: msgRow

spacing: 4 * __dp

MMIcon {
id: msgIcon

source: visible ? StyleV2.errorIcon : ""
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor
visible: errorMsg.length > 0 || warningMsg.length > 0
}
Text {
text: errorMsg.length > 0 ? errorMsg : warningMsg
font: StyleV2.t4
wrapMode: Text.WordWrap
width: messageItem.width - msgRow.spacing - msgIcon.width
visible: errorMsg.length > 0 || warningMsg.length > 0
}
}
font: StyleV2.p6
wrapMode: Text.WordWrap
visible: text.length > 0
}

Rectangle {
Expand Down Expand Up @@ -131,6 +110,34 @@ Item {
}
}

Item {
id: messageItem

width: parent.width
height: msgRow.height

Row {
id: msgRow

spacing: 4 * __dp

MMIcon {
id: msgIcon

source: visible ? StyleV2.errorIcon : ""
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor
visible: errorMsg.length > 0 || warningMsg.length > 0
}
Text {
text: errorMsg.length > 0 ? errorMsg : warningMsg
font: StyleV2.t4
wrapMode: Text.WordWrap
width: messageItem.width - msgRow.spacing - msgIcon.width
visible: errorMsg.length > 0 || warningMsg.length > 0
}
}
}

// add whole text to clipboard
function textToClipboard() {
textField.selectAll()
Expand Down
65 changes: 36 additions & 29 deletions app/qmlV2/component/MMInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,26 @@ import QtQuick.Controls
import QtQuick.Controls.Basic
import ".."

Item {
Column {
id: control

property alias title: titleItem.text
property alias text: textField.text
property alias placeholderText: textField.placeholderText
property url iconSource: ""
property string warningMsg
property string errorMsg

spacing: 6 * __dp
width: 280 * __dp
height: rect.height + messageItem.height

Item {
id: messageItem
Text {
id: titleItem

width: parent.width
anchors.left: parent.left
anchors.top: rect.bottom
anchors.topMargin: 6 * __dp
height: msgRow.height

Row {
id: msgRow

spacing: 4 * __dp

MMIcon {
id: msgIcon

source: visible ? StyleV2.errorIcon : ""
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor
visible: errorMsg.length > 0 || warningMsg.length > 0
}
Text {
text: errorMsg.length > 0 ? errorMsg : warningMsg
font: StyleV2.t4
wrapMode: Text.WordWrap
width: messageItem.width - msgRow.spacing - msgIcon.width
visible: errorMsg.length > 0 || warningMsg.length > 0
}
}
font: StyleV2.p6
wrapMode: Text.WordWrap
visible: text.length > 0
}

Rectangle {
Expand Down Expand Up @@ -116,4 +95,32 @@ Item {
}
}
}

Item {
id: messageItem

width: parent.width
height: msgRow.height

Row {
id: msgRow

spacing: 4 * __dp

MMIcon {
id: msgIcon

source: visible ? StyleV2.errorIcon : ""
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor
visible: errorMsg.length > 0 || warningMsg.length > 0
}
Text {
text: errorMsg.length > 0 ? errorMsg : warningMsg
font: StyleV2.t4
wrapMode: Text.WordWrap
width: messageItem.width - msgRow.spacing - msgIcon.width
visible: errorMsg.length > 0 || warningMsg.length > 0
}
}
}
}
69 changes: 38 additions & 31 deletions app/qmlV2/component/MMPasswordInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,27 @@ import QtQuick.Controls
import QtQuick.Controls.Basic
import ".."

Item {
Column {
id: control

property alias title: titleItem.text
property alias text: textField.text
property alias placeholderText: textField.placeholderText
required property string regexp
property url iconSource: ""
property string warningMsg
property string errorMsg

spacing: 6 * __dp
width: 280 * __dp
height: rect.height + messageItem.height

Item {
id: messageItem
Text {
id: titleItem

width: parent.width
anchors.left: parent.left
anchors.top: rect.bottom
anchors.topMargin: 6 * __dp
height: msgRow.height

Row {
id: msgRow

spacing: 4 * __dp

MMIcon {
id: msgIcon

source: visible ? StyleV2.errorIcon : ""
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor
visible: msg.visible
}
Text {
id: msg

text: errorMsg.length > 0 ? errorMsg : warningMsg
font: StyleV2.t4
wrapMode: Text.WordWrap
width: messageItem.width - msgRow.spacing - msgIcon.width
visible: (errorMsg.length > 0 || warningMsg.length > 0) && !isPasswordCorrect(textField.text)
}
}
font: StyleV2.p6
wrapMode: Text.WordWrap
visible: text.length > 0
}

Rectangle {
Expand Down Expand Up @@ -120,6 +97,36 @@ Item {
}
}

Item {
id: messageItem

width: parent.width
height: msgRow.height

Row {
id: msgRow

spacing: 4 * __dp

MMIcon {
id: msgIcon

source: visible ? StyleV2.errorIcon : ""
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor
visible: msg.visible
}
Text {
id: msg

text: errorMsg.length > 0 ? errorMsg : warningMsg
font: StyleV2.t4
wrapMode: Text.WordWrap
width: messageItem.width - msgRow.spacing - msgIcon.width
visible: (errorMsg.length > 0 || warningMsg.length > 0) && !isPasswordCorrect(textField.text)
}
}
}

function isPasswordCorrect(pwd) {
let pwdRegexp = new RegExp(control.regexp)
return pwdRegexp.test(pwd)
Expand Down
4 changes: 1 addition & 3 deletions app/qmlV2/component/MMSwitch.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ Switch {
width: 20
height: width
radius: width / 2
color: control.down ? StyleV2.mediumGreenColor : StyleV2.whiteColor
border.color: control.enabled ? StyleV2.forestColor : StyleV2.mediumGreenColor
border.width: 6
color: control.enabled ? StyleV2.forestColor : StyleV2.mediumGreenColor
anchors.verticalCenter: parent.verticalCenter
}
}
Expand Down
8 changes: 5 additions & 3 deletions gallery/qml/pages/InputsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ ScrollView {
spacing: 10
anchors.fill: parent
MMInput {
title: "Title"
placeholderText: "Place holder"
}
MMInput {
title: "Title"
text: "Disabled"
enabled: false
}
Column {
TextInput { text: "iconSource: StyleV2.searchIcon" }
MMInput {
title: "Search ..."
placeholderText: "Search"
iconSource: StyleV2.searchIcon
}
}
Column {
TextInput { text: "iconSource: StyleV2.calendarIcon" }
TextInput { text: "warningMsg: ..." }
MMInput {
text: "Calendar"
iconSource: StyleV2.calendarIcon
Expand All @@ -76,6 +76,7 @@ ScrollView {
spacing: 10
anchors.fill: parent
MMPasswordInput {
title: "Username password"
text: "Password"
regexp: '(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{6,})'
errorMsg: "Password must contain at least 6 characters\nMinimum 1 number, uppercase and lowercase letter and special character"
Expand Down Expand Up @@ -104,6 +105,7 @@ ScrollView {
spacing: 10
anchors.fill: parent
MMButtonInput {
title: "Title"
text: "Copy text to clipboard"
buttonText: "Copy"
onClicked: { textToClipboard(); console.log("Text in clipboard") }
Expand Down

1 comment on commit 09aa8f2

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.11.489811 just submitted!

Please sign in to comment.