Skip to content

Commit e8e3f8a

Browse files
committed
Fix title/description editing on Android
1 parent de0c9f9 commit e8e3f8a

File tree

6 files changed

+121
-15
lines changed

6 files changed

+121
-15
lines changed

cmd/streampanel/FyneApp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Website = "https://github.com/xaionaro/streamctl"
55
Name = "streampanel"
66
ID = "center.dx.streampanel"
77
Version = "0.1.0"
8-
Build = 361
8+
Build = 362

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,6 @@ github.com/xaionaro-go/proxy v0.0.0-20250111150848-1f0e7b262638 h1:w7Dt6Mpj36S2c
11611161
github.com/xaionaro-go/proxy v0.0.0-20250111150848-1f0e7b262638/go.mod h1:hOkJBFoMsnCDoZgpSPTHYbnevPgtpD16d9Xga91U+Eo=
11621162
github.com/xaionaro-go/pulse v0.0.0-20241023202712-7151fa00d4bb h1:9iHPI27CYbmJDhzEuCABQthE/DGVNvT60ybWvv3BV8w=
11631163
github.com/xaionaro-go/pulse v0.0.0-20241023202712-7151fa00d4bb/go.mod h1:cpYspI6YljhkUf1WLXLLDmeaaPFc3CnGLjDZf9dZ4no=
1164-
github.com/xaionaro-go/recoder v0.0.0-20250428012439-3fc4b32e59a9 h1:744Nrf5lfHG0lOpivgXHDDsENer25zJlr/f5puIWhGs=
1165-
github.com/xaionaro-go/recoder v0.0.0-20250428012439-3fc4b32e59a9/go.mod h1:Twc+NcQQ+afg4RHxwqqo9pRGIaY7+QwpuAiYa7ClSLw=
11661164
github.com/xaionaro-go/recoder v0.0.0-20250503155018-6f353978d332 h1:jB5I8UE9UL6g7qQKaZ/g9wt3lIXxgkDDJX1cV37D5go=
11671165
github.com/xaionaro-go/recoder v0.0.0-20250503155018-6f353978d332/go.mod h1:Twc+NcQQ+afg4RHxwqqo9pRGIaY7+QwpuAiYa7ClSLw=
11681166
github.com/xaionaro-go/secret v0.0.0-20250111141743-ced12e1082c2 h1:QHpTWfyfmz65cE0MtFXe9fScdi+X0VIYR2wgolSYEUk=

pkg/streampanel/is_mobile.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package streampanel
2+
3+
import (
4+
"fyne.io/fyne/v2"
5+
)
6+
7+
func isMobile() bool {
8+
return fyne.CurrentDevice().IsMobile()
9+
}

