Skip to content

Commit 7323915

Browse files
committed
Clean up textSendWindow to not be pointer referenced
1 parent ecc67a6 commit 7323915

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

internal/transport/bridge/send.go

+15-18
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type SendData struct {
4949

5050
items []*SendItem
5151
info sendInfoDialog
52-
textWindow *textSendWindow
52+
textWindow textSendWindow
5353

5454
deleting atomic.Bool
5555
list *widget.List
@@ -414,30 +414,27 @@ func (s *textSendWindow) send() {
414414
s.textEntry.SetText("")
415415
}
416416

417-
func createTextSendWindow(app fyne.App) *textSendWindow {
418-
display := &textSendWindow{
419-
window: app.NewWindow("Send Text"),
420-
textEntry: &widget.Entry{MultiLine: true, Wrapping: fyne.TextWrapWord},
421-
cancelButton: &widget.Button{Text: "Cancel", Icon: theme.CancelIcon()},
422-
sendButton: &widget.Button{Text: "Send", Icon: theme.MailSendIcon(), Importance: widget.HighImportance},
417+
func (d *SendData) createTextSendWindow() {
418+
window := d.Client.App.NewWindow("Send Text")
419+
window.SetCloseIntercept(d.textWindow.dismiss)
420+
421+
d.textWindow = textSendWindow{
422+
window: window,
423+
textEntry: &widget.Entry{MultiLine: true, Wrapping: fyne.TextWrapWord, OnSubmitted: func(_ string) { d.textWindow.send() }},
424+
cancelButton: &widget.Button{Text: "Cancel", Icon: theme.CancelIcon(), OnTapped: d.textWindow.dismiss},
425+
sendButton: &widget.Button{Text: "Send", Icon: theme.MailSendIcon(), Importance: widget.HighImportance, OnTapped: d.textWindow.send},
423426
text: make(chan string),
424427
}
425428

426-
display.window.SetCloseIntercept(display.dismiss)
427-
display.cancelButton.OnTapped = display.dismiss
428-
display.sendButton.OnTapped = display.send
429-
display.textEntry.OnSubmitted = func(_ string) { display.send() }
430-
431-
actionContainer := container.NewGridWithColumns(2, display.cancelButton, display.sendButton)
432-
display.window.SetContent(container.NewBorder(nil, actionContainer, nil, nil, display.textEntry))
433-
display.window.Resize(fyne.NewSize(400, 300))
434-
return display
429+
actionContainer := container.NewGridWithColumns(2, d.textWindow.cancelButton, d.textWindow.sendButton)
430+
window.SetContent(container.NewBorder(nil, actionContainer, nil, nil, d.textWindow.textEntry))
431+
window.Resize(fyne.NewSize(400, 300))
435432
}
436433

437434
// showTextSendWindow opens a new window for setting up text to send.
438435
func (d *SendData) showTextSendWindow() string {
439-
if d.textWindow == nil {
440-
d.textWindow = createTextSendWindow(d.Client.App)
436+
if d.textWindow.window == nil {
437+
d.createTextSendWindow()
441438
} else if d.textWindow.window.Canvas().Content().Visible() {
442439
d.textWindow.window.RequestFocus()
443440
return ""

0 commit comments

Comments
 (0)