mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-16 16:47:24 +00:00
fix(@desktop/onboarding): show identicon ring and colors for profiles
issue: #5358
This commit is contained in:
parent
f2898b6bf7
commit
bf530a6cc4
@ -1,5 +1,6 @@
|
|||||||
import sequtils, sugar
|
import sequtils, sugar
|
||||||
import color_hash_item, color_hash_model
|
|
||||||
|
import ../../shared_models/[color_hash_item, color_hash_model]
|
||||||
|
|
||||||
type
|
type
|
||||||
ColorHashSegment* = tuple[len, colorIdx: int]
|
ColorHashSegment* = tuple[len, colorIdx: int]
|
||||||
|
@ -1,25 +1,49 @@
|
|||||||
|
import NimQml
|
||||||
|
|
||||||
|
import sequtils, sugar
|
||||||
|
import ../../shared_models/[color_hash_item, color_hash_model]
|
||||||
|
|
||||||
|
type
|
||||||
|
ColorHashSegment* = tuple[len, colorIdx: int]
|
||||||
|
|
||||||
type
|
type
|
||||||
Item* = object
|
Item* = object
|
||||||
name: string
|
name: string
|
||||||
thumbnailImage: string
|
thumbnailImage: string
|
||||||
largeImage: string
|
largeImage: string
|
||||||
keyUid: string
|
keyUid: string
|
||||||
|
colorHash: color_hash_model.Model
|
||||||
|
colorHashVariant: QVariant
|
||||||
|
colorId: int
|
||||||
|
|
||||||
proc initItem*(name, thumbnailImage, largeImage, keyUid: string):
|
proc initItem*(name, thumbnailImage, largeImage, keyUid: string, colorHash: seq[ColorHashSegment], colorId: int):
|
||||||
Item =
|
Item =
|
||||||
result.name = name
|
result.name = name
|
||||||
result.thumbnailImage = thumbnailImage
|
result.thumbnailImage = thumbnailImage
|
||||||
result.largeImage = largeImage
|
result.largeImage = largeImage
|
||||||
result.keyUid = keyUid
|
result.keyUid = keyUid
|
||||||
|
result.colorHash = color_hash_model.newModel()
|
||||||
|
result.colorHash.setItems(map(colorHash, x => color_hash_item.initItem(x.len, x.colorIdx)))
|
||||||
|
result.colorHashVariant = newQVariant(result.colorHash)
|
||||||
|
result.colorId = colorId
|
||||||
|
|
||||||
proc getName*(self: Item): string =
|
proc getName*(self: Item): string =
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
proc getThumbnailImage*(self: Item): string =
|
proc getThumbnailImage*(self: Item): string =
|
||||||
result = self.thumbnailImage
|
return self.thumbnailImage
|
||||||
|
|
||||||
proc getLargeImage*(self: Item): string =
|
proc getLargeImage*(self: Item): string =
|
||||||
result = self.largeImage
|
return self.largeImage
|
||||||
|
|
||||||
proc getKeyUid*(self: Item): string =
|
proc getKeyUid*(self: Item): string =
|
||||||
return self.keyUid
|
return self.keyUid
|
||||||
|
|
||||||
|
proc getColorHash*(self: Item): color_hash_model.Model =
|
||||||
|
return self.colorHash
|
||||||
|
|
||||||
|
proc getColorHashVariant*(self: Item): QVariant =
|
||||||
|
return self.colorHashVariant
|
||||||
|
|
||||||
|
proc getColorId*(self: Item): int =
|
||||||
|
return self.colorId
|
||||||
|
@ -8,6 +8,8 @@ type
|
|||||||
ThumbnailImage
|
ThumbnailImage
|
||||||
LargeImage
|
LargeImage
|
||||||
KeyUid
|
KeyUid
|
||||||
|
ColorHash
|
||||||
|
ColorId
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
@ -33,7 +35,9 @@ QtObject:
|
|||||||
ModelRole.Name.int:"username",
|
ModelRole.Name.int:"username",
|
||||||
ModelRole.ThumbnailImage.int:"thumbnailImage",
|
ModelRole.ThumbnailImage.int:"thumbnailImage",
|
||||||
ModelRole.LargeImage.int:"largeImage",
|
ModelRole.LargeImage.int:"largeImage",
|
||||||
ModelRole.KeyUid.int:"keyUid"
|
ModelRole.KeyUid.int:"keyUid",
|
||||||
|
ModelRole.ColorHash.int:"colorHash",
|
||||||
|
ModelRole.ColorId.int:"colorId"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||||
@ -55,6 +59,10 @@ QtObject:
|
|||||||
result = newQVariant(item.getLargeImage())
|
result = newQVariant(item.getLargeImage())
|
||||||
of ModelRole.KeyUid:
|
of ModelRole.KeyUid:
|
||||||
result = newQVariant(item.getKeyUid())
|
result = newQVariant(item.getKeyUid())
|
||||||
|
of ModelRole.ColorHash:
|
||||||
|
result = newQVariant(item.getColorHash())
|
||||||
|
of ModelRole.ColorId:
|
||||||
|
result = newQVariant(item.getColorId())
|
||||||
|
|
||||||
proc setItems*(self: Model, items: seq[Item]) =
|
proc setItems*(self: Model, items: seq[Item]) =
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
|
@ -56,7 +56,7 @@ method load*(self: Module) =
|
|||||||
var largeImage: string
|
var largeImage: string
|
||||||
self.extractImages(acc, thumbnailImage, largeImage)
|
self.extractImages(acc, thumbnailImage, largeImage)
|
||||||
items.add(initItem(acc.name, thumbnailImage, largeImage,
|
items.add(initItem(acc.name, thumbnailImage, largeImage,
|
||||||
acc.keyUid))
|
acc.keyUid, acc.colorHash, acc.colorId))
|
||||||
|
|
||||||
self.view.setModelItems(items)
|
self.view.setModelItems(items)
|
||||||
|
|
||||||
|
@ -30,6 +30,18 @@ QtObject:
|
|||||||
QtProperty[string] keyUid:
|
QtProperty[string] keyUid:
|
||||||
read = getKeyUid
|
read = getKeyUid
|
||||||
|
|
||||||
|
proc getColorHash(self: SelectedAccount): QVariant {.slot.} =
|
||||||
|
return self.item.getColorHashVariant()
|
||||||
|
|
||||||
|
QtProperty[QVariant] colorHash:
|
||||||
|
read = getColorHash
|
||||||
|
|
||||||
|
proc getColorId(self: SelectedAccount): int {.slot.} =
|
||||||
|
return self.item.getColorId()
|
||||||
|
|
||||||
|
QtProperty[int] colorId:
|
||||||
|
read = getColorId
|
||||||
|
|
||||||
proc getThumbnailImage(self: SelectedAccount): string {.slot.} =
|
proc getThumbnailImage(self: SelectedAccount): string {.slot.} =
|
||||||
return self.item.getThumbnailImage()
|
return self.item.getThumbnailImage()
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import utils 1.0
|
|||||||
import shared 1.0
|
import shared 1.0
|
||||||
import shared.panels 1.0
|
import shared.panels 1.0
|
||||||
import shared.status 1.0
|
import shared.status 1.0
|
||||||
|
import shared.controls.chat 1.0
|
||||||
|
|
||||||
import StatusQ.Controls 0.1 as StatusQControls
|
import StatusQ.Controls 0.1 as StatusQControls
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
@ -16,6 +17,8 @@ Rectangle {
|
|||||||
property string username: "Jotaro Kujo"
|
property string username: "Jotaro Kujo"
|
||||||
property string keyUid: "0x123345677890987654321123456"
|
property string keyUid: "0x123345677890987654321123456"
|
||||||
property string address: ""
|
property string address: ""
|
||||||
|
property var colorHash
|
||||||
|
property int colorId
|
||||||
property url image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAg0lEQVR4nOzXwQmAMBAFURV7sQybsgybsgyr0QYUlE1g+Mw7ioQMe9lMQwhDaAyhMYTGEJqYkPnrj/t5XE/ft2UdW1yken7MRAyhMYTGEBpDaAyhKe9JbzvSX9WdLWYihtAYQuMLkcYQGkPUScxEDKExhMYQGkNoDKExhMYQmjsAAP//ZfIUZgXTZXQAAAAASUVORK5CYII="
|
property url image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAg0lEQVR4nOzXwQmAMBAFURV7sQybsgybsgyr0QYUlE1g+Mw7ioQMe9lMQwhDaAyhMYTGEJqYkPnrj/t5XE/ft2UdW1yken7MRAyhMYTGEBpDaAyhKe9JbzvSX9WdLWYihtAYQuMLkcYQGkPUScxEDKExhMYQGkNoDKExhMYQmjsAAP//ZfIUZgXTZXQAAAAASUVORK5CYII="
|
||||||
property var onAccountSelect: function() {}
|
property var onAccountSelect: function() {}
|
||||||
property var isSelected: function() {}
|
property var isSelected: function() {}
|
||||||
@ -37,14 +40,17 @@ Rectangle {
|
|||||||
return Style.current.transparent
|
return Style.current.transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusSmartIdenticon {
|
UserImage {
|
||||||
id: accountImage
|
id: accountImage
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: Style.current.padding
|
anchors.leftMargin: Style.current.padding
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
name: root.username
|
name: root.username
|
||||||
image.source: root.image
|
image: root.image
|
||||||
icon.charactersLen: 2
|
colorId: root.colorId
|
||||||
|
colorHash: root.colorHash
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
@ -20,6 +20,8 @@ ListView {
|
|||||||
image: model.thumbnailImage
|
image: model.thumbnailImage
|
||||||
keyUid: model.keyUid
|
keyUid: model.keyUid
|
||||||
address: model.address || ''
|
address: model.address || ''
|
||||||
|
colorHash: model.colorHash
|
||||||
|
colorId: model.colorId
|
||||||
isSelected: function (index, keyUid) {
|
isSelected: function (index, keyUid) {
|
||||||
return accountsView.isSelected(index, keyUid)
|
return accountsView.isSelected(index, keyUid)
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import shared.panels 1.0
|
|||||||
import shared.popups 1.0
|
import shared.popups 1.0
|
||||||
import shared.status 1.0
|
import shared.status 1.0
|
||||||
import shared.controls 1.0
|
import shared.controls 1.0
|
||||||
|
import shared.controls.chat 1.0
|
||||||
import "../popups"
|
import "../popups"
|
||||||
import "../stores"
|
import "../stores"
|
||||||
|
|
||||||
@ -87,12 +88,15 @@ Item {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
StatusSmartIdenticon {
|
UserImage {
|
||||||
id: userImage
|
id: userImage
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
image.source: LoginStore.currentAccount.thumbnailImage
|
|
||||||
|
image: LoginStore.currentAccount.thumbnailImage
|
||||||
name: LoginStore.currentAccount.username
|
name: LoginStore.currentAccount.username
|
||||||
icon.charactersLen: 2
|
colorId: LoginStore.currentAccount.colorId
|
||||||
|
colorHash: LoginStore.currentAccount.colorHash
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
@ -5,6 +5,7 @@ import shared.panels 1.0
|
|||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: root
|
id: root
|
||||||
@ -16,9 +17,12 @@ Loader {
|
|||||||
property string name
|
property string name
|
||||||
property string pubkey
|
property string pubkey
|
||||||
property string image
|
property string image
|
||||||
property bool showRing: false
|
property bool showRing: true
|
||||||
property bool interactive: true
|
property bool interactive: true
|
||||||
|
|
||||||
|
property int colorId: Utils.colorIdForPubkey(pubkey)
|
||||||
|
property var colorHash: Utils.getColorHashAsJson(pubkey)
|
||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
|
|
||||||
height: active ? item.height : 0
|
height: active ? item.height : 0
|
||||||
@ -33,12 +37,11 @@ Loader {
|
|||||||
icon {
|
icon {
|
||||||
width: root.imageWidth
|
width: root.imageWidth
|
||||||
height: root.imageHeight
|
height: root.imageHeight
|
||||||
color: Style.current.background
|
color: Theme.palette.userCustomizationColors[root.colorId]
|
||||||
textColor: Style.current.secondaryText
|
|
||||||
charactersLen: 2
|
charactersLen: 2
|
||||||
}
|
}
|
||||||
ringSettings {
|
ringSettings {
|
||||||
ringSpecModel: root.showRing ? Utils.getColorHashAsJson(root.pubkey) : undefined
|
ringSpecModel: root.showRing ? root.colorHash : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick 2.13
|
import QtQuick 2.13
|
||||||
|
|
||||||
import shared 1.0
|
import shared 1.0
|
||||||
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
function isHex(value) {
|
function isHex(value) {
|
||||||
@ -619,6 +621,17 @@ QtObject {
|
|||||||
return JSON.parse(jsonObj)
|
return JSON.parse(jsonObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function colorIdForPubkey(publicKey) {
|
||||||
|
if (publicKey === "") {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return globalUtils.getColorId(publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
function colorForPubkey(publicKey) {
|
||||||
|
return Theme.palette.userCustomizationColors[colorIdForPubkey(publicKey)]
|
||||||
|
}
|
||||||
|
|
||||||
function getCompressedPk(publicKey) {
|
function getCompressedPk(publicKey) {
|
||||||
if (publicKey === "") {
|
if (publicKey === "") {
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user