From d1b30c56daf154d147ae5025315d2b9101820b3a Mon Sep 17 00:00:00 2001 From: anoshenko Date: Sun, 23 Apr 2023 12:32:03 +0300 Subject: [PATCH] Optimisation --- app_styles.css | 2 +- imageView.go | 3 +-- theme.go | 35 +++++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app_styles.css b/app_styles.css index 32c37e3..79f53e9 100644 --- a/app_styles.css +++ b/app_styles.css @@ -112,7 +112,7 @@ ul:focus { } .ruiImageView { - display: grid; + display: block; } .ruiSvgImageView { diff --git a/imageView.go b/imageView.go index bb7de7c..8c52098 100644 --- a/imageView.go +++ b/imageView.go @@ -67,8 +67,7 @@ func newImageView(session Session) View { func (imageView *imageViewData) init(session Session) { imageView.viewData.init(session) imageView.tag = "ImageView" - //imageView.systemClass = "ruiImageView" - + imageView.systemClass = "ruiImageView" } func (imageView *imageViewData) String() string { diff --git a/theme.go b/theme.go index 989e91e..1adb7de 100644 --- a/theme.go +++ b/theme.go @@ -525,18 +525,37 @@ func (theme *theme) cssText(session Session) string { var builder cssStyleBuilder builder.init() - for tag, style := range theme.styles { - builder.startStyle(tag) - style.cssViewStyle(&builder, session) - builder.endStyle() + styleList := func(styles map[string]ViewStyle) []string { + ruiStyles := []string{} + customStyles := []string{} + for tag, _ := range styles { + if strings.HasPrefix(tag, "rui") { + ruiStyles = append(ruiStyles, tag) + } else { + customStyles = append(customStyles, tag) + } + } + sort.Strings(ruiStyles) + sort.Strings(customStyles) + return append(ruiStyles, customStyles...) + } + + for _, tag := range styleList(theme.styles) { + if style := theme.styles[tag]; style != nil { + builder.startStyle(tag) + style.cssViewStyle(&builder, session) + builder.endStyle() + } } for _, media := range theme.mediaStyles { builder.startMedia(media.cssText()) - for tag, style := range media.styles { - builder.startStyle(tag) - style.cssViewStyle(&builder, session) - builder.endStyle() + for _, tag := range styleList(media.styles) { + if style := media.styles[tag]; style != nil { + builder.startStyle(tag) + style.cssViewStyle(&builder, session) + builder.endStyle() + } } builder.endMedia() }