pkg/streampanel/llm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ My keywords: %s`, tagsString))
3737
return
3838
}
3939
p.streamTitleField.SetText(t)
40+
p.streamTitleLabel.SetText(t)
4041
}
4142

4243
func (p *Panel) generateNewDescription(
@@ -54,6 +55,7 @@ func (p *Panel) generateNewDescription(
5455
return
5556
}
5657
p.streamDescriptionField.SetText(t)
58+
p.streamDescriptionLabel.SetText(t)
5759
}
5860

5961
func (p *Panel) generateAlternativeTextFor(

pkg/streampanel/panel.go

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ type Panel struct {
8484
startStopButton *widget.Button
8585
profilesListWidget *widget.List
8686
streamTitleField *widget.Entry
87+
streamTitleLabel *widget.Label
8788
streamDescriptionField *widget.Entry
89+
streamDescriptionLabel *widget.Label
8890

8991
dashboardLocker xsync.Mutex
9092
dashboardShowHideButton *widget.Button
@@ -1127,19 +1129,17 @@ func resizeWindow(w fyne.Window, newSize fyne.Size) {
11271129
}
11281130

11291131
func setupStreamString() string {
1130-
switch runtime.GOOS {
1131-
case "android":
1132+
if isMobile() {
11321133
return "Set!"
1133-
default:
1134+
} else {
11341135
return "Setup stream"
11351136
}
11361137
}
11371138

11381139
func startStreamString() string {
1139-
switch runtime.GOOS {
1140-
case "android":
1140+
if isMobile() {
11411141
return "Go!"
1142-
default:
1142+
} else {
11431143
return "Start stream"
11441144
}
11451145
}
@@ -1400,6 +1400,35 @@ func (p *Panel) initMainWindow(
14001400
p.startStopButton.OnTapped()
14011401
p.startStopButton.OnTapped()
14021402
}
1403+
p.streamTitleLabel = widget.NewLabel("")
1404+
p.streamTitleLabel.Wrapping = fyne.TextWrapWord
1405+
streamTitleButton := widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
1406+
f := widget.NewMultiLineEntry()
1407+
f.SetText(p.streamTitleField.Text)
1408+
f.Wrapping = fyne.TextWrapWord
1409+
w := p.app.NewWindow("title edit")
1410+
w.SetContent(container.NewBorder(
1411+
nil,
1412+
container.NewBorder(
1413+
nil,
1414+
nil,
1415+
widget.NewButtonWithIcon("Cancel", theme.DocumentSaveIcon(), func() {
1416+
w.Close()
1417+
}),
1418+
widget.NewButtonWithIcon("Save", theme.DocumentSaveIcon(), func() {
1419+
f.Text = strings.ReplaceAll(f.Text, "\n", " ")
1420+
f.Text = f.Text[:youtubeTitleLength]
1421+
p.streamTitleField.SetText(f.Text)
1422+
p.streamTitleLabel.SetText(f.Text)
1423+
w.Close()
1424+
}),
1425+
),
1426+
nil,
1427+
nil,
1428+
f,
1429+
))
1430+
w.Show()
1431+
})
14031432

14041433
p.streamDescriptionField = widget.NewMultiLineEntry()
14051434
p.streamDescriptionField.SetPlaceHolder("stream description")
@@ -1411,6 +1440,41 @@ func (p *Panel) initMainWindow(
14111440
p.startStopButton.OnTapped()
14121441
p.startStopButton.OnTapped()
14131442
}
1443+
p.streamDescriptionLabel = widget.NewLabel("")
1444+
p.streamDescriptionLabel.Wrapping = fyne.TextWrapWord
1445+
streamDescriptionButton := widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
1446+
f := widget.NewMultiLineEntry()
1447+
f.SetText(p.streamDescriptionField.Text)
1448+
f.Wrapping = fyne.TextWrapWord
1449+
w := p.app.NewWindow("title edit")
1450+
w.SetContent(container.NewBorder(
1451+
nil,
1452+
container.NewBorder(
1453+
nil,
1454+
nil,
1455+
widget.NewButtonWithIcon("Cancel", theme.DocumentSaveIcon(), func() {
1456+
w.Close()
1457+
}),
1458+
widget.NewButtonWithIcon("Save", theme.DocumentSaveIcon(), func() {
1459+
p.streamDescriptionField.SetText(f.Text)
1460+
p.streamDescriptionLabel.SetText(f.Text)
1461+
w.Close()
1462+
}),
1463+
),
1464+
nil,
1465+
nil,
1466+
f,
1467+
))
1468+
w.Show()
1469+
})
1470+
1471+
if isMobile() {
1472+
p.streamTitleField.Hide()
1473+
p.streamDescriptionField.Hide()
1474+
} else {
1475+
p.streamTitleLabel.Hide()
1476+
p.streamDescriptionLabel.Hide()
1477+
}
14141478

14151479
p.twitchCheck = widget.NewCheck("Twitch", nil)
14161480
p.twitchCheck.SetChecked(true)
@@ -1433,8 +1497,27 @@ func (p *Panel) initMainWindow(
14331497
})
14341498

14351499
bottomPanel := container.NewVBox(
1436-
container.NewBorder(nil, nil, regenerateTitleButton, nil, p.streamTitleField),
1437-
container.NewBorder(nil, nil, regenerateDescriptionButton, nil, p.streamDescriptionField),
1500+
container.NewBorder(
1501+
nil, nil,
1502+
regenerateTitleButton, nil,
1503+
container.NewStack(
1504+
p.streamTitleField,
1505+
container.NewBorder(
1506+
nil, nil, streamTitleButton, nil,
1507+
container.NewHScroll(p.streamTitleLabel),
1508+
)),
1509+
),
1510+
container.NewBorder(
1511+
nil, nil,
1512+
regenerateDescriptionButton, nil,
1513+
container.NewStack(
1514+
p.streamDescriptionField,
1515+
container.NewBorder(
1516+
nil, nil, streamDescriptionButton, nil,
1517+
container.NewHScroll(p.streamDescriptionLabel),
1518+
),
1519+
),
1520+
),
14381521
container.NewBorder(
14391522
nil,
14401523
nil,

pkg/streampanel/profile.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,18 @@ func (p *Panel) profileWindow(
638638
}),
639639
)
640640

641-
w.SetContent(
642-
container.NewBorder(
641+
var content fyne.CanvasObject
642+
if isMobile() {
643+
content = container.NewVScroll(container.NewVBox(
644+
profileName,
645+
defaultStreamTitle,
646+
defaultStreamDescription,
647+
container.NewVBox(bottomContentLeft...),
648+
container.NewVBox(bottomContentRight...),
649+
container.NewVBox(bottomContentCommon...),
650+
))
651+
} else {
652+
content = container.NewBorder(
643653
nil,
644654
container.NewVBox(bottomContentCommon...),
645655
nil,
@@ -661,8 +671,10 @@ func (p *Panel) profileWindow(
661671
bottomContentRight...,
662672
),
663673
),
664-
),
665-
)
674+
)
675+
}
676+
677+
w.SetContent(content)
666678
w.Show()
667679
return w
668680
}
@@ -916,7 +928,9 @@ func (p *Panel) onProfilesListSelect(
916928
})
917929
p.selectedProfileName = ptrCopy(profileName)
918930
p.streamTitleField.SetText(profile.DefaultStreamTitle)
931+
p.streamTitleLabel.SetText(profile.DefaultStreamTitle)
919932
p.streamDescriptionField.SetText(profile.DefaultStreamDescription)
933+
p.streamDescriptionLabel.SetText(profile.DefaultStreamDescription)
920934
}
921935

922936
func (p *Panel) onProfilesListUnselect(

0 commit comments

Comments
 (0)