Files
deskview/internal/ui/styles.go
T
2026-10-27 17:58:28 +08:00

42 lines
984 B
Go

package ui
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)
// lookupColor 从当前主题取色。
func lookupColor(name fyne.ThemeColorName) color.Color {
if app := fyne.CurrentApp(); app != nil {
s := app.Settings()
return s.Theme().Color(name, s.ThemeVariant())
}
return theme.DefaultTheme().Color(name, theme.VariantDark)
}
// withAlpha 调整颜色透明度。
func withAlpha(c color.Color, a uint8) color.Color {
n := color.NRGBAModel.Convert(c).(color.NRGBA)
n.A = a
return n
}
// 界面配色集中在这里,方便统一调整。
func colorUserBubble() color.Color {
return withAlpha(lookupColor(theme.ColorNamePrimary), 0x3A)
}
func colorBotBubble() color.Color {
return withAlpha(lookupColor(theme.ColorNameInputBackground), 0xF2)
}
func colorErrBubble() color.Color {
return withAlpha(lookupColor(theme.ColorNameError), 0x28)
}
func colorBorder() color.Color {
return withAlpha(lookupColor(theme.ColorNameInputBorder), 0xB0)
}