changed a minor issue with lightmode

This commit is contained in:
Grimsace
2026-02-19 14:49:52 -06:00
parent db2c20176c
commit d992dfda2a
2 changed files with 24 additions and 9 deletions
-1
View File
@@ -72,7 +72,6 @@ func (h *historyItem) TappedSecondary(*fyne.PointEvent) {
} }
func (h *historyItem) CreateRenderer() fyne.WidgetRenderer { func (h *historyItem) CreateRenderer() fyne.WidgetRenderer {
h.ExtendBaseWidget(h)
equationLabel := newCustomLabel(h.calc.equation, fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText)*2, fyne.TextStyle{Bold: true}, fyne.TextAlignLeading, theme.ForegroundColor()) equationLabel := newCustomLabel(h.calc.equation, fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText)*2, fyne.TextStyle{Bold: true}, fyne.TextAlignLeading, theme.ForegroundColor())
diceRollsLabel := newCustomLabel(h.calc.diceRolls, fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText)*1.5, fyne.TextStyle{Italic: true}, fyne.TextAlignLeading, theme.ForegroundColor()) diceRollsLabel := newCustomLabel(h.calc.diceRolls, fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText)*1.5, fyne.TextStyle{Italic: true}, fyne.TextAlignLeading, theme.ForegroundColor())
resultLabel := newCustomLabel(h.calc.result, fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText)*2, fyne.TextStyle{}, fyne.TextAlignTrailing, theme.ForegroundColor()) resultLabel := newCustomLabel(h.calc.result, fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText)*2, fyne.TextStyle{}, fyne.TextAlignTrailing, theme.ForegroundColor())
+24 -8
View File
@@ -21,7 +21,6 @@ type customLabel struct {
} }
func (l *customLabel) CreateRenderer() fyne.WidgetRenderer { func (l *customLabel) CreateRenderer() fyne.WidgetRenderer {
l.ExtendBaseWidget(l)
text := canvas.NewText(l.Text, l.Color) text := canvas.NewText(l.Text, l.Color)
text.TextSize = l.TextSize text.TextSize = l.TextSize
text.Alignment = l.Alignment text.Alignment = l.Alignment
@@ -64,13 +63,15 @@ func (r *customLabelRenderer) Destroy() {
} }
func newCustomLabel(text string, size float32, style fyne.TextStyle, align fyne.TextAlign, textColor color.Color) *customLabel { func newCustomLabel(text string, size float32, style fyne.TextStyle, align fyne.TextAlign, textColor color.Color) *customLabel {
return &customLabel{ l := &customLabel{
Text: text, Text: text,
TextSize: size, TextSize: size,
TextStyle: style, TextStyle: style,
Alignment: align, Alignment: align,
Color: textColor, Color: textColor,
} }
l.ExtendBaseWidget(l)
return l
} }
// customButton2 is a custom button widget with theme-aware styling // customButton2 is a custom button widget with theme-aware styling
@@ -82,8 +83,7 @@ type customButton2 struct {
} }
func (b *customButton2) CreateRenderer() fyne.WidgetRenderer { func (b *customButton2) CreateRenderer() fyne.WidgetRenderer {
b.ExtendBaseWidget(b) text := canvas.NewText(b.Text, b.textColor())
text := canvas.NewText(b.Text, color.White)
text.Alignment = fyne.TextAlignCenter text.Alignment = fyne.TextAlignCenter
background := canvas.NewRectangle(color.Transparent) background := canvas.NewRectangle(color.Transparent)
return &customButton2Renderer{ return &customButton2Renderer{
@@ -135,6 +135,7 @@ func (r *customButton2Renderer) MinSize() fyne.Size {
func (r *customButton2Renderer) Refresh() { func (r *customButton2Renderer) Refresh() {
r.text.Text = r.button.Text r.text.Text = r.button.Text
r.text.Color = r.button.textColor()
r.text.Refresh() r.text.Refresh()
r.background.FillColor = r.button.backgroundColor() r.background.FillColor = r.button.backgroundColor()
r.background.Refresh() r.background.Refresh()
@@ -148,27 +149,42 @@ func (r *customButton2Renderer) Destroy() {
} }
func (b *customButton2) backgroundColor() color.Color { func (b *customButton2) backgroundColor() color.Color {
variant := fyne.CurrentApp().Settings().ThemeVariant()
switch b.Importance { switch b.Importance {
case widget.HighImportance: case widget.HighImportance:
return fyne.CurrentApp().Settings().Theme().Color(theme.ColorNamePrimary, theme.VariantDark) return fyne.CurrentApp().Settings().Theme().Color(theme.ColorNamePrimary, variant)
default: default:
return fyne.CurrentApp().Settings().Theme().Color(theme.ColorNameButton, theme.VariantDark) return fyne.CurrentApp().Settings().Theme().Color(theme.ColorNameButton, variant)
}
}
func (b *customButton2) textColor() color.Color {
variant := fyne.CurrentApp().Settings().ThemeVariant()
switch b.Importance {
case widget.HighImportance:
return fyne.CurrentApp().Settings().Theme().Color(theme.ColorNameBackground, variant)
default:
return fyne.CurrentApp().Settings().Theme().Color(theme.ColorNameForeground, variant)
} }
} }
func newCustomButton2(label string, onTap func()) *customButton2 { func newCustomButton2(label string, onTap func()) *customButton2 {
return &customButton2{ b := &customButton2{
Text: label, Text: label,
OnTapped: onTap, OnTapped: onTap,
} }
b.ExtendBaseWidget(b)
return b
} }
func newCustomButton2WithImportance(label string, importance widget.Importance, onTap func()) *customButton2 { func newCustomButton2WithImportance(label string, importance widget.Importance, onTap func()) *customButton2 {
return &customButton2{ b := &customButton2{
Text: label, Text: label,
OnTapped: onTap, OnTapped: onTap,
Importance: importance, Importance: importance,
} }
b.ExtendBaseWidget(b)
return b
} }
// customEntry is a custom entry widget with configurable text size // customEntry is a custom entry widget with configurable text size