mirror of https://github.com/anoshenko/rui.git
				
				
				
			Bug fixing
This commit is contained in:
		
							parent
							
								
									f239af2324
								
							
						
					
					
						commit
						7ac196c549
					
				|  | @ -1,3 +1,6 @@ | |||
| # v0.18.0 | ||||
| Added SetParams method to View interface | ||||
| 
 | ||||
| # v0.17.0 | ||||
| * Added "mod", "rem", "round", "round-up", "round-down", and "round-to-zero" SizeFunc functions | ||||
| * Added ModSize, RemSize, RoundSize, RoundUpSize, RoundDownSize, and RoundToZeroSize functions | ||||
|  |  | |||
|  | @ -251,22 +251,22 @@ function activateTab(layoutId, tabNumber) { | |||
| 	if (element) { | ||||
| 		const currentNumber = element.getAttribute("data-current"); | ||||
| 		if (currentNumber != tabNumber) { | ||||
| 			function setTab(number, styleProperty, display) { | ||||
| 			function setTab(number, styleProperty, visibility) { | ||||
| 				const tab = document.getElementById(layoutId + '-' + number); | ||||
| 				if (tab) {	 | ||||
| 					tab.className = element.getAttribute(styleProperty); | ||||
| 					const page = document.getElementById(tab.getAttribute("data-view")); | ||||
| 					if (page) { | ||||
| 						page.style.display = display; | ||||
| 						page.style.visibility = visibility | ||||
| 					} | ||||
| 					return | ||||
| 				} | ||||
| 				const page = document.getElementById(layoutId + "-page" + number); | ||||
| 				if (page) { | ||||
| 					page.style.display = display; | ||||
| 					page.style.visibility = visibility | ||||
| 				} | ||||
| 			} | ||||
| 			setTab(currentNumber, "data-inactiveTabStyle", "none") | ||||
| 			setTab(currentNumber, "data-inactiveTabStyle", "hidden") | ||||
| 			setTab(tabNumber, "data-activeTabStyle", ""); | ||||
| 			element.setAttribute("data-current", tabNumber); | ||||
| 			scanElementsSize() | ||||
|  |  | |||
|  | @ -83,6 +83,10 @@ func (customView *CustomViewData) SetAnimated(tag string, value any, animation A | |||
| 	return customView.superView.SetAnimated(tag, value, animation) | ||||
| } | ||||
| 
 | ||||
| func (customView *CustomViewData) SetParams(params Params) bool { | ||||
| 	return customView.superView.SetParams(params) | ||||
| } | ||||
| 
 | ||||
| // SetChangeListener set the function to track the change of the View property
 | ||||
| func (customView *CustomViewData) SetChangeListener(tag string, listener func(View, string)) { | ||||
| 	customView.superView.SetChangeListener(tag, listener) | ||||
|  |  | |||
|  | @ -38,8 +38,8 @@ const ( | |||
| 	// TabCloseButton is the constant for "tab-close-button" property tag.
 | ||||
| 	//
 | ||||
| 	// Used by `TabsLayout`.
 | ||||
| 	// Controls whether to add close button to a tab(s). This property can be set separately for each child view or for tabs 
 | ||||
| 	// layout itself. Property set for child view takes precedence over the value set for tabs layout. Default value is 
 | ||||
| 	// Controls whether to add close button to a tab(s). This property can be set separately for each child view or for tabs
 | ||||
| 	// layout itself. Property set for child view takes precedence over the value set for tabs layout. Default value is
 | ||||
| 	// `false`.
 | ||||
| 	//
 | ||||
| 	// Supported types: `bool`, `int`, `string`.
 | ||||
|  | @ -103,7 +103,7 @@ const ( | |||
| 	// CurrentTabStyle is the constant for "current-tab-style" property tag.
 | ||||
| 	//
 | ||||
| 	// Used by `TabsLayout`.
 | ||||
| 	// Set the style for the display of the current(selected) tab. The default value is "ruiCurrentTab" or 
 | ||||
| 	// Set the style for the display of the current(selected) tab. The default value is "ruiCurrentTab" or
 | ||||
| 	// "ruiCurrentVerticalTab".
 | ||||
| 	//
 | ||||
| 	// Supported types: `string`.
 | ||||
|  | @ -925,24 +925,24 @@ func (tabsLayout *tabsLayoutData) htmlSubviews(self View, buffer *strings.Builde | |||
| 		buffer.WriteString(`-page`) | ||||
| 		buffer.WriteString(strconv.Itoa(n)) | ||||
| 
 | ||||
| 		if current != n { | ||||
| 			buffer.WriteString(`" style="display: grid; align-items: stretch; justify-items: stretch; visibility: hidden; `) | ||||
| 		} else { | ||||
| 			buffer.WriteString(`" style="display: grid; align-items: stretch; justify-items: stretch; `) | ||||
| 		} | ||||
| 
 | ||||
| 		switch location { | ||||
| 		case LeftTabs, LeftListTabs: | ||||
| 			buffer.WriteString(`" style="position: relative; grid-row-start: 1; grid-row-end: 2; grid-column-start: 2; grid-column-end: 3;`) | ||||
| 			buffer.WriteString(`grid-row-start: 1; grid-row-end: 2; grid-column-start: 2; grid-column-end: 3;">`) | ||||
| 
 | ||||
| 		case TopTabs: | ||||
| 			buffer.WriteString(`" style="position: relative; grid-row-start: 2; grid-row-end: 3; grid-column-start: 1; grid-column-end: 2;`) | ||||
| 			buffer.WriteString(`grid-row-start: 2; grid-row-end: 3; grid-column-start: 1; grid-column-end: 2;">`) | ||||
| 
 | ||||
| 		default: | ||||
| 			buffer.WriteString(`" style="position: relative; grid-row-start: 1; grid-row-end: 2; grid-column-start: 1; grid-column-end: 2;`) | ||||
| 			buffer.WriteString(`grid-row-start: 1; grid-row-end: 2; grid-column-start: 1; grid-column-end: 2;">`) | ||||
| 		} | ||||
| 
 | ||||
| 		if current != n { | ||||
| 			buffer.WriteString(` display: none;`) | ||||
| 		} | ||||
| 		buffer.WriteString(`">`) | ||||
| 
 | ||||
| 		view.addToCSSStyle(map[string]string{`position`: `absolute`, `left`: `0`, `right`: `0`, `top`: `0`, `bottom`: `0`}) | ||||
| 		viewHTML(tabsLayout.views[n], buffer) | ||||
| 		viewHTML(view, buffer) | ||||
| 		buffer.WriteString(`</div>`) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
							
								
								
									
										23
									
								
								view.go
								
								
								
								
							
							
						
						
									
										23
									
								
								view.go
								
								
								
								
							|  | @ -54,6 +54,11 @@ type View interface { | |||
| 	// Scroll returns the location size of the scrollable view in pixels
 | ||||
| 	Scroll() Frame | ||||
| 
 | ||||
| 	// SetParams sets properties with name "tag" of the "rootView" subview. Result:
 | ||||
| 	// * true - all properties were set successful,
 | ||||
| 	// * false - error (incompatible type or invalid format of a string value, see AppLog).
 | ||||
| 	SetParams(params Params) bool | ||||
| 
 | ||||
| 	// SetAnimated sets the value (second argument) of the property with name defined by the first argument.
 | ||||
| 	// Return "true" if the value has been set, in the opposite case "false" are returned and
 | ||||
| 	// a description of the error is written to the log
 | ||||
|  | @ -423,6 +428,24 @@ func (view *viewData) set(tag string, value any) bool { | |||
| 	return true | ||||
| } | ||||
| 
 | ||||
| func (view *viewData) SetParams(params Params) bool { | ||||
| 	if params == nil { | ||||
| 		errorLog("Argument of function SetParams is nil") | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	session := view.Session() | ||||
| 	session.startUpdateScript(view.htmlID()) | ||||
| 	result := true | ||||
| 	for _, tag := range params.AllTags() { | ||||
| 		if value, ok := params[tag]; ok { | ||||
| 			result = view.Set(tag, value) && result | ||||
| 		} | ||||
| 	} | ||||
| 	session.finishUpdateScript(view.htmlID()) | ||||
| 	return result | ||||
| } | ||||
| 
 | ||||
| func viewPropertyChanged(view *viewData, tag string) { | ||||
| 	if view.updateTransformProperty(tag) { | ||||
| 		return | ||||
|  |  | |||
							
								
								
									
										10
									
								
								viewUtils.go
								
								
								
								
							
							
						
						
									
										10
									
								
								viewUtils.go
								
								
								
								
							|  | @ -57,9 +57,15 @@ func SetParams(rootView View, viewID string, params Params) bool { | |||
| 	session := rootView.Session() | ||||
| 	session.startUpdateScript(rootView.htmlID()) | ||||
| 	result := true | ||||
| 	for tag, value := range params { | ||||
| 		result = rootView.Set(tag, value) && result | ||||
| 	//for tag, value := range params {
 | ||||
| 	//	result = rootView.Set(tag, value) && result
 | ||||
| 	//}
 | ||||
| 	for _, tag := range params.AllTags() { | ||||
| 		if value, ok := params[tag]; ok { | ||||
| 			result = rootView.Set(tag, value) && result | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	session.finishUpdateScript(rootView.htmlID()) | ||||
| 	return result | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue