mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2026-03-15 14:03:17 +08:00
41 lines
732 B
Go
41 lines
732 B
Go
package component
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/widget"
|
|
)
|
|
|
|
type LabelOpt func(*widget.Label)
|
|
|
|
func LabelWrapping(wrapping fyne.TextWrap) LabelOpt {
|
|
return func(l *widget.Label) {
|
|
l.Wrapping = wrapping
|
|
}
|
|
}
|
|
|
|
func LabelAlignment(align fyne.TextAlign) LabelOpt {
|
|
return func(l *widget.Label) {
|
|
l.Alignment = align
|
|
}
|
|
}
|
|
|
|
func LabelTextStyle(style fyne.TextStyle) LabelOpt {
|
|
return func(l *widget.Label) {
|
|
l.TextStyle = style
|
|
}
|
|
}
|
|
|
|
func LabelTruncation(truncation fyne.TextTruncation) LabelOpt {
|
|
return func(l *widget.Label) {
|
|
l.Truncation = truncation
|
|
}
|
|
}
|
|
|
|
func NewLabelWithOpts(text string, opts ...LabelOpt) *widget.Label {
|
|
l := widget.NewLabel(text)
|
|
for _, opt := range opts {
|
|
opt(l)
|
|
}
|
|
return l
|
|
}
|