Compare commits
2 Commits
3aa8054dc0
...
b926173f43
| Author | SHA1 | Date | |
|---|---|---|---|
| b926173f43 | |||
| 2667b0ccfd |
47
main.go
47
main.go
@@ -13,6 +13,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"image/color"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -38,6 +39,7 @@ import (
|
|||||||
"mellium.im/xmpp/muc"
|
"mellium.im/xmpp/muc"
|
||||||
"mellium.im/xmpp/pubsub"
|
"mellium.im/xmpp/pubsub"
|
||||||
"mellium.im/xmpp/stanza"
|
"mellium.im/xmpp/stanza"
|
||||||
|
xmppColor "mellium.im/xmpp/color"
|
||||||
// TODO: integrated theme switcher
|
// TODO: integrated theme switcher
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -166,9 +168,9 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
|||||||
im := ii.Image(25)
|
im := ii.Image(25)
|
||||||
ico := canvas.NewImageFromImage(im)
|
ico := canvas.NewImageFromImage(im)
|
||||||
ico.FillMode = canvas.ImageFillOriginal
|
ico.FillMode = canvas.ImageFillOriginal
|
||||||
author := widget.NewLabel("author")
|
author := canvas.NewText("author", color.RGBA{255, 255, 255, 255})
|
||||||
author.TextStyle.Bold = true
|
author.TextStyle.Bold = true
|
||||||
author.Selectable = true
|
// author.Selectable = true
|
||||||
content := widget.NewLabel("content")
|
content := widget.NewLabel("content")
|
||||||
content.Wrapping = fyne.TextWrapWord
|
content.Wrapping = fyne.TextWrapWord
|
||||||
content.Selectable = true
|
content.Selectable = true
|
||||||
@@ -206,7 +208,10 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
|||||||
|
|
||||||
// Icon generate end
|
// 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)
|
content := vbox.Objects[2].(*widget.Label)
|
||||||
unknown_tags := chatTabs[chatJidStr].Messages[i].Raw.Unknown
|
unknown_tags := chatTabs[chatJidStr].Messages[i].Raw.Unknown
|
||||||
for _, v := range unknown_tags {
|
for _, v := range unknown_tags {
|
||||||
@@ -215,7 +220,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
|||||||
if attr.Name.Local == "id" {
|
if attr.Name.Local == "id" {
|
||||||
reason, ok := OccupantIdsToBlock[attr.Value]
|
reason, ok := OccupantIdsToBlock[attr.Value]
|
||||||
if ok {
|
if ok {
|
||||||
author.SetText("Ignored user")
|
author.Text = ("Ignored user")
|
||||||
content.SetText("This user is ignored due to: " + reason)
|
content.SetText("This user is ignored due to: " + reason)
|
||||||
content.Importance = widget.LowImportance
|
content.Importance = widget.LowImportance
|
||||||
return // message is from blocked user
|
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-- {
|
for i := len(chatTabs[chatJidStr].Messages) - 1; i >= 0; i-- {
|
||||||
if reply.ID == chatTabs[chatJidStr].Messages[i].Raw.StanzaID.ID {
|
if reply.ID == chatTabs[chatJidStr].Messages[i].Raw.StanzaID.ID {
|
||||||
replytext.Show()
|
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
|
guy = chatTabs[chatJidStr].Messages[i].Author
|
||||||
break
|
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 {
|
} else {
|
||||||
author.SetText(chatTabs[chatJidStr].Messages[i].Author)
|
author.Text = (chatTabs[chatJidStr].Messages[i].Author)
|
||||||
replytext.Hide()
|
replytext.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +327,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if sl[0] == "/me" {
|
if sl[0] == "/me" {
|
||||||
author.SetText(author.Text + " " + strings.Join(sl[1:], " "))
|
author.Text = (author.Text + " " + strings.Join(sl[1:], " "))
|
||||||
content.SetText(" ")
|
content.SetText(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1293,6 +1298,8 @@ func main() {
|
|||||||
entry.Text = old
|
entry.Text = old
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kai := fyne.NewMenuItem("kai cenat beg", func() {
|
kai := fyne.NewMenuItem("kai cenat beg", func() {
|
||||||
old := entry.Text
|
old := entry.Text
|
||||||
entry.Text = "chat will you subscribe to save the kai cenat mafiathon 3"
|
entry.Text = "chat will you subscribe to save the kai cenat mafiathon 3"
|
||||||
@@ -1307,6 +1314,13 @@ func main() {
|
|||||||
entry.Text = old
|
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() {
|
exposed_suffix := fyne.NewMenuItem(".exposed", func() {
|
||||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||||
if !ok {
|
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() {
|
bit := fyne.NewMenuItem("mark selected message as read", func() {
|
||||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||||
if !ok {
|
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'
|
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
|
id := chatTabs[activeMucJid].Messages[selectedId].Raw.StanzaID
|
||||||
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)
|
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)
|
fmt.Println(msg)
|
||||||
err := client.Session.Send(context.TODO(), xml.NewDecoder(strings.NewReader(msg)))
|
err := client.Session.Send(context.TODO(), xml.NewDecoder(strings.NewReader(msg)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1593,7 +1611,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppTabs.OnUnselected = func(ti *container.TabItem) {
|
AppTabs.OnUnselected = func(ti *container.TabItem) {
|
||||||
fmt.Println("hiding")
|
|
||||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@@ -1604,7 +1621,6 @@ func main() {
|
|||||||
var MainSplit *container.Split
|
var MainSplit *container.Split
|
||||||
|
|
||||||
AppTabs.OnSelected = func(ti *container.TabItem) {
|
AppTabs.OnSelected = func(ti *container.TabItem) {
|
||||||
fmt.Println("showing")
|
|
||||||
chatSidebar.Resize(chatSidebar.Size())
|
chatSidebar.Resize(chatSidebar.Size())
|
||||||
if AppTabs.Selected() == AppTabs.Items[0] {
|
if AppTabs.Selected() == AppTabs.Items[0] {
|
||||||
chatSidebar.Hidden = true
|
chatSidebar.Hidden = true
|
||||||
@@ -1635,7 +1651,7 @@ func main() {
|
|||||||
memberLabel := widget.NewLabel(fmt.Sprintf("%d members ", len(tab.Members)))
|
memberLabel := widget.NewLabel(fmt.Sprintf("%d members ", len(tab.Members)))
|
||||||
memberLabel.Truncation = fyne.TextTruncateEllipsis
|
memberLabel.Truncation = fyne.TextTruncateEllipsis
|
||||||
box := container.NewVBox(nameLabel)
|
box := container.NewVBox(nameLabel)
|
||||||
chatSidebar.Objects = []fyne.CanvasObject{}
|
// chatSidebar.Objects = []fyne.CanvasObject{}
|
||||||
|
|
||||||
for name, p := range tab.Members {
|
for name, p := range tab.Members {
|
||||||
log.Println(string(p.Type))
|
log.Println(string(p.Type))
|
||||||
@@ -1677,6 +1693,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
s.Truncation = fyne.TextTruncateEllipsis
|
s.Truncation = fyne.TextTruncateEllipsis
|
||||||
box.Add(s)
|
box.Add(s)
|
||||||
|
box.Refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1690,7 +1707,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
chatSidebar.Hidden = false
|
chatSidebar.Hidden = false
|
||||||
chatSidebar.Refresh()
|
chatSidebar.Show()
|
||||||
MainSplit.Resize(MainSplit.Size())
|
MainSplit.Resize(MainSplit.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user