2022-05-05 04:47:35 +08:00
|
|
|
package components
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image/color"
|
|
|
|
|
|
|
|
"fyne.io/fyne/v2"
|
|
|
|
"fyne.io/fyne/v2/canvas"
|
|
|
|
"fyne.io/fyne/v2/container"
|
|
|
|
"fyne.io/fyne/v2/layout"
|
|
|
|
"fyne.io/fyne/v2/widget"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ColoredText - renders a colored label
|
|
|
|
func ColoredText(text string, color color.Color) *fyne.Container {
|
|
|
|
btn := widget.NewLabel(text)
|
2022-05-07 00:31:43 +08:00
|
|
|
btn.Wrapping = fyne.TextWrapWord
|
2022-05-05 04:47:35 +08:00
|
|
|
bgColor := canvas.NewRectangle(color)
|
|
|
|
return container.New(
|
2022-05-07 00:31:43 +08:00
|
|
|
layout.NewMaxLayout(),
|
2022-05-05 04:47:35 +08:00
|
|
|
bgColor,
|
|
|
|
btn,
|
|
|
|
)
|
|
|
|
}
|