forked from mbk-lab/rui_orig
Added Append function to Theme & bug fixing
This commit is contained in:
parent
26bcc60b1d
commit
3097f89f5a
|
@ -46,7 +46,7 @@ theme {
|
||||||
},
|
},
|
||||||
constants = _{
|
constants = _{
|
||||||
ruiButtonHorizontalPadding = 16px,
|
ruiButtonHorizontalPadding = 16px,
|
||||||
ruiButtonVerticalPadding = 8px,
|
ruiButtonVerticalPadding = 6px,
|
||||||
ruiButtonMargin = 4px,
|
ruiButtonMargin = 4px,
|
||||||
ruiButtonRadius = 4px,
|
ruiButtonRadius = 4px,
|
||||||
ruiButtonHighlightDilation = 1.5px,
|
ruiButtonHighlightDilation = 1.5px,
|
||||||
|
@ -64,7 +64,7 @@ theme {
|
||||||
},
|
},
|
||||||
constants:touch = _{
|
constants:touch = _{
|
||||||
ruiButtonHorizontalPadding = 20px,
|
ruiButtonHorizontalPadding = 20px,
|
||||||
ruiButtonVerticalPadding = 16px
|
ruiButtonVerticalPadding = 10px
|
||||||
},
|
},
|
||||||
styles = [
|
styles = [
|
||||||
ruiApp {
|
ruiApp {
|
||||||
|
|
|
@ -278,7 +278,7 @@ func (edit *editViewData) set(tag string, value interface{}) bool {
|
||||||
case EditViewPattern:
|
case EditViewPattern:
|
||||||
oldText := GetEditViewPattern(edit, "")
|
oldText := GetEditViewPattern(edit, "")
|
||||||
if text, ok := value.(string); ok {
|
if text, ok := value.(string); ok {
|
||||||
edit.properties[Pattern] = text
|
edit.properties[EditViewPattern] = text
|
||||||
if text = GetEditViewPattern(edit, ""); oldText != text {
|
if text = GetEditViewPattern(edit, ""); oldText != text {
|
||||||
if edit.created {
|
if edit.created {
|
||||||
if text != "" {
|
if text != "" {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -2,4 +2,4 @@ module github.com/anoshenko/rui
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require github.com/gorilla/websocket v1.4.2
|
require github.com/gorilla/websocket v1.5.0
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -1,2 +1,4 @@
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
|
|
@ -231,9 +231,9 @@ func registerThemeText(text string) bool {
|
||||||
|
|
||||||
name := theme.Name()
|
name := theme.Name()
|
||||||
if name == "" {
|
if name == "" {
|
||||||
defaultTheme.concat(theme)
|
defaultTheme.Append(theme)
|
||||||
} else if t, ok := resources.themes[name]; ok {
|
} else if t, ok := resources.themes[name]; ok {
|
||||||
t.concat(theme)
|
t.Append(theme)
|
||||||
} else {
|
} else {
|
||||||
resources.themes[name] = theme
|
resources.themes[name] = theme
|
||||||
}
|
}
|
||||||
|
@ -418,9 +418,9 @@ func AddTheme(theme Theme) {
|
||||||
if theme != nil {
|
if theme != nil {
|
||||||
name := theme.Name()
|
name := theme.Name()
|
||||||
if name == "" {
|
if name == "" {
|
||||||
defaultTheme.concat(theme)
|
defaultTheme.Append(theme)
|
||||||
} else if t, ok := resources.themes[name]; ok {
|
} else if t, ok := resources.themes[name]; ok {
|
||||||
t.concat(theme)
|
t.Append(theme)
|
||||||
} else {
|
} else {
|
||||||
resources.themes[name] = theme
|
resources.themes[name] = theme
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,10 @@ type Session interface {
|
||||||
TextDirection() int
|
TextDirection() int
|
||||||
// Constant returns the constant with "tag" name or "" if it is not exists
|
// Constant returns the constant with "tag" name or "" if it is not exists
|
||||||
Constant(tag string) (string, bool)
|
Constant(tag string) (string, bool)
|
||||||
// ConstantTags returns the list of all available constants
|
|
||||||
ConstantTags() []string
|
|
||||||
// Color returns the color with "tag" name or 0 if it is not exists
|
// Color returns the color with "tag" name or 0 if it is not exists
|
||||||
Color(tag string) (Color, bool)
|
Color(tag string) (Color, bool)
|
||||||
// ColorTags returns the list of all available color constants
|
|
||||||
ColorTags() []string
|
|
||||||
// ImageConstant returns the image constant with "tag" name or "" if it is not exists
|
// ImageConstant returns the image constant with "tag" name or "" if it is not exists
|
||||||
ImageConstant(tag string) (string, bool)
|
ImageConstant(tag string) (string, bool)
|
||||||
// ImageConstantTags returns the list of all available image constants
|
|
||||||
ImageConstantTags() []string
|
|
||||||
// SetCustomTheme set the custom theme
|
// SetCustomTheme set the custom theme
|
||||||
SetCustomTheme(name string) bool
|
SetCustomTheme(name string) bool
|
||||||
// UserAgent returns the "user-agent" text of the client browser
|
// UserAgent returns the "user-agent" text of the client browser
|
||||||
|
|
|
@ -119,8 +119,8 @@ func (session *sessionData) getCurrentTheme() Theme {
|
||||||
|
|
||||||
if session.customTheme != nil {
|
if session.customTheme != nil {
|
||||||
session.currentTheme = NewTheme("")
|
session.currentTheme = NewTheme("")
|
||||||
session.currentTheme.concat(defaultTheme)
|
session.currentTheme.Append(defaultTheme)
|
||||||
session.currentTheme.concat(session.customTheme)
|
session.currentTheme.Append(session.customTheme)
|
||||||
return session.currentTheme
|
return session.currentTheme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,15 +337,3 @@ func (session *sessionData) SetLanguage(lang string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *sessionData) ConstantTags() []string {
|
|
||||||
return session.getCurrentTheme().ConstantTags()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (session *sessionData) ColorTags() []string {
|
|
||||||
return session.getCurrentTheme().ColorTags()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (session *sessionData) ImageConstantTags() []string {
|
|
||||||
return session.getCurrentTheme().ImageConstantTags()
|
|
||||||
}
|
|
||||||
|
|
14
tableView.go
14
tableView.go
|
@ -895,8 +895,9 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
vAlign := vAlignCss[vAlignValue]
|
vAlign := vAlignCss[vAlignValue]
|
||||||
|
|
||||||
tableCSS := func(startRow, endRow int, cellTag string, cellBorder BorderProperty, cellPadding BoundsProperty) {
|
tableCSS := func(startRow, endRow int, cellTag string, cellBorder BorderProperty, cellPadding BoundsProperty) {
|
||||||
for row := startRow; row < endRow; row++ {
|
var namedColors []NamedColor = nil
|
||||||
|
|
||||||
|
for row := startRow; row < endRow; row++ {
|
||||||
cssBuilder.buffer.Reset()
|
cssBuilder.buffer.Reset()
|
||||||
if rowStyle != nil {
|
if rowStyle != nil {
|
||||||
if styles := rowStyle.RowStyle(row); styles != nil {
|
if styles := rowStyle.RowStyle(row); styles != nil {
|
||||||
|
@ -1069,6 +1070,17 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
buffer.WriteString(value.cssString())
|
buffer.WriteString(value.cssString())
|
||||||
buffer.WriteString(`"> </div> `)
|
buffer.WriteString(`"> </div> `)
|
||||||
buffer.WriteString(value.String())
|
buffer.WriteString(value.String())
|
||||||
|
if namedColors == nil {
|
||||||
|
namedColors = NamedColors()
|
||||||
|
}
|
||||||
|
for _, namedColor := range namedColors {
|
||||||
|
if namedColor.Color == value {
|
||||||
|
buffer.WriteString(" (")
|
||||||
|
buffer.WriteString(namedColor.Name)
|
||||||
|
buffer.WriteRune(')')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
buffer.WriteString(textToJS(value.String()))
|
buffer.WriteString(textToJS(value.String()))
|
||||||
|
|
4
theme.go
4
theme.go
|
@ -45,12 +45,12 @@ type Theme interface {
|
||||||
SetImage(tag, image, darkUIImage string)
|
SetImage(tag, image, darkUIImage string)
|
||||||
// ImageConstantTags returns the list of all available image constants
|
// ImageConstantTags returns the list of all available image constants
|
||||||
ImageConstantTags() []string
|
ImageConstantTags() []string
|
||||||
|
Append(anotherTheme Theme)
|
||||||
|
|
||||||
constant(tag string, touchUI bool) string
|
constant(tag string, touchUI bool) string
|
||||||
color(tag string, darkUI bool) string
|
color(tag string, darkUI bool) string
|
||||||
image(tag string, darkUI bool) string
|
image(tag string, darkUI bool) string
|
||||||
style(tag string) Params
|
style(tag string) Params
|
||||||
concat(anotherTheme Theme)
|
|
||||||
cssText(session Session) string
|
cssText(session Session) string
|
||||||
data() *theme
|
data() *theme
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ func (theme *theme) data() *theme {
|
||||||
return theme
|
return theme
|
||||||
}
|
}
|
||||||
|
|
||||||
func (theme *theme) concat(anotherTheme Theme) {
|
func (theme *theme) Append(anotherTheme Theme) {
|
||||||
if theme.constants == nil {
|
if theme.constants == nil {
|
||||||
theme.init()
|
theme.init()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue