mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-08 03:12:50 +08:00
add netease login plugin
This commit is contained in:
52
gui/helper_async_button.go
Normal file
52
gui/helper_async_button.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
// AsyncButton is a Button that handle OnTapped handler asynchronously.
|
||||
type AsyncButton struct {
|
||||
widget.Button
|
||||
anim *fyne.Animation
|
||||
}
|
||||
|
||||
func NewAsyncButton(label string, tapped func()) *AsyncButton {
|
||||
button := &AsyncButton{
|
||||
Button: widget.Button{
|
||||
Text: label,
|
||||
OnTapped: tapped,
|
||||
},
|
||||
}
|
||||
button.ExtendBaseWidget(button)
|
||||
return button
|
||||
}
|
||||
|
||||
func NewAsyncButtonWithIcon(label string, icon fyne.Resource, tapped func()) *AsyncButton {
|
||||
button := &AsyncButton{
|
||||
Button: widget.Button{
|
||||
Text: label,
|
||||
Icon: icon,
|
||||
OnTapped: tapped,
|
||||
},
|
||||
}
|
||||
button.ExtendBaseWidget(button)
|
||||
return button
|
||||
}
|
||||
|
||||
func (b *AsyncButton) Tapped(e *fyne.PointEvent) {
|
||||
if b.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
// missing animation
|
||||
b.Refresh()
|
||||
|
||||
if b.OnTapped != nil {
|
||||
b.Disable()
|
||||
go func() {
|
||||
b.OnTapped()
|
||||
b.Enable()
|
||||
}()
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package gui
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
@@ -11,5 +12,10 @@ type RoomLoggerContainer struct {
|
||||
var RoomLogger = &RoomLoggerContainer{}
|
||||
|
||||
func createRoomLogger() fyne.CanvasObject {
|
||||
return widget.NewLabel("广告位招租")
|
||||
//b := NewAsyncButton("ceshi", func() {
|
||||
// time.Sleep(time.Second * 5)
|
||||
//})
|
||||
return container.NewVBox(
|
||||
widget.NewLabel("广告位招租"),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user