Colored nicks
This commit is contained in:
47
main.go
47
main.go
@@ -13,6 +13,7 @@ import (
|
||||
"log"
|
||||
"math/rand/v2"
|
||||
"net/url"
|
||||
"image/color"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -38,6 +39,7 @@ import (
|
||||
"mellium.im/xmpp/muc"
|
||||
"mellium.im/xmpp/pubsub"
|
||||
"mellium.im/xmpp/stanza"
|
||||
xmppColor "mellium.im/xmpp/color"
|
||||
// TODO: integrated theme switcher
|
||||
)
|
||||
|
||||
@@ -166,9 +168,9 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
im := ii.Image(25)
|
||||
ico := canvas.NewImageFromImage(im)
|
||||
ico.FillMode = canvas.ImageFillOriginal
|
||||
author := widget.NewLabel("author")
|
||||
author := canvas.NewText("author", color.RGBA{255, 255, 255, 255})
|
||||
author.TextStyle.Bold = true
|
||||
author.Selectable = true
|
||||
// author.Selectable = true
|
||||
content := widget.NewLabel("content")
|
||||
content.Wrapping = fyne.TextWrapWord
|
||||
content.Selectable = true
|
||||
@@ -206,7 +208,10 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
|
||||
// Icon generate end
|
||||
|
||||
author := authorBox.Objects[1].(*widget.Label)
|
||||
author := authorBox.Objects[1].(*canvas.Text)
|
||||
col := xmppColor.String(chatTabs[chatJidStr].Messages[i].Author, 0, xmppColor.None)
|
||||
author.Color = col
|
||||
|
||||
content := vbox.Objects[2].(*widget.Label)
|
||||
unknown_tags := chatTabs[chatJidStr].Messages[i].Raw.Unknown
|
||||
for _, v := range unknown_tags {
|
||||
@@ -215,7 +220,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
if attr.Name.Local == "id" {
|
||||
reason, ok := OccupantIdsToBlock[attr.Value]
|
||||
if ok {
|
||||
author.SetText("Ignored user")
|
||||
author.Text = ("Ignored user")
|
||||
content.SetText("This user is ignored due to: " + reason)
|
||||
content.Importance = widget.LowImportance
|
||||
return // message is from blocked user
|
||||
@@ -298,15 +303,15 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
for i := len(chatTabs[chatJidStr].Messages) - 1; i >= 0; i-- {
|
||||
if reply.ID == chatTabs[chatJidStr].Messages[i].Raw.StanzaID.ID {
|
||||
replytext.Show()
|
||||
replytext.SetText(fmt.Sprintf("%s %s", replyBodyIcon, strings.ReplaceAll(chatTabs[chatJidStr].Messages[i].Content, "\n", newlineIcon)))
|
||||
replytext.Text = fmt.Sprintf("%s %s", replyBodyIcon, strings.ReplaceAll(chatTabs[chatJidStr].Messages[i].Content, "\n", newlineIcon))
|
||||
guy = chatTabs[chatJidStr].Messages[i].Author
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
author.SetText(fmt.Sprintf("%s %s %s", chatTabs[chatJidStr].Messages[i].Author, replyNameIcon, guy))
|
||||
author.Text = (fmt.Sprintf("%s %s %s", chatTabs[chatJidStr].Messages[i].Author, replyNameIcon, guy))
|
||||
} else {
|
||||
author.SetText(chatTabs[chatJidStr].Messages[i].Author)
|
||||
author.Text = (chatTabs[chatJidStr].Messages[i].Author)
|
||||
replytext.Hide()
|
||||
}
|
||||
|
||||
@@ -322,7 +327,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
}
|
||||
|
||||
if sl[0] == "/me" {
|
||||
author.SetText(author.Text + " " + strings.Join(sl[1:], " "))
|
||||
author.Text = (author.Text + " " + strings.Join(sl[1:], " "))
|
||||
content.SetText(" ")
|
||||
}
|
||||
|
||||
@@ -1293,6 +1298,8 @@ func main() {
|
||||
entry.Text = old
|
||||
})
|
||||
|
||||
|
||||
|
||||
kai := fyne.NewMenuItem("kai cenat beg", func() {
|
||||
old := entry.Text
|
||||
entry.Text = "chat will you subscribe to save the kai cenat mafiathon 3"
|
||||
@@ -1307,6 +1314,13 @@ func main() {
|
||||
entry.Text = old
|
||||
})
|
||||
|
||||
wspeed := fyne.NewMenuItem("W Speed ❤️🩹❤️🩹", func() {
|
||||
old := entry.Text
|
||||
entry.Text = "W Speed ❤️🩹❤️🩹"
|
||||
SendCallback()
|
||||
entry.Text = old
|
||||
})
|
||||
|
||||
exposed_suffix := fyne.NewMenuItem(".exposed", func() {
|
||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||
if !ok {
|
||||
@@ -1383,7 +1397,7 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
menu_jokes := fyne.NewMenu("Δ", mycurrenttime, mycurrentplayingsong, hafjag, hotfuck, agree, kai, mipipiemi, exposed_suffix)
|
||||
menu_jokes := fyne.NewMenu("Δ", mycurrenttime, mycurrentplayingsong, hafjag, hotfuck, agree, kai, mipipiemi, exposed_suffix, wspeed)
|
||||
bit := fyne.NewMenuItem("mark selected message as read", func() {
|
||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||
if !ok {
|
||||
@@ -1418,8 +1432,12 @@ func main() {
|
||||
return // TODO: For 1:1 DMs we use OccupantID for the ID and send message type 'chat'
|
||||
}
|
||||
|
||||
id := chatTabs[activeMucJid].Messages[selectedId].Raw.StanzaID.ID
|
||||
msg := fmt.Sprintf("<message type='groupchat' to='%s' id='retract-message-1'><retract id='%s' xmlns='urn:xmpp:message-retract:1'/><fallback xmlns='urn:xmpp:fallback:0' for='urn:xmpp:message-retract:1' /><body>This user retracted a previous message, but it's unsupported by your client.</body><store xmlns='urn:xmpp:hints'/></message>", activeMucJid, id)
|
||||
id := chatTabs[activeMucJid].Messages[selectedId].Raw.StanzaID
|
||||
if id == nil {
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("<message type='groupchat' to='%s' id='retract-message-1'><retract id='%s' xmlns='urn:xmpp:message-retract:1'/><fallback xmlns='urn:xmpp:fallback:0' for='urn:xmpp:message-retract:1' /><body>This user retracted a previous message, but it's unsupported by your client.</body><store xmlns='urn:xmpp:hints'/></message>", activeMucJid, id.ID)
|
||||
fmt.Println(msg)
|
||||
err := client.Session.Send(context.TODO(), xml.NewDecoder(strings.NewReader(msg)))
|
||||
if err != nil {
|
||||
@@ -1593,7 +1611,6 @@ func main() {
|
||||
}
|
||||
|
||||
AppTabs.OnUnselected = func(ti *container.TabItem) {
|
||||
fmt.Println("hiding")
|
||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||
if !ok {
|
||||
return
|
||||
@@ -1604,7 +1621,6 @@ func main() {
|
||||
var MainSplit *container.Split
|
||||
|
||||
AppTabs.OnSelected = func(ti *container.TabItem) {
|
||||
fmt.Println("showing")
|
||||
chatSidebar.Resize(chatSidebar.Size())
|
||||
if AppTabs.Selected() == AppTabs.Items[0] {
|
||||
chatSidebar.Hidden = true
|
||||
@@ -1635,7 +1651,7 @@ func main() {
|
||||
memberLabel := widget.NewLabel(fmt.Sprintf("%d members ", len(tab.Members)))
|
||||
memberLabel.Truncation = fyne.TextTruncateEllipsis
|
||||
box := container.NewVBox(nameLabel)
|
||||
chatSidebar.Objects = []fyne.CanvasObject{}
|
||||
// chatSidebar.Objects = []fyne.CanvasObject{}
|
||||
|
||||
for name, p := range tab.Members {
|
||||
log.Println(string(p.Type))
|
||||
@@ -1677,6 +1693,7 @@ func main() {
|
||||
}
|
||||
s.Truncation = fyne.TextTruncateEllipsis
|
||||
box.Add(s)
|
||||
box.Refresh()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1690,7 +1707,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
chatSidebar.Hidden = false
|
||||
chatSidebar.Refresh()
|
||||
chatSidebar.Show()
|
||||
MainSplit.Resize(MainSplit.Size())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user