mirror of https://github.com/anoshenko/rui.git
Improved DetailsView
This commit is contained in:
parent
7d4b90769f
commit
84a00af595
|
@ -35,7 +35,7 @@ func (layout *absoluteLayoutData) htmlSubviews(self View, buffer *strings.Builde
|
|||
if layout.views != nil {
|
||||
for _, view := range layout.views {
|
||||
view.addToCSSStyle(map[string]string{`position`: `absolute`})
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,9 +142,13 @@ func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Buil
|
|||
buffer.WriteString("</summary>")
|
||||
|
||||
case View:
|
||||
buffer.WriteString(`<summary><div style="display: inline-block;">`)
|
||||
viewHTML(value, buffer)
|
||||
buffer.WriteString("</div></summary>")
|
||||
if value.htmlTag() == "div" {
|
||||
viewHTML(value, buffer, "summary")
|
||||
} else {
|
||||
buffer.WriteString(`<summary><div style="display: inline-block;">`)
|
||||
viewHTML(value, buffer, "")
|
||||
buffer.WriteString("</div></summary>")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ func (listLayout *listLayoutData) htmlSubviews(self View, buffer *strings.Builde
|
|||
if listLayout.views != nil {
|
||||
for _, view := range listLayout.views {
|
||||
view.addToCSSStyle(map[string]string{`flex`: `0 0 auto`})
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -659,7 +659,7 @@ func (listView *listViewData) checkboxSubviews(adapter ListAdapter, buffer *stri
|
|||
|
||||
if view := listView.getItemView(adapter, i); view != nil {
|
||||
//view.setNoResizeEvent()
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
} else {
|
||||
buffer.WriteString("ERROR: invalid item view")
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ func (listView *listViewData) noneCheckboxSubviews(adapter ListAdapter, buffer *
|
|||
|
||||
if view := listView.getItemView(adapter, i); view != nil {
|
||||
//view.setNoResizeEvent()
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
} else {
|
||||
buffer.WriteString("ERROR: invalid item view")
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ func (listView *listViewData) updateCheckboxItem(index int, checked bool) {
|
|||
if adapter := listView.getAdapter(); adapter != nil {
|
||||
if view := listView.getItemView(adapter, index); view != nil {
|
||||
view.setNoResizeEvent()
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
} else {
|
||||
buffer.WriteString("ERROR: invalid item view")
|
||||
}
|
||||
|
|
2
popup.go
2
popup.go
|
@ -720,7 +720,7 @@ func (popup *popupData) Show() {
|
|||
|
||||
func (popup *popupData) html(buffer *strings.Builder) {
|
||||
|
||||
viewHTML(popup.layerView, buffer)
|
||||
viewHTML(popup.layerView, buffer, "")
|
||||
}
|
||||
|
||||
func (popup *popupData) viewByHTMLID(id string) View {
|
||||
|
|
|
@ -431,6 +431,6 @@ func (resizable *resizableData) htmlSubviews(self View, buffer *strings.Builder)
|
|||
"grid-row-start": strconv.Itoa(top),
|
||||
"grid-row-end": strconv.Itoa(top + 1),
|
||||
})
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ func (session *sessionData) writeInitScript(writer *strings.Builder) {
|
|||
writer.WriteString(`document.getElementById('ruiRootView').innerHTML = '`)
|
||||
buffer := allocStringBuilder()
|
||||
defer freeStringBuilder(buffer)
|
||||
viewHTML(session.rootView, buffer)
|
||||
viewHTML(session.rootView, buffer, "")
|
||||
text := strings.ReplaceAll(buffer.String(), "'", `\'`)
|
||||
writer.WriteString(text)
|
||||
writer.WriteString("';\nscanElementsSize();")
|
||||
|
@ -360,7 +360,7 @@ func (session *sessionData) reload() {
|
|||
buffer := allocStringBuilder()
|
||||
defer freeStringBuilder(buffer)
|
||||
|
||||
viewHTML(session.rootView, buffer)
|
||||
viewHTML(session.rootView, buffer, "")
|
||||
session.bridge.updateInnerHTML("ruiRootView", buffer.String())
|
||||
session.bridge.callFunc("scanElementsSize")
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ func (session *sessionData) SetLanguage(lang string) {
|
|||
buffer := allocStringBuilder()
|
||||
defer freeStringBuilder(buffer)
|
||||
|
||||
viewHTML(session.rootView, buffer)
|
||||
viewHTML(session.rootView, buffer, "")
|
||||
session.bridge.updateInnerHTML("ruiRootView", buffer.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ func (layout *stackLayoutData) Push(view View, animation int, onPushFinished fun
|
|||
|
||||
buffer.WriteString(`1s ease;">`)
|
||||
|
||||
viewHTML(layout.pushView, buffer)
|
||||
viewHTML(layout.pushView, buffer, "")
|
||||
buffer.WriteString(`</div>`)
|
||||
|
||||
session.appendToInnerHTML(htmlID, buffer.String())
|
||||
|
@ -386,7 +386,7 @@ func (layout *stackLayoutData) Pop(animation int, onPopFinished func(View)) bool
|
|||
buffer.WriteString(`', 'ruiPop', event)" ontransitioncancel="stackTransitionEndEvent('`)
|
||||
buffer.WriteString(htmlID)
|
||||
buffer.WriteString(`', 'ruiPop', event)" style="transition: transform 1s ease;">`)
|
||||
viewHTML(layout.popView, buffer)
|
||||
viewHTML(layout.popView, buffer, "")
|
||||
buffer.WriteString(`</div>`)
|
||||
|
||||
session.appendToInnerHTML(htmlID, buffer.String())
|
||||
|
@ -429,7 +429,7 @@ func (layout *stackLayoutData) htmlSubviews(self View, buffer *strings.Builder)
|
|||
buffer.WriteString(` style="visibility: hidden;"`)
|
||||
}
|
||||
buffer.WriteString(`>`)
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
buffer.WriteString(`</div>`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1559,7 +1559,7 @@ func (table *tableViewData) writeCellHtml(adapter TableAdapter, row, column int,
|
|||
buffer.WriteString(value)
|
||||
|
||||
case View:
|
||||
viewHTML(value, buffer)
|
||||
viewHTML(value, buffer, "")
|
||||
table.cellViews = append(table.cellViews, value)
|
||||
|
||||
case Color:
|
||||
|
|
|
@ -861,7 +861,7 @@ func (tabsLayout *tabsLayoutData) htmlSubviews(self View, buffer *strings.Builde
|
|||
buffer.WriteString(`grid-row-start: 1; grid-row-end: 2; grid-column-start: 1; grid-column-end: 2;">`)
|
||||
}
|
||||
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
buffer.WriteString(`</div>`)
|
||||
}
|
||||
}
|
||||
|
|
11
view.go
11
view.go
|
@ -836,10 +836,13 @@ func (view *viewData) htmlProperties(self View, buffer *strings.Builder) {
|
|||
}
|
||||
}
|
||||
|
||||
func viewHTML(view View, buffer *strings.Builder) {
|
||||
viewHTMLTag := view.htmlTag()
|
||||
func viewHTML(view View, buffer *strings.Builder, htmlTag string) {
|
||||
if htmlTag == "" {
|
||||
htmlTag = view.htmlTag()
|
||||
}
|
||||
//viewHTMLTag := view.htmlTag()
|
||||
buffer.WriteRune('<')
|
||||
buffer.WriteString(viewHTMLTag)
|
||||
buffer.WriteString(htmlTag)
|
||||
buffer.WriteString(` id="`)
|
||||
buffer.WriteString(view.htmlID())
|
||||
buffer.WriteRune('"')
|
||||
|
@ -907,7 +910,7 @@ func viewHTML(view View, buffer *strings.Builder) {
|
|||
view.htmlSubviews(view, buffer)
|
||||
if view.closeHTMLTag() {
|
||||
buffer.WriteString(`</`)
|
||||
buffer.WriteString(viewHTMLTag)
|
||||
buffer.WriteString(htmlTag)
|
||||
buffer.WriteRune('>')
|
||||
}
|
||||
}
|
||||
|
|
41
viewUtils.go
41
viewUtils.go
|
@ -372,23 +372,7 @@ func GetAccentColor(view View, subviewID ...string) Color {
|
|||
// GetFontName returns the subview font.
|
||||
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
||||
func GetFontName(view View, subviewID ...string) string {
|
||||
if len(subviewID) > 0 && subviewID[0] != "" {
|
||||
view = ViewByID(view, subviewID[0])
|
||||
}
|
||||
if view != nil {
|
||||
if font, ok := stringProperty(view, FontName, view.Session()); ok {
|
||||
return font
|
||||
}
|
||||
if value := valueFromStyle(view, FontName); value != nil {
|
||||
if font, ok := value.(string); ok {
|
||||
return font
|
||||
}
|
||||
}
|
||||
if parent := view.Parent(); parent != nil {
|
||||
return GetFontName(parent)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return stringStyledProperty(view, nil, FontName, true)
|
||||
}
|
||||
|
||||
// GetTextColor returns a text color of the subview.
|
||||
|
@ -725,6 +709,29 @@ func valueFromStyle(view View, tag PropertyName) any {
|
|||
return getValue(Style)
|
||||
}
|
||||
|
||||
func stringStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) string {
|
||||
if len(subviewID) > 0 && subviewID[0] != "" {
|
||||
view = ViewByID(view, subviewID[0])
|
||||
}
|
||||
if view != nil {
|
||||
if text, ok := stringProperty(view, tag, view.Session()); ok {
|
||||
return text
|
||||
}
|
||||
if value := valueFromStyle(view, tag); value != nil {
|
||||
if text, ok := value.(string); ok {
|
||||
return text
|
||||
}
|
||||
}
|
||||
if inherit {
|
||||
if parent := view.Parent(); parent != nil {
|
||||
return stringStyledProperty(parent, nil, tag, true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) SizeUnit {
|
||||
if len(subviewID) > 0 && subviewID[0] != "" {
|
||||
view = ViewByID(view, subviewID[0])
|
||||
|
|
|
@ -146,7 +146,7 @@ func (container *viewsContainerData) cssStyle(self View, builder cssBuilder) {
|
|||
func (container *viewsContainerData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||
if container.views != nil {
|
||||
for _, view := range container.views {
|
||||
viewHTML(view, buffer)
|
||||
viewHTML(view, buffer, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue