Experimental notifications + windows icon

This commit is contained in:
2025-11-23 11:59:55 +00:00
parent e933f44a32
commit 16ede1f39c
5 changed files with 63 additions and 8 deletions

55
main.go
View File

@@ -3,7 +3,9 @@ package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
@@ -11,6 +13,7 @@ import (
"github.com/google/uuid"
"github.com/kirsle/configdir"
"github.com/mattn/go-mastodon"
"github.com/k3a/html2text"
webview "github.com/webview/webview_go"
"encoding/json"
@@ -21,6 +24,7 @@ import (
"fmt"
"log"
"os"
_ "time"
"strings"
)
@@ -67,6 +71,9 @@ var ProfileSetupProfile *FederaleProfile
var ProfileSelectionDone bool = false
var ProfileSelectionProfile *FederaleProfile
// The visibility that the post is going to be posted with
var PostVisibility string
// This function saves the config in memory to disk.
func SaveConfigToDisk() error {
ConfigPath := configdir.LocalConfig("federale") // Federale foler in the user's config directory
@@ -380,18 +387,50 @@ func main() {
ReplyIDLabel := widget.NewLabel("In reply to")
ReplyBox := container.NewHBox(ReplyIDLabel, ReplyIDEntry)
Timeline := container.NewVBox(widget.NewLabel("Please Wait..."))
Timeline := container.NewGridWithColumns(4)
VisibilitySelector := widget.NewSelect([]string{"public", "unlisted", "private", "direct"}, func(value string) {
PostVisibility = value
})
go func() {
NewTimeline := container.NewVBox(widget.NewLabel("Posts"))
//pg := new(mastodon.Pagination)
///
Timeline = NewTimeline
pg := new(mastodon.Pagination)
//NewTimeline := container.NewVBox(widget.NewLabel("Notifications"))
notis, err := Client.GetNotifications(context.Background(), pg)
if err != nil {
Timeline.Objects[0] = widget.NewLabel(fmt.Sprintf("Error getting notifications: %s", err.Error()))
return
}
for _, v := range notis {
timeb, err := v.CreatedAt.MarshalText()
if err != nil {
continue
}
timestring := string(timeb)
label := widget.NewLabel(html2text.HTML2Text(v.Status.Content))
label.Truncation = fyne.TextTruncateEllipsis
avatar_uri := v.Account.AvatarStatic
u, err := storage.ParseURI(avatar_uri)
if err != nil {
continue
}
im := canvas.NewImageFromURI(u)
im.FillMode = canvas.ImageFillContain
Timeline.Add(im)
Timeline.Add(widget.NewRichTextFromMarkdown(fmt.Sprintf("%s %s your post", v.Account.Username, v.Type)))
Timeline.Add(label)
Timeline.Add(widget.NewLabel(timestring))
}
//Timeline = NewTimeline
}()
MainWindow.SetContent(container.NewHBox(container.NewVBox(TootEntry, ReplyBox, widget.NewButton("Post", func() {
MainWindow.SetContent(container.NewHSplit(container.NewVBox(TootEntry, ReplyBox, VisibilitySelector, widget.NewButton("Post", func() {
toot := mastodon.Toot{
Status: TootEntry.Text,
Visibility: "public",
Visibility: PostVisibility,
InReplyToID: mastodon.ID(ReplyIDEntry.Text),
}
@@ -399,6 +438,6 @@ func main() {
if err != nil {
dialog.ShowError(err, MainWindow)
}
})), Timeline))
})), container.NewVScroll(Timeline)))
MainWindow.ShowAndRun()
}