format code
This commit is contained in:
65
main.go
65
main.go
@@ -6,29 +6,29 @@ import (
|
|||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/storage"
|
|
||||||
"fyne.io/fyne/v2/dialog"
|
"fyne.io/fyne/v2/dialog"
|
||||||
"fyne.io/fyne/v2/layout"
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/storage"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"github.com/k3a/html2text"
|
||||||
"github.com/kirsle/configdir"
|
"github.com/kirsle/configdir"
|
||||||
"github.com/mattn/go-mastodon"
|
"github.com/mattn/go-mastodon"
|
||||||
"github.com/k3a/html2text"
|
|
||||||
/*webview "github.com/webview/webview_go"*/
|
/*webview "github.com/webview/webview_go"*/
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path/filepath"
|
|
||||||
"net/url"
|
|
||||||
_ "net/http"
|
_ "net/http"
|
||||||
|
"net/url"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
_ "time"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
_ "time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var App fyne.App
|
var App fyne.App
|
||||||
@@ -75,7 +75,7 @@ var ProfileSelectionDone bool = false
|
|||||||
var ProfileSelectionProfile *HashbangProfile
|
var ProfileSelectionProfile *HashbangProfile
|
||||||
|
|
||||||
// The visibility that the post is going to be posted with
|
// The visibility that the post is going to be posted with
|
||||||
var PostVisibility string = "public"
|
var PostVisibility string = "public"
|
||||||
|
|
||||||
var ReplyIDEntry *widget.Entry
|
var ReplyIDEntry *widget.Entry
|
||||||
|
|
||||||
@@ -182,12 +182,12 @@ func ProfileLaunch() {
|
|||||||
// Step two: the user now needs to log in
|
// Step two: the user now needs to log in
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Webview := webview.New(false)
|
Webview := webview.New(false)
|
||||||
defer Webview.Destroy()
|
defer Webview.Destroy()
|
||||||
Webview.SetTitle("Authenticate - copy the authorisation code when logged in.")
|
Webview.SetTitle("Authenticate - copy the authorisation code when logged in.")
|
||||||
Webview.SetSize(480, 320, webview.HintNone)
|
Webview.SetSize(480, 320, webview.HintNone)
|
||||||
Webview.Navigate(app.AuthURI)
|
Webview.Navigate(app.AuthURI)
|
||||||
Webview.Run()
|
Webview.Run()
|
||||||
*/
|
*/
|
||||||
u, err := url.Parse(app.AuthURI)
|
u, err := url.Parse(app.AuthURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -269,10 +269,10 @@ func ProfileLaunch() {
|
|||||||
for _, v := range Profiles {
|
for _, v := range Profiles {
|
||||||
ext := ""
|
ext := ""
|
||||||
btn := widget.NewButton("Log in", func() {
|
btn := widget.NewButton("Log in", func() {
|
||||||
ProfileSelectionDone = true
|
ProfileSelectionDone = true
|
||||||
ProfileSelectionProfile = v
|
ProfileSelectionProfile = v
|
||||||
MainWindow.Close()
|
MainWindow.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
if v.InternalName == LoadedConfig.ProfileName {
|
if v.InternalName == LoadedConfig.ProfileName {
|
||||||
ext = "🚪 "
|
ext = "🚪 "
|
||||||
@@ -283,7 +283,6 @@ func ProfileLaunch() {
|
|||||||
|
|
||||||
btn.Text = ext + btn.Text
|
btn.Text = ext + btn.Text
|
||||||
|
|
||||||
|
|
||||||
ProfileSelection.Add(
|
ProfileSelection.Add(
|
||||||
container.NewHBox(
|
container.NewHBox(
|
||||||
widget.NewLabel(v.Name),
|
widget.NewLabel(v.Name),
|
||||||
@@ -419,7 +418,7 @@ func main() {
|
|||||||
|
|
||||||
Timeline := container.NewGridWithColumns(4)
|
Timeline := container.NewGridWithColumns(4)
|
||||||
PostTimeline := container.NewVBox(widget.NewLabel("Posts"))
|
PostTimeline := container.NewVBox(widget.NewLabel("Posts"))
|
||||||
|
|
||||||
VisibilitySelector := widget.NewSelect([]string{"public", "unlisted", "private", "direct"}, func(value string) {
|
VisibilitySelector := widget.NewSelect([]string{"public", "unlisted", "private", "direct"}, func(value string) {
|
||||||
PostVisibility = value
|
PostVisibility = value
|
||||||
})
|
})
|
||||||
@@ -443,9 +442,8 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
im := canvas.NewImageFromURI(u)
|
im := canvas.NewImageFromURI(u)
|
||||||
im.Resize(fyne.NewSize(25,25))
|
im.Resize(fyne.NewSize(25, 25))
|
||||||
im.FillMode = canvas.ImageFillContain
|
im.FillMode = canvas.ImageFillContain
|
||||||
lab := widget.NewLabel(fmt.Sprintf("%s: %s", status.Account.Username, html2text.HTML2Text(status.Content)))
|
lab := widget.NewLabel(fmt.Sprintf("%s: %s", status.Account.Username, html2text.HTML2Text(status.Content)))
|
||||||
lab.Selectable = true
|
lab.Selectable = true
|
||||||
@@ -489,18 +487,18 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
im := canvas.NewImageFromURI(u)
|
im := canvas.NewImageFromURI(u)
|
||||||
im.FillMode = canvas.ImageFillCover
|
im.FillMode = canvas.ImageFillCover
|
||||||
fyne.Do(func(){Timeline.Add(im)
|
fyne.Do(func() {
|
||||||
ml := widget.NewRichTextFromMarkdown(fmt.Sprintf("%s %s your post", v.Account.Username, v.Type))
|
Timeline.Add(im)
|
||||||
ml.Wrapping = fyne.TextWrapWord
|
ml := widget.NewRichTextFromMarkdown(fmt.Sprintf("%s %s your post", v.Account.Username, v.Type))
|
||||||
Timeline.Add(ml)
|
ml.Wrapping = fyne.TextWrapWord
|
||||||
Timeline.Add(label)
|
Timeline.Add(ml)
|
||||||
tw := widget.NewLabel(timestring)
|
Timeline.Add(label)
|
||||||
tw.Wrapping = fyne.TextWrapWord
|
tw := widget.NewLabel(timestring)
|
||||||
Timeline.Add(tw)
|
tw.Wrapping = fyne.TextWrapWord
|
||||||
})
|
Timeline.Add(tw)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
//Timeline = NewTimeline
|
//Timeline = NewTimeline
|
||||||
}
|
}
|
||||||
@@ -508,16 +506,15 @@ func main() {
|
|||||||
go ShowNotifications()
|
go ShowNotifications()
|
||||||
go ShowTimeline()
|
go ShowTimeline()
|
||||||
|
|
||||||
RefreshAll := widget.NewButton("Refresh", func(){
|
RefreshAll := widget.NewButton("Refresh", func() {
|
||||||
ShowNotifications()
|
ShowNotifications()
|
||||||
ShowTimeline()
|
ShowTimeline()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
MainWindow.SetContent(container.NewVSplit(container.NewVScroll(PostTimeline), container.NewHSplit(container.NewVBox(TootEntry, ReplyBox, VisibilitySelector, widget.NewButton("Post", func() {
|
MainWindow.SetContent(container.NewVSplit(container.NewVScroll(PostTimeline), container.NewHSplit(container.NewVBox(TootEntry, ReplyBox, VisibilitySelector, widget.NewButton("Post", func() {
|
||||||
toot := mastodon.Toot{
|
toot := mastodon.Toot{
|
||||||
Status: TootEntry.Text,
|
Status: TootEntry.Text,
|
||||||
Visibility: PostVisibility,
|
Visibility: PostVisibility,
|
||||||
InReplyToID: mastodon.ID(ReplyIDEntry.Text),
|
InReplyToID: mastodon.ID(ReplyIDEntry.Text),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user