mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-06 02:37:21 +03:00
Move out get credential color logic
This commit is contained in:
parent
f9dd88eb3c
commit
8deb89eb98
25
qml/Main.qml
25
qml/Main.qml
@ -177,7 +177,6 @@ ApplicationWindow {
|
||||
ColumnLayout {
|
||||
width: scrollView.viewport.width
|
||||
id: credentialsColumn
|
||||
spacing: 0
|
||||
visible: device.hasDevice
|
||||
anchors.right: appWindow.right
|
||||
anchors.left: appWindow.left
|
||||
@ -186,23 +185,13 @@ ApplicationWindow {
|
||||
Repeater {
|
||||
id: repeater
|
||||
model: filteredCredentials(credentials)
|
||||
property var selected
|
||||
property var selected: null
|
||||
property var selectedIndex: null
|
||||
|
||||
Rectangle {
|
||||
id: credentialRectangle
|
||||
focus: true
|
||||
color: {
|
||||
if (repeater.selected != null) {
|
||||
if (repeater.selected.name == modelData.name) {
|
||||
return palette.dark
|
||||
}
|
||||
}
|
||||
if (index % 2 == 0) {
|
||||
return "#00000000"
|
||||
}
|
||||
return palette.alternateBase
|
||||
}
|
||||
color: getCredentialColor(index, repeater.selected, modelData)
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: 70
|
||||
Layout.alignment: Qt.AlignTop
|
||||
@ -476,4 +465,14 @@ ApplicationWindow {
|
||||
device.deleteCredential(repeater.selected)
|
||||
}
|
||||
}
|
||||
|
||||
function getCredentialColor(index, selected, modelData) {
|
||||
if (selected !== null && selected.name === modelData.name) {
|
||||
return palette.dark
|
||||
}
|
||||
if (index % 2 == 0) {
|
||||
return "#00000000"
|
||||
}
|
||||
return palette.alternateBase
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user