aboutsummaryrefslogtreecommitdiff
path: root/ui/widget
diff options
context:
space:
mode:
Diffstat (limited to 'ui/widget')
-rw-r--r--ui/widget/color.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/ui/widget/color.go b/ui/widget/color.go
index edb966c..5a8d001 100644
--- a/ui/widget/color.go
+++ b/ui/widget/color.go
@@ -21,6 +21,8 @@ import (
"hash/fnv"
"maunium.net/go/tcell"
+
+ "maunium.net/go/mautrix/id"
)
var colorNames = []string{
@@ -201,8 +203,17 @@ func GetHashColorName(s string) string {
// GetHashColor gets the tcell Color value for the given string.
//
// GetHashColor calls GetHashColorName() and gets the Color value from the tcell.ColorNames map.
-func GetHashColor(s string) tcell.Color {
- return tcell.ColorNames[GetHashColorName(s)]
+func GetHashColor(val interface{}) tcell.Color {
+ switch str := val.(type) {
+ case string:
+ return tcell.ColorNames[GetHashColorName(str)]
+ case *string:
+ return tcell.ColorNames[GetHashColorName(*str)]
+ case id.UserID:
+ return tcell.ColorNames[GetHashColorName(string(str))]
+ default:
+ return tcell.ColorNames["red"]
+ }
}
// AddColor adds tview color tags to the given string.