diff --git a/README-ru.md b/README-ru.md index 2968b42..829e61d 100644 --- a/README-ru.md +++ b/README-ru.md @@ -358,8 +358,8 @@ View имеет ряд свойств, таких как высота, шири (View реализует данный интерфейс): type Properties interface { - Get(tag string) interface{} - Set(tag string, value interface{}) bool + Get(tag string) any + Set(tag string, value any) bool Remove(tag string) Clear() AllTags() []string @@ -374,8 +374,8 @@ View имеет ряд свойств, таких как высота, шири Для упрощения установки/чтения свойств имеются также две глобальные функции Get и Set: - func Get(rootView View, viewID, tag string) interface{} - func Set(rootView View, viewID, tag string, value interface{}) bool + func Get(rootView View, viewID, tag string) any + func Set(rootView View, viewID, tag string, value any) bool Данные функции возвращают/устанавливают значение дочернего View @@ -439,7 +439,7 @@ View имеет ряд свойств, таких как высота, шири * функция func([<параметры>]) * массив функций []func(< View >[, <параметры>]) * массив функций []func([<параметры>]) -* []interface{} содержащий только func(< View >[, <параметры>]) и func([<параметры>]) +* []any содержащий только func(< View >[, <параметры>]) и func([<параметры>]) После присваивания свойству все эти типы преобразуются в массив функций []func(, [<параметры>]). Соответственно функция Get всегда возвращает массив функций []func(, [<параметры>]). @@ -451,7 +451,7 @@ View имеет ряд свойств, таких как высота, шири * func(newText string) * []func(editor EditView, newText string) * []func(newText string) -* []interface{} содержащий только func(editor EditView, newText string) и func(newText string) +* []any содержащий только func(editor EditView, newText string) и func(newText string) А свойство "edit-text-changed" всегда хранит и возвращает []func(EditView, string). @@ -1037,7 +1037,7 @@ RadiusProperty, а не структура BoxRadius. Получить стру Pos определяет положение точки относительно начала линии градиента. Массив должен иметь не менее 2 точек. В качестве значения градиента можно также передать массив Color. В этом случае точки равномерно распределяются вдоль линии градиента. -Также в качестве массива ключевых точек можно использовать массив типа []interface{}. +Также в качестве массива ключевых точек можно использовать массив типа []any. Элементами этого массива могут быть BackgroundGradientPoint, Color, текстовое представление BackgroundGradientPoint или Color и имя константы @@ -1105,8 +1105,8 @@ Pos определяет положение точки относительно описывается структурой BackgroundGradientAngle: type BackgroundGradientAngle struct { - Color interface{} - Angle interface{} + Color any + Angle any } где Color задает цвет ключевого угла и может принимать значение типа Color или string (цветовая константа @@ -1216,7 +1216,7 @@ radius необходимо передать nil Многоугольная область обрезки. Создается с помощью функций: - func PolygonClip(points []interface{}) ClipShape + func PolygonClip(points []any) ClipShape func PolygonPointsClip(points []SizeUnit) ClipShape в качестве аргумента передается массив угловых точек многоугольника в следующем порядке: x1, y1, x2, y2, … @@ -2114,7 +2114,7 @@ radius необходимо передать nil * []string - каждый элемент массива преобразуется во View как описано в предыдущем пункте; -* []interface{} - данный массив должен содержать только View и string. Каждый string-элемент +* []any - данный массив должен содержать только View и string. Каждый string-элемент преобразуется во View, как описано выше. Если массив будет содержать недопустимае значения, то свойство "content" не будет установлено, а функция Set вернет false и в лог запишется сообщение об ошибке. @@ -2285,7 +2285,7 @@ Cвойство "grid-auto-flow" может принимать следующи * []string. Каждый элемент должен быть текстовым представлением SizeUnit (или SizeUnit константой) -* []interface{}. Каждый элемент должен или иметь тип SizeUnit или быть текстовым +* []any. Каждый элемент должен или иметь тип SizeUnit или быть текстовым представлением SizeUnit (или SizeUnit константой) Если количество элементов в свойствах "cell-width" и "cell-height" меньше, чем используемое число @@ -3141,7 +3141,7 @@ FileInfo содержит только информацию о файле, но * []string * []fmt.Stringer -* []interface{} содержащий в качестве элементов только: string, fmt.Stringer, bool, rune, +* []any содержащий в качестве элементов только: string, fmt.Stringer, bool, rune, float32, float64, int, int8…int64, uint, uint8…uint64. Все эти типы данных преопразуются в []string и присваиваются свойству "items". @@ -3157,9 +3157,9 @@ float32, float64, int, int8…int64, uint, uint8…uint64. * int * []string * string может содержать несколько индексов разделенных запятыми -* []interface{} содержащий в качестве элементов только: string, int, int8…int64, uint, uint8…uint64. +* []any содержащий в качестве элементов только: string, int, int8…int64, uint, uint8…uint64. -Все эти типы данных преопразуются в []interface{} и присваиваются свойству "disabled-items". +Все эти типы данных преопразуются в []any и присваиваются свойству "disabled-items". Прочитать значение свойства "disabled-items" можно с помощью функции func GetDropDownDisabledItems(view View, subviewID string) []int @@ -3248,7 +3248,7 @@ Cвойствy "items" могут быть присвоены следующие * ListAdapter; * []View при присваиваниии преобразуется в ListAdapter с помощью функции NewViewListAdapter; * []string при присваиваниии преобразуется в ListAdapter с помощью функции NewTextListAdapter; -* []interface{} который может содержать элементы типа View, string, fmt.Stringer, bool, rune, +* []any который может содержать элементы типа View, string, fmt.Stringer, bool, rune, float32, float64, int, int8…int64, uint, uint8…uint64. При присваиваниии все типы кроме View и string преобразуется в string, далее все string в TextView и из получившегося массива View с помощью функции NewViewListAdapter получается ListAdapter. @@ -3454,7 +3454,7 @@ CheckboxHorizontalAlign и CheckboxVerticalAlign) type TableAdapter interface { RowCount() int ColumnCount() int - Cell(row, column int) interface{} + Cell(row, column int) any } где функции RowCount() и ColumnCount() должны возврацать количество строк и столбцов в таблице; @@ -3474,10 +3474,10 @@ Cell(row, column int) возвращает содержимое ячейки т Свойству "content" можно также присваивать следующие типы данных * TableAdapter -* [][]interface{} +* [][]any * [][]string -[][]interface{} и [][]string при присвоении преобразуются к TableAdapter. +[][]any и [][]string при присвоении преобразуются к TableAdapter. ### Свойство "cell-style" @@ -3530,7 +3530,7 @@ Cell(row, column int) возвращает содержимое ячейки т | | | | |------|-------|--------| -Если в качестве значения свойства "content" используется [][]interface{}, то для объединения +Если в качестве значения свойства "content" используется [][]any, то для объединения ячеек используются пустые структуры type VerticalTableJoin struct { @@ -3541,7 +3541,7 @@ Cell(row, column int) возвращает содержимое ячейки т Данные структуры присоединяют ячейку, соответсвенно, к верхней/левой. Описание приведенной выше таблицы будет иметь следующий вид - content := [][]interface{} { + content := [][]any { {"", "", rui.HorizontalTableJoin{}}, {rui.VerticalTableJoin{}, "", ""}, } @@ -4552,7 +4552,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Однократная анимация запускается с помощью функции SetAnimated интерфейса View. Данная функция имеет следующее описание: - SetAnimated(tag string, value interface{}, animation Animation) bool + SetAnimated(tag string, value any, animation Animation) bool Она присваивает свойству новое значение, при этом изменение происходит с использованием заданной анимации. Например, @@ -4564,7 +4564,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Есть также глобальная функция для анимированного однократного изменения значения свойства дочернего View - func SetAnimated(rootView View, viewID, tag string, value interface{}, animation Animation) bool + func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool Постоянная анимация запускается каждый раз когда изменяется значение свойства. Для задания постоянной анимации перехода используется свойство "transition" (константа Transition). В качества значения данному @@ -4641,8 +4641,8 @@ Cценарий анимации описывает более сложную а type AnimatedProperty struct { Tag string - From, To interface{} - KeyFrames map[int]interface{} + From, To any + KeyFrames map[int]any } где Tag - имя свойства, From - начальное значение свойства, To - конечное значение свойства, @@ -4834,11 +4834,11 @@ Safari и Firefox. * SetTitleColor(color Color) устанавливает цвет панели навигации браузера. Поддерживается только в Safari и Chrome для Android. -* Get(viewID, tag string) interface{} - возвращает значение свойства View с именем tag. Эквивалентно +* Get(viewID, tag string) any - возвращает значение свойства View с именем tag. Эквивалентно rui.Get(session.RootView(), viewID, tag) -* Set(viewID, tag string, value interface{}) bool - устанавливает значение свойства View с именем tag. +* Set(viewID, tag string, value any) bool - устанавливает значение свойства View с именем tag. rui.Set(session.RootView(), viewID, tag, value) diff --git a/README.md b/README.md index dc0d816..04bd3fb 100644 --- a/README.md +++ b/README.md @@ -362,8 +362,8 @@ View has a number of properties like height, width, color, text parameters, etc. The Properties interface is used to read and write the property value (View implements this interface): type Properties interface { - Get(tag string) interface{} - Set(tag string, value interface{}) bool + Get(tag string) any + Set(tag string, value any) bool Remove(tag string) Clear() AllTags() []string @@ -378,8 +378,8 @@ The Remove function removes property value, equivalent to Set(nil) To simplify setting / reading properties, there are also two global functions Get and Set: - func Get(rootView View, viewID, tag string) interface{} - func Set(rootView View, viewID, tag string, value interface{}) bool + func Get(rootView View, viewID, tag string) any + func Set(rootView View, viewID, tag string, value any) bool These functions get/set the value of the child View @@ -441,7 +441,7 @@ Each event can have multiple listeners. In this regard, five data types can be u * func([< parameters>]) * []func(< View >[, < parameters >]) * []func([< parameters >]) -* []interface{} which only contains func(< View >[, < parameters >]) and func([< parameters >]) +* []any which only contains func(< View >[, < parameters >]) and func([< parameters >]) After being assigned to a property, all these types are converted to an array of []func(< View >, [< parameters >]). Accordingly, the Get function always returns an array of []func(< View >, [< parameters >]). @@ -453,7 +453,7 @@ For the "edit-text-changed" event, this * func(newText string) * []func(editor EditView, newText string) * []func(newText string) -* []interface{} содержащий только func(editor EditView, newText string) и func(newText string) +* []any содержащий только func(editor EditView, newText string) и func(newText string) And the "edit-text-changed" property always stores and returns []func(EditView, string). @@ -1016,7 +1016,7 @@ Optional parameter. The default direction is from bottom to top. It can be eithe Each point is described by a BackgroundGradientPoint structure, which has two fields: Pos of type SizeUnit and Color. Pos defines the position of the point relative to the start of the gradient line. The array must have at least 2 points. You can also pass a Color array as the gradient value. In this case, the points are evenly distributed along the gradient line. -You can also use an array of []interface{} as an array of cue points. +You can also use an array of []any as an array of cue points. The elements of this array can be BackgroundGradientPoint, Color, BackgroundGradientPoint or Color text representation, and the name of the constant * Repeating ("repeating") - a boolean value that determines whether the gradient will repeat after the last key point. @@ -1081,8 +1081,8 @@ The radial gradient has the following options: Each key angle is described by a BackgroundGradientAngle structure: type BackgroundGradientAngle struct { - Color interface{} - Angle interface{} + Color any + Angle any } where Color specifies the color of the key corner and can take a value of Color type or @@ -1194,7 +1194,7 @@ The textual description of the elliptical clipping region is in the following fo Polygonal cropping area. Created using functions: - func PolygonClip(points []interface{}) ClipShape + func PolygonClip(points []any) ClipShape func PolygonPointsClip(points []SizeUnit) ClipShape an array of corner points of the polygon is passed as an argument in the following order: x1, y1, x2, y2, … @@ -2091,7 +2091,7 @@ Next, a []View is created containing the resulting View; * []string - each element of the array is converted to View as described in the previous paragraph; -* []interface{} - this array must contain only View and string. Each string element is converted to +* []any - this array must contain only View and string. Each string element is converted to a View as described above. If the array contains invalid values, the "content" property will not be set, and the Set function will return false and an error message will be written to the log. @@ -3112,7 +3112,7 @@ The following data types can be passed as a value to the "items" property * []string * []fmt.Stringer -* []interface{} containing as elements only: string, fmt.Stringer, bool, rune, +* []any containing as elements only: string, fmt.Stringer, bool, rune, float32, float64, int, int8 … int64, uint, uint8 … uint64. All of these data types are converted to []string and assigned to the "items" property. @@ -3127,9 +3127,9 @@ This property is assigned an array of disabled item indices. The index can be sp * int * []string * string - can contain multiple indexes separated by commas -* []interface{} - containing as elements only: string, int, int8…int64, uint, uint8…uint64. +* []any - containing as elements only: string, int, int8…int64, uint, uint8…uint64. -All of these data types are converted to []interface{} and assigned to the "disabled-items" property. +All of these data types are converted to []any and assigned to the "disabled-items" property. You can read the value of the "disabled-items" property using the function func GetDropDownDisabledItems(view View, subviewID string) []int @@ -3422,7 +3422,7 @@ To describe the content, you need to implement the TableAdapter interface declar type TableAdapter interface { RowCount() int ColumnCount() int - Cell(row, column int) interface{} + Cell(row, column int) any } where RowCount() and ColumnCount() functions must return the number of rows and columns in the table; @@ -3441,10 +3441,10 @@ Cell(row, column int) returns the contents of a table cell. The Cell() function The "content" property can also be assigned the following data types * TableAdapter -* [][]interface{} +* [][]any * [][]string -[][]interface{} and [][]string are converted to a TableAdapter when assigned. +[][]any and [][]string are converted to a TableAdapter when assigned. ### "cell-style" property @@ -3496,7 +3496,7 @@ In this case, the table will look like this | | | | |------+-------+--------| -If [][]interface{} is used as the value of the "content" property, then empty structures are used to merge cells +If [][]any is used as the value of the "content" property, then empty structures are used to merge cells type VerticalTableJoin struct { } @@ -3506,7 +3506,7 @@ If [][]interface{} is used as the value of the "content" property, then empty st These structures attach the cell to the top/left, respectively. The description of the above table will be as follows - content := [][]interface{} { + content := [][]any { {"", "", rui.HorizontalTableJoin{}}, {rui.VerticalTableJoin{}, "", ""}, } @@ -4513,7 +4513,7 @@ There are two types of transition animations: A one-time animation is triggered using the SetAnimated function of the View interface. This function has the following description: - SetAnimated(tag string, value interface{}, animation Animation) bool + SetAnimated(tag string, value any, animation Animation) bool It assigns a new value to the property, and the change occurs using the specified animation. For example, @@ -4525,7 +4525,7 @@ For example, There is also a global function for animated one-time change of the property value of the child View - func SetAnimated(rootView View, viewID, tag string, value interface{}, animation Animation) bool + func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool A persistent animation runs every time the property value changes. To set the constant animation of the transition, use the "transition" property (the Transition constant). @@ -4603,8 +4603,8 @@ the change script of one property. She is described as type AnimatedProperty struct { Tag string - From, To interface{} - KeyFrames map[int]interface{} + From, To any + KeyFrames map[int]any } where Tag is the name of the property, From is the initial value of the property, @@ -4791,7 +4791,7 @@ Returns false if no topic with this name was found. Themes named "" are the defa * SetTitleColor(color Color) sets the color of the browser navigation bar. Supported only in Safari and Chrome for android -* Get(viewID, tag string) interface{} returns the value of the View property named tag. Equivalent to +* Get(viewID, tag string) any returns the value of the View property named tag. Equivalent to rui.Get(session.RootView(), viewID, tag) diff --git a/animation.go b/animation.go index 706cab4..444730a 100644 --- a/animation.go +++ b/animation.go @@ -107,11 +107,11 @@ type AnimatedProperty struct { // Tag is the name of the property Tag string // From is the initial value of the property - From interface{} + From any // To is the final value of the property - To interface{} + To any // KeyFrames is intermediate property values - KeyFrames map[int]interface{} + KeyFrames map[int]any } type animationData struct { @@ -184,7 +184,7 @@ func (animation *animationData) normalizeTag(tag string) string { return tag } -func (animation *animationData) Set(tag string, value interface{}) bool { +func (animation *animationData) Set(tag string, value any) bool { if value == nil { animation.Remove(tag) return true @@ -285,7 +285,7 @@ func (animation *animationData) Set(tag string, value interface{}) bool { ErrorLogF(`key-frame "%d" is out of range`, n) } else { if result.KeyFrames == nil { - result.KeyFrames = map[int]interface{}{n: node.Text()} + result.KeyFrames = map[int]any{n: node.Text()} } else { result.KeyFrames[n] = node.Text() } @@ -359,7 +359,7 @@ func (animation *animationData) Remove(tag string) { delete(animation.properties, animation.normalizeTag(tag)) } -func (animation *animationData) Get(tag string) interface{} { +func (animation *animationData) Get(tag string) any { return animation.getRaw(animation.normalizeTag(tag)) } @@ -602,7 +602,7 @@ func (session *sessionData) registerAnimation(props []AnimatedProperty) string { return name } -func (view *viewData) SetAnimated(tag string, value interface{}, animation Animation) bool { +func (view *viewData) SetAnimated(tag string, value any, animation Animation) bool { if animation == nil { return view.Set(tag, value) } @@ -684,7 +684,7 @@ func (view *viewData) getTransitions() Params { // SetAnimated sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result: // true - success, // false - error (incompatible type or invalid format of a string value, see AppLog). -func SetAnimated(rootView View, viewID, tag string, value interface{}, animation Animation) bool { +func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool { if view := ViewByID(rootView, viewID); view != nil { return view.SetAnimated(tag, value, animation) } diff --git a/animationEvents.go b/animationEvents.go index 0b0a080..4bb45e1 100644 --- a/animationEvents.go +++ b/animationEvents.go @@ -51,7 +51,7 @@ const ( AnimationIterationEvent = "animation-iteration-event" ) -func valueToAnimationListeners(value interface{}) ([]func(View, string), bool) { +func valueToAnimationListeners(value any) ([]func(View, string), bool) { if value == nil { return nil, true } @@ -137,7 +137,7 @@ func valueToAnimationListeners(value interface{}) ([]func(View, string), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -183,7 +183,7 @@ var transitionEvents = map[string]struct{ jsEvent, jsFunc string }{ TransitionCancelEvent: {jsEvent: "ontransitioncancel", jsFunc: "transitionCancelEvent"}, } -func (view *viewData) setTransitionListener(tag string, value interface{}) bool { +func (view *viewData) setTransitionListener(tag string, value any) bool { listeners, ok := valueToAnimationListeners(value) if !ok { notCompatibleType(tag, value) @@ -263,7 +263,7 @@ var animationEvents = map[string]struct{ jsEvent, jsFunc string }{ AnimationCancelEvent: {jsEvent: "onanimationcancel", jsFunc: "animationCancelEvent"}, } -func (view *viewData) setAnimationListener(tag string, value interface{}) bool { +func (view *viewData) setAnimationListener(tag string, value any) bool { listeners, ok := valueToAnimationListeners(value) if !ok { notCompatibleType(tag, value) diff --git a/appLog.go b/appLog.go index 60919bd..3d23c27 100644 --- a/appLog.go +++ b/appLog.go @@ -39,7 +39,7 @@ func DebugLog(text string) { } // DebugLogF print the text to the debug log -func DebugLogF(format string, a ...interface{}) { +func DebugLogF(format string, a ...any) { if debugLogFunc != nil { debugLogFunc(fmt.Sprintf(format, a...)) } @@ -57,7 +57,7 @@ func ErrorLog(text string) { } // ErrorLogF print the text to the error log -func ErrorLogF(format string, a ...interface{}) { +func ErrorLogF(format string, a ...any) { lastError = fmt.Sprintf(format, a...) if errorLogFunc != nil { errorLogFunc(lastError) diff --git a/background.go b/background.go index 9aed11d..f1ff1f9 100644 --- a/background.go +++ b/background.go @@ -81,22 +81,22 @@ func createBackground(obj DataObject) BackgroundElement { switch obj.Tag() { case "image": image := new(backgroundImage) - image.properties = map[string]interface{}{} + image.properties = map[string]any{} result = image case "linear-gradient": gradient := new(backgroundLinearGradient) - gradient.properties = map[string]interface{}{} + gradient.properties = map[string]any{} result = gradient case "radial-gradient": gradient := new(backgroundRadialGradient) - gradient.properties = map[string]interface{}{} + gradient.properties = map[string]any{} result = gradient case "conic-gradient": gradient := new(backgroundConicGradient) - gradient.properties = map[string]interface{}{} + gradient.properties = map[string]any{} result = gradient default: @@ -118,7 +118,7 @@ func createBackground(obj DataObject) BackgroundElement { // NewBackgroundImage creates the new background image func NewBackgroundImage(params Params) BackgroundElement { result := new(backgroundImage) - result.properties = map[string]interface{}{} + result.properties = map[string]any{} for tag, value := range params { result.Set(tag, value) } @@ -156,7 +156,7 @@ func (image *backgroundImage) normalizeTag(tag string) string { return tag } -func (image *backgroundImage) Set(tag string, value interface{}) bool { +func (image *backgroundImage) Set(tag string, value any) bool { tag = image.normalizeTag(tag) switch tag { case Attachment, Width, Height, Repeat, ImageHorizontalAlign, ImageVerticalAlign, @@ -167,7 +167,7 @@ func (image *backgroundImage) Set(tag string, value interface{}) bool { return false } -func (image *backgroundImage) Get(tag string) interface{} { +func (image *backgroundImage) Get(tag string) any { return image.backgroundElement.Get(image.normalizeTag(tag)) } diff --git a/backgroundConicGradient.go b/backgroundConicGradient.go index 31bbfaf..b52d30b 100644 --- a/backgroundConicGradient.go +++ b/backgroundConicGradient.go @@ -12,16 +12,16 @@ type backgroundConicGradient struct { type BackgroundGradientAngle struct { // Color - the color of the key angle. Must not be nil. // Can take a value of Color type or string (color constant or textual description of the color) - Color interface{} + Color any // Angle - the key angle. Optional (may be nil). // Can take a value of AngleUnit type or string (angle constant or textual description of the angle) - Angle interface{} + Angle any } // NewBackgroundConicGradient creates the new background conic gradient func NewBackgroundConicGradient(params Params) BackgroundElement { result := new(backgroundConicGradient) - result.properties = map[string]interface{}{} + result.properties = map[string]any{} for tag, value := range params { result.Set(tag, value) } @@ -139,7 +139,7 @@ func (gradient *backgroundConicGradient) normalizeTag(tag string) string { return tag } -func (gradient *backgroundConicGradient) Set(tag string, value interface{}) bool { +func (gradient *backgroundConicGradient) Set(tag string, value any) bool { tag = gradient.normalizeTag(tag) switch tag { case CenterX, CenterY, Repeating, From: @@ -153,7 +153,7 @@ func (gradient *backgroundConicGradient) Set(tag string, value interface{}) bool return false } -func (gradient *backgroundConicGradient) stringToAngle(text string) (interface{}, bool) { +func (gradient *backgroundConicGradient) stringToAngle(text string) (any, bool) { if text == "" { return nil, false } else if text[0] == '@' { @@ -216,7 +216,7 @@ func (gradient *backgroundConicGradient) parseGradientText(value string) []Backg return vector } -func (gradient *backgroundConicGradient) setGradient(value interface{}) bool { +func (gradient *backgroundConicGradient) setGradient(value any) bool { if value == nil { delete(gradient.properties, Gradient) return true @@ -262,7 +262,7 @@ func (gradient *backgroundConicGradient) setGradient(value interface{}) bool { return false } -func (gradient *backgroundConicGradient) Get(tag string) interface{} { +func (gradient *backgroundConicGradient) Get(tag string) any { return gradient.backgroundElement.Get(gradient.normalizeTag(tag)) } diff --git a/backgroundGradient.go b/backgroundGradient.go index 08a8328..d7b5eee 100644 --- a/backgroundGradient.go +++ b/backgroundGradient.go @@ -50,10 +50,10 @@ const ( type BackgroundGradientPoint struct { // Color - the color of the point. Must not be nil. // Can take a value of Color type or string (color constant or textual description of the color) - Color interface{} + Color any // Pos - the distance from the start of the gradient straight line. Optional (may be nil). // Can take a value of SizeUnit type or string (angle constant or textual description of the SizeUnit) - Pos interface{} + Pos any } type backgroundGradient struct { @@ -71,7 +71,7 @@ type backgroundRadialGradient struct { // NewBackgroundLinearGradient creates the new background linear gradient func NewBackgroundLinearGradient(params Params) BackgroundElement { result := new(backgroundLinearGradient) - result.properties = map[string]interface{}{} + result.properties = map[string]any{} for tag, value := range params { result.Set(tag, value) } @@ -81,7 +81,7 @@ func NewBackgroundLinearGradient(params Params) BackgroundElement { // NewBackgroundRadialGradient creates the new background radial gradient func NewBackgroundRadialGradient(params Params) BackgroundElement { result := new(backgroundRadialGradient) - result.properties = map[string]interface{}{} + result.properties = map[string]any{} for tag, value := range params { result.Set(tag, value) } @@ -106,7 +106,7 @@ func (gradient *backgroundGradient) parseGradientText(value string) []Background return points } -func (gradient *backgroundGradient) Set(tag string, value interface{}) bool { +func (gradient *backgroundGradient) Set(tag string, value any) bool { switch tag = strings.ToLower(tag); tag { case Repeating: @@ -296,7 +296,7 @@ func (image *backgroundLinearGradient) Clone() BackgroundElement { return result } -func (gradient *backgroundLinearGradient) Set(tag string, value interface{}) bool { +func (gradient *backgroundLinearGradient) Set(tag string, value any) bool { if strings.ToLower(tag) == Direction { switch value := value.(type) { case AngleUnit: @@ -402,7 +402,7 @@ func (gradient *backgroundRadialGradient) normalizeTag(tag string) string { return tag } -func (gradient *backgroundRadialGradient) Set(tag string, value interface{}) bool { +func (gradient *backgroundRadialGradient) Set(tag string, value any) bool { tag = gradient.normalizeTag(tag) switch tag { case RadialGradientRadius: @@ -426,7 +426,7 @@ func (gradient *backgroundRadialGradient) Set(tag string, value interface{}) boo return true } - case []interface{}: + case []any: switch len(value) { case 0: delete(gradient.properties, RadialGradientRadius) @@ -477,7 +477,7 @@ func (gradient *backgroundRadialGradient) Set(tag string, value interface{}) boo return gradient.backgroundGradient.Set(tag, value) } -func (gradient *backgroundRadialGradient) Get(tag string) interface{} { +func (gradient *backgroundRadialGradient) Get(tag string) any { return gradient.backgroundGradient.Get(gradient.normalizeTag(tag)) } @@ -557,7 +557,7 @@ func (gradient *backgroundRadialGradient) cssStyle(session Session) string { buffer.WriteString(" ") } - case []interface{}: + case []any: count := len(value) if count > 2 { count = 2 diff --git a/border.go b/border.go index e270c07..29b317d 100644 --- a/border.go +++ b/border.go @@ -64,9 +64,9 @@ type borderProperty struct { propertyList } -func newBorderProperty(value interface{}) BorderProperty { +func newBorderProperty(value any) BorderProperty { border := new(borderProperty) - border.properties = map[string]interface{}{} + border.properties = map[string]any{} if value != nil { switch value := value.(type) { @@ -131,7 +131,7 @@ func newBorderProperty(value interface{}) BorderProperty { // NewBorder creates the new BorderProperty func NewBorder(params Params) BorderProperty { border := new(borderProperty) - border.properties = map[string]interface{}{} + border.properties = map[string]any{} if params != nil { for _, tag := range []string{Style, Width, ColorTag, Left, Right, Top, Bottom, LeftStyle, RightStyle, TopStyle, BottomStyle, @@ -213,7 +213,7 @@ func (border *borderProperty) writeString(buffer *strings.Builder, indent string buffer.WriteString("_{ ") comma := false - write := func(tag string, value interface{}) { + write := func(tag string, value any) { if comma { buffer.WriteString(", ") } @@ -430,7 +430,7 @@ func (border *borderProperty) Remove(tag string) { } } -func (border *borderProperty) Set(tag string, value interface{}) bool { +func (border *borderProperty) Set(tag string, value any) bool { if value == nil { border.Remove(tag) return true @@ -512,7 +512,7 @@ func (border *borderProperty) Set(tag string, value interface{}) bool { return false } -func (border *borderProperty) Get(tag string) interface{} { +func (border *borderProperty) Get(tag string) any { tag = border.normalizeTag(tag) if result, ok := border.properties[tag]; ok { diff --git a/bounds.go b/bounds.go index 6f6626c..ed4ddb2 100644 --- a/bounds.go +++ b/bounds.go @@ -20,7 +20,7 @@ type boundsPropertyData struct { // NewBoundsProperty creates the new BoundsProperty object func NewBoundsProperty(params Params) BoundsProperty { bounds := new(boundsPropertyData) - bounds.properties = map[string]interface{}{} + bounds.properties = map[string]any{} if params != nil { for _, tag := range []string{Top, Right, Bottom, Left} { if value, ok := params[tag]; ok { @@ -79,7 +79,7 @@ func (bounds *boundsPropertyData) Remove(tag string) { bounds.propertyList.Remove(bounds.normalizeTag(tag)) } -func (bounds *boundsPropertyData) Set(tag string, value interface{}) bool { +func (bounds *boundsPropertyData) Set(tag string, value any) bool { if value == nil { bounds.Remove(tag) return true @@ -98,7 +98,7 @@ func (bounds *boundsPropertyData) Set(tag string, value interface{}) bool { return false } -func (bounds *boundsPropertyData) Get(tag string) interface{} { +func (bounds *boundsPropertyData) Get(tag string) any { tag = bounds.normalizeTag(tag) if value, ok := bounds.properties[tag]; ok { return value @@ -228,7 +228,7 @@ func (bounds *Bounds) cssString() string { return builder.finish() } -func (properties *propertyList) setBounds(tag string, value interface{}) bool { +func (properties *propertyList) setBounds(tag string, value any) bool { if !properties.setSimpleProperty(tag, value) { switch value := value.(type) { case string: @@ -340,7 +340,7 @@ func (properties *propertyList) removeBoundsSide(mainTag, sideTag string) { } } -func (properties *propertyList) setBoundsSide(mainTag, sideTag string, value interface{}) bool { +func (properties *propertyList) setBoundsSide(mainTag, sideTag string, value any) bool { bounds := properties.boundsProperty(mainTag) if bounds.Set(sideTag, value) { properties.properties[mainTag] = bounds diff --git a/canvasView.go b/canvasView.go index c251bbf..10a18bb 100644 --- a/canvasView.go +++ b/canvasView.go @@ -63,11 +63,11 @@ func (canvasView *canvasViewData) remove(tag string) { } } -func (canvasView *canvasViewData) Set(tag string, value interface{}) bool { +func (canvasView *canvasViewData) Set(tag string, value any) bool { return canvasView.set(canvasView.normalizeTag(tag), value) } -func (canvasView *canvasViewData) set(tag string, value interface{}) bool { +func (canvasView *canvasViewData) set(tag string, value any) bool { if tag == DrawFunction { if value == nil { canvasView.drawer = nil @@ -85,11 +85,11 @@ func (canvasView *canvasViewData) set(tag string, value interface{}) bool { return canvasView.viewData.set(tag, value) } -func (canvasView *canvasViewData) Get(tag string) interface{} { +func (canvasView *canvasViewData) Get(tag string) any { return canvasView.get(canvasView.normalizeTag(tag)) } -func (canvasView *canvasViewData) get(tag string) interface{} { +func (canvasView *canvasViewData) get(tag string) any { if tag == DrawFunction { return canvasView.drawer } diff --git a/checkbox.go b/checkbox.go index f39291d..0746b1e 100644 --- a/checkbox.go +++ b/checkbox.go @@ -51,7 +51,7 @@ func (button *checkboxData) Focusable() bool { return true } -func (button *checkboxData) Get(tag string) interface{} { +func (button *checkboxData) Get(tag string) any { switch strings.ToLower(tag) { case CheckboxChangedEvent: return button.checkedListeners @@ -60,11 +60,11 @@ func (button *checkboxData) Get(tag string) interface{} { return button.viewsContainerData.Get(tag) } -func (button *checkboxData) Set(tag string, value interface{}) bool { +func (button *checkboxData) Set(tag string, value any) bool { return button.set(tag, value) } -func (button *checkboxData) set(tag string, value interface{}) bool { +func (button *checkboxData) set(tag string, value any) bool { switch tag { case CheckboxChangedEvent: if !button.setChangedListener(value) { @@ -205,7 +205,7 @@ func checkboxKeyListener(view View, event KeyEvent) { } } -func (button *checkboxData) setChangedListener(value interface{}) bool { +func (button *checkboxData) setChangedListener(value any) bool { if value == nil { if len(button.checkedListeners) > 0 { button.checkedListeners = []func(Checkbox, bool){} @@ -239,7 +239,7 @@ func (button *checkboxData) setChangedListener(value interface{}) bool { } button.checkedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(Checkbox, bool), len(value)) for i, val := range value { if val == nil { diff --git a/colorPicker.go b/colorPicker.go index 6dca74b..130a4f8 100644 --- a/colorPicker.go +++ b/colorPicker.go @@ -75,11 +75,11 @@ func (picker *colorPickerData) remove(tag string) { } } -func (picker *colorPickerData) Set(tag string, value interface{}) bool { +func (picker *colorPickerData) Set(tag string, value any) bool { return picker.set(picker.normalizeTag(tag), value) } -func (picker *colorPickerData) set(tag string, value interface{}) bool { +func (picker *colorPickerData) set(tag string, value any) bool { if value == nil { picker.remove(tag) return true @@ -114,7 +114,7 @@ func (picker *colorPickerData) set(tag string, value interface{}) bool { } picker.colorChangedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(ColorPicker, Color), len(value)) for i, val := range value { if val == nil { @@ -166,11 +166,11 @@ func (picker *colorPickerData) colorChanged(oldColor Color) { } } -func (picker *colorPickerData) Get(tag string) interface{} { +func (picker *colorPickerData) Get(tag string) any { return picker.get(picker.normalizeTag(tag)) } -func (picker *colorPickerData) get(tag string) interface{} { +func (picker *colorPickerData) get(tag string) any { switch tag { case ColorChangedEvent: return picker.colorChangedListeners diff --git a/columnLayout.go b/columnLayout.go index 8ef7d35..91a4151 100644 --- a/columnLayout.go +++ b/columnLayout.go @@ -76,7 +76,7 @@ func (columnLayout *columnLayoutData) normalizeTag(tag string) string { return tag } -func (columnLayout *columnLayoutData) Get(tag string) interface{} { +func (columnLayout *columnLayoutData) Get(tag string) any { return columnLayout.get(columnLayout.normalizeTag(tag)) } @@ -97,11 +97,11 @@ func (columnLayout *columnLayoutData) remove(tag string) { } } -func (columnLayout *columnLayoutData) Set(tag string, value interface{}) bool { +func (columnLayout *columnLayoutData) Set(tag string, value any) bool { return columnLayout.set(columnLayout.normalizeTag(tag), value) } -func (columnLayout *columnLayoutData) set(tag string, value interface{}) bool { +func (columnLayout *columnLayoutData) set(tag string, value any) bool { if value == nil { columnLayout.remove(tag) return true diff --git a/columnSeparator.go b/columnSeparator.go index b3d91fa..804269b 100644 --- a/columnSeparator.go +++ b/columnSeparator.go @@ -18,11 +18,11 @@ type columnSeparatorProperty struct { propertyList } -func newColumnSeparatorProperty(value interface{}) ColumnSeparatorProperty { +func newColumnSeparatorProperty(value any) ColumnSeparatorProperty { if value == nil { separator := new(columnSeparatorProperty) - separator.properties = map[string]interface{}{} + separator.properties = map[string]any{} return separator } @@ -32,7 +32,7 @@ func newColumnSeparatorProperty(value interface{}) ColumnSeparatorProperty { case DataObject: separator := new(columnSeparatorProperty) - separator.properties = map[string]interface{}{} + separator.properties = map[string]any{} for _, tag := range []string{Style, Width, ColorTag} { if val, ok := value.PropertyValue(tag); ok && val != "" { separator.set(tag, value) @@ -42,7 +42,7 @@ func newColumnSeparatorProperty(value interface{}) ColumnSeparatorProperty { case ViewBorder: separator := new(columnSeparatorProperty) - separator.properties = map[string]interface{}{ + separator.properties = map[string]any{ Style: value.Style, Width: value.Width, ColorTag: value.Color, @@ -57,7 +57,7 @@ func newColumnSeparatorProperty(value interface{}) ColumnSeparatorProperty { // NewColumnSeparator creates the new ColumnSeparatorProperty func NewColumnSeparator(params Params) ColumnSeparatorProperty { separator := new(columnSeparatorProperty) - separator.properties = map[string]interface{}{} + separator.properties = map[string]any{} if params != nil { for _, tag := range []string{Style, Width, ColorTag} { if value, ok := params[tag]; ok && value != nil { @@ -117,7 +117,7 @@ func (separator *columnSeparatorProperty) Remove(tag string) { } } -func (separator *columnSeparatorProperty) Set(tag string, value interface{}) bool { +func (separator *columnSeparatorProperty) Set(tag string, value any) bool { tag = separator.normalizeTag(tag) if value == nil { @@ -140,7 +140,7 @@ func (separator *columnSeparatorProperty) Set(tag string, value interface{}) boo return false } -func (separator *columnSeparatorProperty) Get(tag string) interface{} { +func (separator *columnSeparatorProperty) Get(tag string) any { tag = separator.normalizeTag(tag) if result, ok := separator.properties[tag]; ok { diff --git a/customView.go b/customView.go index 66b864c..27b93d5 100644 --- a/customView.go +++ b/customView.go @@ -45,26 +45,26 @@ func (customView *CustomViewData) setTag(tag string) { // Get returns a value of the property with name defined by the argument. // The type of return value depends on the property. If the property is not set then nil is returned. -func (customView *CustomViewData) Get(tag string) interface{} { +func (customView *CustomViewData) Get(tag string) any { return customView.superView.Get(tag) } -func (customView *CustomViewData) getRaw(tag string) interface{} { +func (customView *CustomViewData) getRaw(tag string) any { return customView.superView.getRaw(tag) } -func (customView *CustomViewData) setRaw(tag string, value interface{}) { +func (customView *CustomViewData) setRaw(tag string, value any) { customView.superView.setRaw(tag, value) } // Set 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 -func (customView *CustomViewData) Set(tag string, value interface{}) bool { +func (customView *CustomViewData) Set(tag string, value any) bool { return customView.superView.Set(tag, value) } -func (customView *CustomViewData) SetAnimated(tag string, value interface{}, animation Animation) bool { +func (customView *CustomViewData) SetAnimated(tag string, value any, animation Animation) bool { return customView.superView.SetAnimated(tag, value, animation) } diff --git a/datePicker.go b/datePicker.go index 5c1b808..edd8c15 100644 --- a/datePicker.go +++ b/datePicker.go @@ -114,11 +114,11 @@ func (picker *datePickerData) remove(tag string) { picker.propertyChangedEvent(tag) } -func (picker *datePickerData) Set(tag string, value interface{}) bool { +func (picker *datePickerData) Set(tag string, value any) bool { return picker.set(picker.normalizeTag(tag), value) } -func (picker *datePickerData) set(tag string, value interface{}) bool { +func (picker *datePickerData) set(tag string, value any) bool { if value == nil { picker.remove(tag) return true @@ -262,7 +262,7 @@ func (picker *datePickerData) set(tag string, value interface{}) bool { } picker.dateChangedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(DatePicker, time.Time), len(value)) for i, val := range value { if val == nil { @@ -295,11 +295,11 @@ func (picker *datePickerData) set(tag string, value interface{}) bool { return false } -func (picker *datePickerData) Get(tag string) interface{} { +func (picker *datePickerData) Get(tag string) any { return picker.get(picker.normalizeTag(tag)) } -func (picker *datePickerData) get(tag string) interface{} { +func (picker *datePickerData) get(tag string) any { switch tag { case DateChangedEvent: return picker.dateChangedListeners @@ -374,7 +374,7 @@ func (picker *datePickerData) handleCommand(self View, command string, data Data } func getDateProperty(view View, mainTag, shortTag string) (time.Time, bool) { - valueToTime := func(value interface{}) (time.Time, bool) { + valueToTime := func(value any) (time.Time, bool) { if value != nil { switch value := value.(type) { case time.Time: diff --git a/detailsView.go b/detailsView.go index 5748b12..054497f 100644 --- a/detailsView.go +++ b/detailsView.go @@ -68,11 +68,11 @@ func (detailsView *detailsViewData) remove(tag string) { } } -func (detailsView *detailsViewData) Set(tag string, value interface{}) bool { +func (detailsView *detailsViewData) Set(tag string, value any) bool { return detailsView.set(strings.ToLower(tag), value) } -func (detailsView *detailsViewData) set(tag string, value interface{}) bool { +func (detailsView *detailsViewData) set(tag string, value any) bool { if value == nil { detailsView.remove(tag) return true @@ -133,11 +133,11 @@ func (detailsView *detailsViewData) set(tag string, value interface{}) bool { return true } -func (detailsView *detailsViewData) Get(tag string) interface{} { +func (detailsView *detailsViewData) Get(tag string) any { return detailsView.get(strings.ToLower(tag)) } -func (detailsView *detailsViewData) get(tag string) interface{} { +func (detailsView *detailsViewData) get(tag string) any { return detailsView.viewsContainerData.get(tag) } diff --git a/dropDownList.go b/dropDownList.go index 1ded185..470e749 100644 --- a/dropDownList.go +++ b/dropDownList.go @@ -17,7 +17,7 @@ type DropDownList interface { type dropDownListData struct { viewData items []string - disabledItems []interface{} + disabledItems []any dropDownListener []func(DropDownList, int) } @@ -37,7 +37,7 @@ func (list *dropDownListData) Init(session Session) { list.viewData.Init(session) list.tag = "DropDownList" list.items = []string{} - list.disabledItems = []interface{}{} + list.disabledItems = []any{} list.dropDownListener = []func(DropDownList, int){} } @@ -66,7 +66,7 @@ func (list *dropDownListData) remove(tag string) { case DisabledItems: if len(list.disabledItems) > 0 { - list.disabledItems = []interface{}{} + list.disabledItems = []any{} if list.created { updateInnerHTML(list.htmlID(), list.session) } @@ -95,11 +95,11 @@ func (list *dropDownListData) remove(tag string) { } } -func (list *dropDownListData) Set(tag string, value interface{}) bool { +func (list *dropDownListData) Set(tag string, value any) bool { return list.set(strings.ToLower(tag), value) } -func (list *dropDownListData) set(tag string, value interface{}) bool { +func (list *dropDownListData) set(tag string, value any) bool { if value == nil { list.remove(tag) return true @@ -133,7 +133,7 @@ func (list *dropDownListData) set(tag string, value interface{}) bool { return list.viewData.set(tag, value) } -func (list *dropDownListData) setItems(value interface{}) bool { +func (list *dropDownListData) setItems(value any) bool { switch value := value.(type) { case string: list.items = []string{value} @@ -155,7 +155,7 @@ func (list *dropDownListData) setItems(value interface{}) bool { list.items[i] = str.String() } - case []interface{}: + case []any: items := make([]string, 0, len(value)) for _, v := range value { switch val := v.(type) { @@ -206,16 +206,16 @@ func (list *dropDownListData) setItems(value interface{}) bool { return true } -func (list *dropDownListData) setDisabledItems(value interface{}) bool { +func (list *dropDownListData) setDisabledItems(value any) bool { switch value := value.(type) { case []int: - list.disabledItems = make([]interface{}, len(value)) + list.disabledItems = make([]any, len(value)) for i, n := range value { list.disabledItems[i] = n } - case []interface{}: - disabledItems := make([]interface{}, len(value)) + case []any: + disabledItems := make([]any, len(value)) for i, val := range value { if val == nil { notCompatibleType(DisabledItems, value) @@ -248,7 +248,7 @@ func (list *dropDownListData) setDisabledItems(value interface{}) bool { case string: values := strings.Split(value, ",") - disabledItems := make([]interface{}, len(values)) + disabledItems := make([]any, len(values)) for i, str := range values { str = strings.Trim(str, " ") if str == "" { @@ -291,7 +291,7 @@ func (list *dropDownListData) setDisabledItems(value interface{}) bool { } -func (list *dropDownListData) setDropDownListener(value interface{}) bool { +func (list *dropDownListData) setDropDownListener(value any) bool { switch value := value.(type) { case func(DropDownList, int): list.dropDownListener = []func(DropDownList, int){value} @@ -317,7 +317,7 @@ func (list *dropDownListData) setDropDownListener(value interface{}) bool { } list.dropDownListener = listeners - case []interface{}: + case []any: listeners := make([]func(DropDownList, int), len(value)) for i, val := range value { if val == nil { @@ -349,11 +349,11 @@ func (list *dropDownListData) setDropDownListener(value interface{}) bool { return true } -func (list *dropDownListData) Get(tag string) interface{} { +func (list *dropDownListData) Get(tag string) any { return list.get(strings.ToLower(tag)) } -func (list *dropDownListData) get(tag string) interface{} { +func (list *dropDownListData) get(tag string) any { switch tag { case Items: return list.items @@ -479,7 +479,7 @@ func GetDropDownDisabledItems(view View, subviewID string) []int { } if view != nil { if value := view.Get(DisabledItems); value != nil { - if values, ok := value.([]interface{}); ok { + if values, ok := value.([]any); ok { count := len(values) if count > 0 { result := make([]int, 0, count) diff --git a/editView.go b/editView.go index 362d256..a33678c 100644 --- a/editView.go +++ b/editView.go @@ -190,11 +190,11 @@ func (edit *editViewData) remove(tag string) { } } -func (edit *editViewData) Set(tag string, value interface{}) bool { +func (edit *editViewData) Set(tag string, value any) bool { return edit.set(edit.normalizeTag(tag), value) } -func (edit *editViewData) set(tag string, value interface{}) bool { +func (edit *editViewData) set(tag string, value any) bool { if value == nil { edit.remove(tag) return true @@ -344,7 +344,7 @@ func (edit *editViewData) set(tag string, value interface{}) bool { return edit.viewData.set(tag, value) } -func (edit *editViewData) setChangeListeners(value interface{}) bool { +func (edit *editViewData) setChangeListeners(value any) bool { switch value := value.(type) { case func(EditView, string): edit.textChangeListeners = []func(EditView, string){value} @@ -370,7 +370,7 @@ func (edit *editViewData) setChangeListeners(value interface{}) bool { } edit.textChangeListeners = listeners - case []interface{}: + case []any: listeners := make([]func(EditView, string), len(value)) for i, v := range value { if v == nil { @@ -397,11 +397,11 @@ func (edit *editViewData) setChangeListeners(value interface{}) bool { return true } -func (edit *editViewData) Get(tag string) interface{} { +func (edit *editViewData) Get(tag string) any { return edit.get(edit.normalizeTag(tag)) } -func (edit *editViewData) get(tag string) interface{} { +func (edit *editViewData) get(tag string) any { return edit.viewData.get(tag) } diff --git a/filePicker.go b/filePicker.go index 980295f..97fea43 100644 --- a/filePicker.go +++ b/filePicker.go @@ -139,11 +139,11 @@ func (picker *filePickerData) remove(tag string) { } } -func (picker *filePickerData) Set(tag string, value interface{}) bool { +func (picker *filePickerData) Set(tag string, value any) bool { return picker.set(strings.ToLower(tag), value) } -func (picker *filePickerData) set(tag string, value interface{}) bool { +func (picker *filePickerData) set(tag string, value any) bool { if value == nil { picker.remove(tag) return true @@ -178,7 +178,7 @@ func (picker *filePickerData) set(tag string, value interface{}) bool { } picker.fileSelectedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(FilePicker, []FileInfo), len(value)) for i, val := range value { if val == nil { diff --git a/focusEvents.go b/focusEvents.go index 025c702..c40f7a6 100644 --- a/focusEvents.go +++ b/focusEvents.go @@ -20,7 +20,7 @@ const ( LostFocusEvent = "lost-focus-event" ) -func valueToFocusListeners(value interface{}) ([]func(View), bool) { +func valueToFocusListeners(value any) ([]func(View), bool) { if value == nil { return nil, true } @@ -62,7 +62,7 @@ func valueToFocusListeners(value interface{}) ([]func(View), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -96,7 +96,7 @@ var focusEvents = map[string]struct{ jsEvent, jsFunc string }{ LostFocusEvent: {jsEvent: "onblur", jsFunc: "blurEvent"}, } -func (view *viewData) setFocusListener(tag string, value interface{}) bool { +func (view *viewData) setFocusListener(tag string, value any) bool { listeners, ok := valueToFocusListeners(value) if !ok { notCompatibleType(tag, value) diff --git a/go.mod b/go.mod index ff93f55..4ad2028 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/anoshenko/rui -go 1.17 +go 1.18 require github.com/gorilla/websocket v1.5.0 diff --git a/gridLayout.go b/gridLayout.go index 3de52bf..c4e12d7 100644 --- a/gridLayout.go +++ b/gridLayout.go @@ -37,11 +37,11 @@ func (gridLayout *gridLayoutData) String() string { return getViewString(gridLayout) } -func (style *viewStyle) setGridCellSize(tag string, value interface{}) bool { +func (style *viewStyle) setGridCellSize(tag string, value any) bool { setValues := func(values []string) bool { count := len(values) if count > 1 { - sizes := make([]interface{}, count) + sizes := make([]any, count) for i, val := range values { val = strings.Trim(val, " \t\n\r") if isConstantName(val) { @@ -99,13 +99,13 @@ func (style *viewStyle) setGridCellSize(tag string, value interface{}) bool { return false } - case []interface{}: + case []any: count := len(value) if count == 0 { invalidPropertyValue(tag, value) return false } - sizes := make([]interface{}, count) + sizes := make([]any, count) for i, val := range value { switch val := val.(type) { case SizeUnit: @@ -195,11 +195,11 @@ func (gridLayout *gridLayoutData) normalizeTag(tag string) string { return tag } -func (gridLayout *gridLayoutData) Get(tag string) interface{} { +func (gridLayout *gridLayoutData) Get(tag string) any { return gridLayout.get(gridLayout.normalizeTag(tag)) } -func (gridLayout *gridLayoutData) get(tag string) interface{} { +func (gridLayout *gridLayoutData) get(tag string) any { if tag == Gap { rowGap := GetGridRowGap(gridLayout, "") columnGap := GetGridColumnGap(gridLayout, "") @@ -239,11 +239,11 @@ func (gridLayout *gridLayoutData) remove(tag string) { } } -func (gridLayout *gridLayoutData) Set(tag string, value interface{}) bool { +func (gridLayout *gridLayoutData) Set(tag string, value any) bool { return gridLayout.set(gridLayout.normalizeTag(tag), value) } -func (gridLayout *gridLayoutData) set(tag string, value interface{}) bool { +func (gridLayout *gridLayoutData) set(tag string, value any) bool { if value == nil { gridLayout.remove(tag) return true @@ -285,7 +285,7 @@ func gridCellSizes(properties Properties, tag string, session Session) []SizeUni case SizeUnit: return []SizeUnit{value} - case []interface{}: + case []any: result := make([]SizeUnit, len(value)) for i, val := range value { result[i] = AutoSize() diff --git a/imageView.go b/imageView.go index 79bfbac..4d63e57 100644 --- a/imageView.go +++ b/imageView.go @@ -114,11 +114,11 @@ func (imageView *imageViewData) remove(tag string) { } } -func (imageView *imageViewData) Set(tag string, value interface{}) bool { +func (imageView *imageViewData) Set(tag string, value any) bool { return imageView.set(imageView.normalizeTag(tag), value) } -func valueToImageListeners(value interface{}) ([]func(ImageView), bool) { +func valueToImageListeners(value any) ([]func(ImageView), bool) { if value == nil { return nil, true } @@ -160,7 +160,7 @@ func valueToImageListeners(value interface{}) ([]func(ImageView), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -189,7 +189,7 @@ func valueToImageListeners(value interface{}) ([]func(ImageView), bool) { return nil, false } -func (imageView *imageViewData) set(tag string, value interface{}) bool { +func (imageView *imageViewData) set(tag string, value any) bool { if value == nil { imageView.remove(tag) return true @@ -248,7 +248,7 @@ func (imageView *imageViewData) set(tag string, value interface{}) bool { return false } -func (imageView *imageViewData) Get(tag string) interface{} { +func (imageView *imageViewData) Get(tag string) any { return imageView.viewData.get(imageView.normalizeTag(tag)) } diff --git a/keyEvents.go b/keyEvents.go index 1c11f47..acf2602 100644 --- a/keyEvents.go +++ b/keyEvents.go @@ -50,7 +50,7 @@ type KeyEvent struct { MetaKey bool } -func valueToKeyListeners(value interface{}) ([]func(View, KeyEvent), bool) { +func valueToKeyListeners(value any) ([]func(View, KeyEvent), bool) { if value == nil { return nil, true } @@ -136,7 +136,7 @@ func valueToKeyListeners(value interface{}) ([]func(View, KeyEvent), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -180,7 +180,7 @@ var keyEvents = map[string]struct{ jsEvent, jsFunc string }{ KeyUpEvent: {jsEvent: "onkeyup", jsFunc: "keyUpEvent"}, } -func (view *viewData) setKeyListener(tag string, value interface{}) bool { +func (view *viewData) setKeyListener(tag string, value any) bool { listeners, ok := valueToKeyListeners(value) if !ok { notCompatibleType(tag, value) diff --git a/listLayout.go b/listLayout.go index 29f47bb..983421f 100644 --- a/listLayout.go +++ b/listLayout.go @@ -62,7 +62,7 @@ func (listLayout *listLayoutData) normalizeTag(tag string) string { return tag } -func (listLayout *listLayoutData) Get(tag string) interface{} { +func (listLayout *listLayoutData) Get(tag string) any { return listLayout.get(listLayout.normalizeTag(tag)) } @@ -80,11 +80,11 @@ func (listLayout *listLayoutData) remove(tag string) { } } -func (listLayout *listLayoutData) Set(tag string, value interface{}) bool { +func (listLayout *listLayoutData) Set(tag string, value any) bool { return listLayout.set(listLayout.normalizeTag(tag), value) } -func (listLayout *listLayoutData) set(tag string, value interface{}) bool { +func (listLayout *listLayoutData) set(tag string, value any) bool { if value == nil { listLayout.remove(tag) return true diff --git a/listView.go b/listView.go index f8206bd..3ad0d24 100644 --- a/listView.go +++ b/listView.go @@ -193,11 +193,11 @@ func (listView *listViewData) remove(tag string) { } } -func (listView *listViewData) Set(tag string, value interface{}) bool { +func (listView *listViewData) Set(tag string, value any) bool { return listView.set(listView.normalizeTag(tag), value) } -func (listView *listViewData) set(tag string, value interface{}) bool { +func (listView *listViewData) set(tag string, value any) bool { if value == nil { listView.remove(tag) return true @@ -288,7 +288,7 @@ func (listView *listViewData) set(tag string, value interface{}) bool { return true } -func (listView *listViewData) setItemCheckedEvent(value interface{}) bool { +func (listView *listViewData) setItemCheckedEvent(value any) bool { switch value := value.(type) { case func(ListView, []int): listView.checkedListeners = []func(ListView, []int){value} @@ -316,7 +316,7 @@ func (listView *listViewData) setItemCheckedEvent(value interface{}) bool { } listView.checkedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(ListView, []int), len(value)) for i, val := range value { if val == nil { @@ -343,11 +343,11 @@ func (listView *listViewData) setItemCheckedEvent(value interface{}) bool { return true } -func (listView *listViewData) Get(tag string) interface{} { +func (listView *listViewData) Get(tag string) any { return listView.get(listView.normalizeTag(tag)) } -func (listView *listViewData) get(tag string) interface{} { +func (listView *listViewData) get(tag string) any { switch tag { case ListItemClickedEvent: return listView.clickedListeners @@ -376,7 +376,7 @@ func (listView *listViewData) get(tag string) interface{} { return listView.viewData.get(tag) } -func (listView *listViewData) setItems(value interface{}) bool { +func (listView *listViewData) setItems(value any) bool { switch value := value.(type) { case []string: listView.adapter = NewTextListAdapter(value, nil) @@ -412,7 +412,7 @@ func (listView *listViewData) setItems(value interface{}) bool { listView.adapter = NewTextListAdapter(items, nil) } - case []interface{}: + case []any: items := make([]View, len(value)) for i, val := range value { switch value := val.(type) { @@ -460,7 +460,7 @@ func (listView *listViewData) setItems(value interface{}) bool { return true } -func (listView *listViewData) valueToItemListeners(value interface{}) []func(ListView, int) { +func (listView *listViewData) valueToItemListeners(value any) []func(ListView, int) { if value == nil { return []func(ListView, int){} } @@ -490,7 +490,7 @@ func (listView *listViewData) valueToItemListeners(value interface{}) []func(Lis } return listeners - case []interface{}: + case []any: listeners := make([]func(ListView, int), len(value)) for i, val := range value { if val == nil { @@ -515,7 +515,7 @@ func (listView *listViewData) valueToItemListeners(value interface{}) []func(Lis return nil } -func (listView *listViewData) setChecked(value interface{}) bool { +func (listView *listViewData) setChecked(value any) bool { var checked []int if value == nil { checked = []int{} diff --git a/mediaPlayer.go b/mediaPlayer.go index 80b55a2..2b84d75 100644 --- a/mediaPlayer.go +++ b/mediaPlayer.go @@ -185,11 +185,11 @@ func (player *mediaPlayerData) remove(tag string) { player.propertyChanged(tag) } -func (player *mediaPlayerData) Set(tag string, value interface{}) bool { +func (player *mediaPlayerData) Set(tag string, value any) bool { return player.set(strings.ToLower(tag), value) } -func (player *mediaPlayerData) set(tag string, value interface{}) bool { +func (player *mediaPlayerData) set(tag string, value any) bool { if value == nil { player.remove(tag) return true @@ -257,7 +257,7 @@ func (player *mediaPlayerData) set(tag string, value interface{}) bool { return false } -func (player *mediaPlayerData) setSource(value interface{}) bool { +func (player *mediaPlayerData) setSource(value any) bool { switch value := value.(type) { case string: src := MediaSource{Url: value, MimeType: ""} @@ -311,7 +311,7 @@ func (player *mediaPlayerData) setSource(value interface{}) bool { return true } -func valueToPlayerListeners(value interface{}) ([]func(MediaPlayer), bool) { +func valueToPlayerListeners(value any) ([]func(MediaPlayer), bool) { if value == nil { return nil, true } @@ -353,7 +353,7 @@ func valueToPlayerListeners(value interface{}) ([]func(MediaPlayer), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -382,7 +382,7 @@ func valueToPlayerListeners(value interface{}) ([]func(MediaPlayer), bool) { return nil, false } -func valueToPlayerTimeListeners(value interface{}) ([]func(MediaPlayer, float64), bool) { +func valueToPlayerTimeListeners(value any) ([]func(MediaPlayer, float64), bool) { if value == nil { return nil, true } @@ -468,7 +468,7 @@ func valueToPlayerTimeListeners(value interface{}) ([]func(MediaPlayer, float64) } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -507,7 +507,7 @@ func valueToPlayerTimeListeners(value interface{}) ([]func(MediaPlayer, float64) return nil, false } -func valueToPlayerErrorListeners(value interface{}) ([]func(MediaPlayer, int, string), bool) { +func valueToPlayerErrorListeners(value any) ([]func(MediaPlayer, int, string), bool) { if value == nil { return nil, true } @@ -593,7 +593,7 @@ func valueToPlayerErrorListeners(value interface{}) ([]func(MediaPlayer, int, st } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true diff --git a/mouseEvents.go b/mouseEvents.go index e9ae3a6..a4905fb 100644 --- a/mouseEvents.go +++ b/mouseEvents.go @@ -144,7 +144,7 @@ type MouseEvent struct { MetaKey bool } -func valueToMouseListeners(value interface{}) ([]func(View, MouseEvent), bool) { +func valueToMouseListeners(value any) ([]func(View, MouseEvent), bool) { if value == nil { return nil, true } @@ -230,7 +230,7 @@ func valueToMouseListeners(value interface{}) ([]func(View, MouseEvent), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -280,7 +280,7 @@ var mouseEvents = map[string]struct{ jsEvent, jsFunc string }{ ContextMenuEvent: {jsEvent: "oncontextmenu", jsFunc: "contextMenuEvent"}, } -func (view *viewData) setMouseListener(tag string, value interface{}) bool { +func (view *viewData) setMouseListener(tag string, value any) bool { listeners, ok := valueToMouseListeners(value) if !ok { notCompatibleType(tag, value) diff --git a/numberPicker.go b/numberPicker.go index a44f60a..6b47a3f 100644 --- a/numberPicker.go +++ b/numberPicker.go @@ -87,11 +87,11 @@ func (picker *numberPickerData) remove(tag string) { } } -func (picker *numberPickerData) Set(tag string, value interface{}) bool { +func (picker *numberPickerData) Set(tag string, value any) bool { return picker.set(picker.normalizeTag(tag), value) } -func (picker *numberPickerData) set(tag string, value interface{}) bool { +func (picker *numberPickerData) set(tag string, value any) bool { if value == nil { picker.remove(tag) return true @@ -126,7 +126,7 @@ func (picker *numberPickerData) set(tag string, value interface{}) bool { } picker.numberChangedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(NumberPicker, float64), len(value)) for i, val := range value { if val == nil { @@ -208,11 +208,11 @@ func (picker *numberPickerData) propertyChanged(tag string) { } } -func (picker *numberPickerData) Get(tag string) interface{} { +func (picker *numberPickerData) Get(tag string) any { return picker.get(picker.normalizeTag(tag)) } -func (picker *numberPickerData) get(tag string) interface{} { +func (picker *numberPickerData) get(tag string) any { switch tag { case NumberChangedEvent: return picker.numberChangedListeners diff --git a/outline.go b/outline.go index 939abc7..ea2ac95 100644 --- a/outline.go +++ b/outline.go @@ -18,7 +18,7 @@ type outlinePropertyData struct { func NewOutlineProperty(params Params) OutlineProperty { outline := new(outlinePropertyData) - outline.properties = map[string]interface{}{} + outline.properties = map[string]any{} for tag, value := range params { outline.Set(tag, value) } @@ -55,7 +55,7 @@ func (outline *outlinePropertyData) Remove(tag string) { delete(outline.properties, outline.normalizeTag(tag)) } -func (outline *outlinePropertyData) Set(tag string, value interface{}) bool { +func (outline *outlinePropertyData) Set(tag string, value any) bool { if value == nil { outline.Remove(tag) return true @@ -85,7 +85,7 @@ func (outline *outlinePropertyData) Set(tag string, value interface{}) bool { return false } -func (outline *outlinePropertyData) Get(tag string) interface{} { +func (outline *outlinePropertyData) Get(tag string) any { return outline.propertyList.Get(outline.normalizeTag(tag)) } @@ -128,7 +128,7 @@ func getOutline(properties Properties) OutlineProperty { return nil } -func (style *viewStyle) setOutline(value interface{}) bool { +func (style *viewStyle) setOutline(value any) bool { switch value := value.(type) { case OutlineProperty: style.properties[Outline] = value diff --git a/params.go b/params.go index dceca0f..b52b8d9 100644 --- a/params.go +++ b/params.go @@ -3,25 +3,25 @@ package rui import "sort" // Params defines a type of a parameters list -type Params map[string]interface{} +type Params map[string]any -func (params Params) Get(tag string) interface{} { +func (params Params) Get(tag string) any { return params.getRaw(tag) } -func (params Params) getRaw(tag string) interface{} { +func (params Params) getRaw(tag string) any { if value, ok := params[tag]; ok { return value } return nil } -func (params Params) Set(tag string, value interface{}) bool { +func (params Params) Set(tag string, value any) bool { params.setRaw(tag, value) return true } -func (params Params) setRaw(tag string, value interface{}) { +func (params Params) setRaw(tag string, value any) { if value != nil { params[tag] = value } else { diff --git a/pointerEvents.go b/pointerEvents.go index e0f78db..6d84909 100644 --- a/pointerEvents.go +++ b/pointerEvents.go @@ -87,7 +87,7 @@ type PointerEvent struct { IsPrimary bool } -func valueToPointerListeners(value interface{}) ([]func(View, PointerEvent), bool) { +func valueToPointerListeners(value any) ([]func(View, PointerEvent), bool) { if value == nil { return nil, true } @@ -173,7 +173,7 @@ func valueToPointerListeners(value interface{}) ([]func(View, PointerEvent), boo } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -221,7 +221,7 @@ var pointerEvents = map[string]struct{ jsEvent, jsFunc string }{ PointerOver: {jsEvent: "onpointerover", jsFunc: "pointerOverEvent"}, } -func (view *viewData) setPointerListener(tag string, value interface{}) bool { +func (view *viewData) setPointerListener(tag string, value any) bool { listeners, ok := valueToPointerListeners(value) if !ok { notCompatibleType(tag, value) diff --git a/popup.go b/popup.go index 9f0177f..d177d34 100644 --- a/popup.go +++ b/popup.go @@ -102,7 +102,7 @@ func (popup *popupData) init(view View, params Params) { } } - case []interface{}: + case []any: for _, val := range value { if val != nil { switch fn := val.(type) { diff --git a/progressBar.go b/progressBar.go index 9ee5347..a4d20ce 100644 --- a/progressBar.go +++ b/progressBar.go @@ -73,11 +73,11 @@ func (progress *progressBarData) propertyChanged(tag string) { } } -func (progress *progressBarData) Set(tag string, value interface{}) bool { +func (progress *progressBarData) Set(tag string, value any) bool { return progress.set(progress.normalizeTag(tag), value) } -func (progress *progressBarData) set(tag string, value interface{}) bool { +func (progress *progressBarData) set(tag string, value any) bool { if progress.viewData.set(tag, value) { progress.propertyChanged(tag) return true @@ -85,7 +85,7 @@ func (progress *progressBarData) set(tag string, value interface{}) bool { return false } -func (progress *progressBarData) Get(tag string) interface{} { +func (progress *progressBarData) Get(tag string) any { return progress.get(progress.normalizeTag(tag)) } diff --git a/properties.go b/properties.go index 1b27e80..a53ef8e 100644 --- a/properties.go +++ b/properties.go @@ -9,13 +9,13 @@ import ( type Properties interface { // Get returns a value of the property with name defined by the argument. // The type of return value depends on the property. If the property is not set then nil is returned. - Get(tag string) interface{} - getRaw(tag string) interface{} + Get(tag string) any + getRaw(tag string) any // Set 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 - Set(tag string, value interface{}) bool - setRaw(tag string, value interface{}) + Set(tag string, value any) bool + setRaw(tag string, value any) // Remove removes the property with name defined by the argument Remove(tag string) // Clear removes all properties @@ -25,25 +25,25 @@ type Properties interface { } type propertyList struct { - properties map[string]interface{} + properties map[string]any } func (properties *propertyList) init() { - properties.properties = map[string]interface{}{} + properties.properties = map[string]any{} } -func (properties *propertyList) Get(tag string) interface{} { +func (properties *propertyList) Get(tag string) any { return properties.getRaw(strings.ToLower(tag)) } -func (properties *propertyList) getRaw(tag string) interface{} { +func (properties *propertyList) getRaw(tag string) any { if value, ok := properties.properties[tag]; ok { return value } return nil } -func (properties *propertyList) setRaw(tag string, value interface{}) { +func (properties *propertyList) setRaw(tag string, value any) { properties.properties[tag] = value } @@ -56,7 +56,7 @@ func (properties *propertyList) remove(tag string) { } func (properties *propertyList) Clear() { - properties.properties = map[string]interface{}{} + properties.properties = map[string]any{} } func (properties *propertyList) AllTags() []string { diff --git a/properties_test.go b/properties_test.go index 3de1304..840e04d 100644 --- a/properties_test.go +++ b/properties_test.go @@ -32,49 +32,49 @@ func TestProperties(t *testing.T) { t.Error(`list.Get("name") is not string`) } - sizeValues := []interface{}{"@small", "auto", "10px", Pt(20), AutoSize()} + sizeValues := []any{"@small", "auto", "10px", Pt(20), AutoSize()} for _, value := range sizeValues { if !list.setSizeProperty("size", value) { t.Errorf(`setSizeProperty("size", %v) fail`, value) } } - failSizeValues := []interface{}{"@small,big", "abc", "10", Color(20), 100} + failSizeValues := []any{"@small,big", "abc", "10", Color(20), 100} for _, value := range failSizeValues { if list.setSizeProperty("size", value) { t.Errorf(`setSizeProperty("size", %v) success`, value) } } - angleValues := []interface{}{"@angle", "2pi", "π", "3deg", "60°", Rad(1.5), Deg(45), 1, 1.5} + angleValues := []any{"@angle", "2pi", "π", "3deg", "60°", Rad(1.5), Deg(45), 1, 1.5} for _, value := range angleValues { if !list.setAngleProperty("angle", value) { t.Errorf(`setAngleProperty("angle", %v) fail`, value) } } - failAngleValues := []interface{}{"@angle,2", "pi32", "deg", "60°x", Color(0xFFFFFFFF)} + failAngleValues := []any{"@angle,2", "pi32", "deg", "60°x", Color(0xFFFFFFFF)} for _, value := range failAngleValues { if list.setAngleProperty("angle", value) { t.Errorf(`setAngleProperty("angle", %v) success`, value) } } - colorValues := []interface{}{"@color", "#FF234567", "#234567", "rgba(30%, 128, 0.5, .25)", "rgb(30%, 128, 0.5)", Color(0xFFFFFFFF), 0xFFFFFFFF, White} + colorValues := []any{"@color", "#FF234567", "#234567", "rgba(30%, 128, 0.5, .25)", "rgb(30%, 128, 0.5)", Color(0xFFFFFFFF), 0xFFFFFFFF, White} for _, color := range colorValues { if !list.setColorProperty("color", color) { t.Errorf(`list.setColorProperty("color", %v) fail`, color) } } - failColorValues := []interface{}{"@color|2", "#FF234567FF", "#TT234567", "rgba(500%, 128, 10.5, .25)", 10.6} + failColorValues := []any{"@color|2", "#FF234567FF", "#TT234567", "rgba(500%, 128, 10.5, .25)", 10.6} for _, color := range failColorValues { if list.setColorProperty("color", color) { t.Errorf(`list.setColorProperty("color", %v) success`, color) } } - enumValues := []interface{}{"@enum", "inherit", "on", Inherit, 2} + enumValues := []any{"@enum", "inherit", "on", Inherit, 2} inheritOffOn := inheritOffOnValues() for _, value := range enumValues { if !list.setEnumProperty("enum", value, inheritOffOn) { @@ -82,56 +82,56 @@ func TestProperties(t *testing.T) { } } - failEnumValues := []interface{}{"@enum 13", "inherit2", "onn", -1, 10} + failEnumValues := []any{"@enum 13", "inherit2", "onn", -1, 10} for _, value := range failEnumValues { if list.setEnumProperty("enum", value, inheritOffOn) { t.Errorf(`list.setEnumProperty("enum", %v, %v) success`, value, inheritOffOn) } } - boolValues := []interface{}{"@bool", "true", "yes ", "on", " 1", "false", "no", "off", "0", 0, 1, false, true} + boolValues := []any{"@bool", "true", "yes ", "on", " 1", "false", "no", "off", "0", 0, 1, false, true} for _, value := range boolValues { if !list.setBoolProperty("bool", value) { t.Errorf(`list.setBoolProperty("bool", %v) fail`, value) } } - failBoolValues := []interface{}{"@bool,2", "tr", "ys", "10", -1, 10, 0.8} + failBoolValues := []any{"@bool,2", "tr", "ys", "10", -1, 10, 0.8} for _, value := range failBoolValues { if list.setBoolProperty("bool", value) { t.Errorf(`list.setBoolProperty("bool", %v) success`, value) } } - intValues := []interface{}{"@int", " 100", "-10 ", 0, 250} + intValues := []any{"@int", " 100", "-10 ", 0, 250} for _, value := range intValues { if !list.setIntProperty("int", value) { t.Errorf(`list.setIntProperty("int", %v) fail`, value) } } - failIntValues := []interface{}{"@int|10", "100i", "-1.0 ", 0.0} + failIntValues := []any{"@int|10", "100i", "-1.0 ", 0.0} for _, value := range failIntValues { if list.setIntProperty("int", value) { t.Errorf(`list.setIntProperty("int", %v) success`, value) } } - floatValues := []interface{}{"@float", " 100.25", "-1.5e12 ", uint(0), 250, float32(10.2), float64(0)} + floatValues := []any{"@float", " 100.25", "-1.5e12 ", uint(0), 250, float32(10.2), float64(0)} for _, value := range floatValues { if !list.setFloatProperty("float", value) { t.Errorf(`list.setFloatProperty("float", %v) fail`, value) } } - failFloatValues := []interface{}{"@float|2", " 100.25i", "-1.5ee12 ", "abc"} + failFloatValues := []any{"@float|2", " 100.25i", "-1.5ee12 ", "abc"} for _, value := range failFloatValues { if list.setFloatProperty("float", value) { t.Errorf(`list.setFloatProperty("float", %v) success`, value) } } - boundsValues := []interface{}{"@bounds", "10px,20pt,@bottom,0", Em(2), []interface{}{"@top", Px(10), AutoSize(), "14pt"}} + boundsValues := []any{"@bounds", "10px,20pt,@bottom,0", Em(2), []any{"@top", Px(10), AutoSize(), "14pt"}} for _, value := range boundsValues { if !list.setBoundsProperty("margin", value) { t.Errorf(`list.setBoundsProperty("margin", %v) fail`, value) diff --git a/propertyGet.go b/propertyGet.go index 6b102d8..eb51f16 100644 --- a/propertyGet.go +++ b/propertyGet.go @@ -31,7 +31,7 @@ func imageProperty(properties Properties, tag string, session Session) (string, return "", false } -func valueToSizeUnit(value interface{}, session Session) (SizeUnit, bool) { +func valueToSizeUnit(value any, session Session) (SizeUnit, bool) { if value != nil { switch value := value.(type) { case SizeUnit: @@ -67,7 +67,7 @@ func angleProperty(properties Properties, tag string, session Session) (AngleUni return AngleUnit{Type: 0, Value: 0}, false } -func valueToColor(value interface{}, session Session) (Color, bool) { +func valueToColor(value any, session Session) (Color, bool) { if value != nil { switch value := value.(type) { case Color: @@ -88,7 +88,7 @@ func colorProperty(properties Properties, tag string, session Session) (Color, b return valueToColor(properties.getRaw(tag), session) } -func valueToEnum(value interface{}, tag string, session Session, defaultValue int) (int, bool) { +func valueToEnum(value any, tag string, session Session, defaultValue int) (int, bool) { if value != nil { values := enumProperties[tag].values switch value := value.(type) { @@ -155,7 +155,7 @@ func enumProperty(properties Properties, tag string, session Session, defaultVal return valueToEnum(properties.getRaw(tag), tag, session, defaultValue) } -func valueToBool(value interface{}, session Session) (bool, bool) { +func valueToBool(value any, session Session) (bool, bool) { if value != nil { switch value := value.(type) { case bool: @@ -184,7 +184,7 @@ func boolProperty(properties Properties, tag string, session Session) (bool, boo return valueToBool(properties.getRaw(tag), session) } -func valueToInt(value interface{}, session Session, defaultValue int) (int, bool) { +func valueToInt(value any, session Session, defaultValue int) (int, bool) { if value != nil { switch value := value.(type) { case string: @@ -214,7 +214,7 @@ func intProperty(properties Properties, tag string, session Session, defaultValu return valueToInt(properties.getRaw(tag), session, defaultValue) } -func valueToFloat(value interface{}, session Session, defaultValue float64) (float64, bool) { +func valueToFloat(value any, session Session, defaultValue float64) (float64, bool) { if value != nil { switch value := value.(type) { case float64: @@ -238,7 +238,7 @@ func floatProperty(properties Properties, tag string, session Session, defaultVa return valueToFloat(properties.getRaw(tag), session, defaultValue) } -func valueToRange(value interface{}, session Session) (Range, bool) { +func valueToRange(value any, session Session) (Range, bool) { if value != nil { switch value := value.(type) { case Range: diff --git a/propertySet.go b/propertySet.go index ac78adc..8cfa519 100644 --- a/propertySet.go +++ b/propertySet.go @@ -431,11 +431,11 @@ var enumProperties = map[string]struct { }, } -func notCompatibleType(tag string, value interface{}) { +func notCompatibleType(tag string, value any) { ErrorLogF(`"%T" type not compatible with "%s" property`, value, tag) } -func invalidPropertyValue(tag string, value interface{}) { +func invalidPropertyValue(tag string, value any) { ErrorLogF(`Invalid value "%v" of "%s" property`, value, tag) } @@ -457,7 +457,7 @@ func isConstantName(text string) bool { return !strings.ContainsAny(text, ",;|\"'`+(){}[]<>/\\*&%! \t\n\r") } -func isInt(value interface{}) (int, bool) { +func isInt(value any) (int, bool) { var n int switch value := value.(type) { case int: @@ -497,7 +497,7 @@ func isInt(value interface{}) (int, bool) { return n, true } -func (properties *propertyList) setSimpleProperty(tag string, value interface{}) bool { +func (properties *propertyList) setSimpleProperty(tag string, value any) bool { if value == nil { delete(properties.properties, tag) return true @@ -515,7 +515,7 @@ func (properties *propertyList) setSimpleProperty(tag string, value interface{}) return false } -func (properties *propertyList) setSizeProperty(tag string, value interface{}) bool { +func (properties *propertyList) setSizeProperty(tag string, value any) bool { if !properties.setSimpleProperty(tag, value) { var size SizeUnit switch value := value.(type) { @@ -556,7 +556,7 @@ func (properties *propertyList) setSizeProperty(tag string, value interface{}) b return true } -func (properties *propertyList) setAngleProperty(tag string, value interface{}) bool { +func (properties *propertyList) setAngleProperty(tag string, value any) bool { if !properties.setSimpleProperty(tag, value) { var angle AngleUnit switch value := value.(type) { @@ -589,7 +589,7 @@ func (properties *propertyList) setAngleProperty(tag string, value interface{}) return true } -func (properties *propertyList) setColorProperty(tag string, value interface{}) bool { +func (properties *propertyList) setColorProperty(tag string, value any) bool { if !properties.setSimpleProperty(tag, value) { var result Color switch value := value.(type) { @@ -621,7 +621,7 @@ func (properties *propertyList) setColorProperty(tag string, value interface{}) return true } -func (properties *propertyList) setEnumProperty(tag string, value interface{}, values []string) bool { +func (properties *propertyList) setEnumProperty(tag string, value any, values []string) bool { if !properties.setSimpleProperty(tag, value) { var n int if text, ok := value.(string); ok { @@ -646,7 +646,7 @@ func (properties *propertyList) setEnumProperty(tag string, value interface{}, v return true } -func (properties *propertyList) setBoolProperty(tag string, value interface{}) bool { +func (properties *propertyList) setBoolProperty(tag string, value any) bool { if !properties.setSimpleProperty(tag, value) { if text, ok := value.(string); ok { switch strings.ToLower(strings.Trim(text, " \t")) { @@ -683,7 +683,7 @@ func (properties *propertyList) setBoolProperty(tag string, value interface{}) b return true } -func (properties *propertyList) setIntProperty(tag string, value interface{}) bool { +func (properties *propertyList) setIntProperty(tag string, value any) bool { if !properties.setSimpleProperty(tag, value) { if text, ok := value.(string); ok { n, err := strconv.Atoi(strings.Trim(text, " \t")) @@ -704,7 +704,7 @@ func (properties *propertyList) setIntProperty(tag string, value interface{}) bo return true } -func (properties *propertyList) setFloatProperty(tag string, value interface{}, min, max float64) bool { +func (properties *propertyList) setFloatProperty(tag string, value any, min, max float64) bool { if !properties.setSimpleProperty(tag, value) { f := float64(0) switch value := value.(type) { @@ -742,11 +742,11 @@ func (properties *propertyList) setFloatProperty(tag string, value interface{}, return true } -func (properties *propertyList) Set(tag string, value interface{}) bool { +func (properties *propertyList) Set(tag string, value any) bool { return properties.set(strings.ToLower(tag), value) } -func (properties *propertyList) set(tag string, value interface{}) bool { +func (properties *propertyList) set(tag string, value any) bool { if value == nil { delete(properties.properties, tag) return true diff --git a/radius.go b/radius.go index 17674e8..11462e0 100644 --- a/radius.go +++ b/radius.go @@ -109,7 +109,7 @@ type radiusPropertyData struct { // NewRadiusProperty creates the new RadiusProperty func NewRadiusProperty(params Params) RadiusProperty { result := new(radiusPropertyData) - result.properties = map[string]interface{}{} + result.properties = map[string]any{} if params != nil { for _, tag := range []string{X, Y, TopLeft, TopRight, BottomLeft, BottomRight, TopLeftX, TopLeftY, TopRightX, TopRightY, BottomLeftX, BottomLeftY, BottomRightX, BottomRightY} { @@ -172,7 +172,7 @@ func (radius *radiusPropertyData) deleteUnusedTags() { } } - equalValue := func(value1, value2 interface{}) bool { + equalValue := func(value1, value2 any) bool { switch value1 := value1.(type) { case string: switch value2 := value2.(type) { @@ -243,7 +243,7 @@ func (radius *radiusPropertyData) Remove(tag string) { } -func (radius *radiusPropertyData) Set(tag string, value interface{}) bool { +func (radius *radiusPropertyData) Set(tag string, value any) bool { if value == nil { radius.Remove(tag) return true @@ -318,7 +318,7 @@ func (radius *radiusPropertyData) Set(tag string, value interface{}) bool { return false } -func (radius *radiusPropertyData) Get(tag string) interface{} { +func (radius *radiusPropertyData) Get(tag string) any { tag = radius.normalizeTag(tag) if value, ok := radius.properties[tag]; ok { return value @@ -570,7 +570,7 @@ func getRadiusProperty(style Properties) RadiusProperty { return NewRadiusProperty(nil) } -func (properties *propertyList) setRadius(value interface{}) bool { +func (properties *propertyList) setRadius(value any) bool { if value == nil { delete(properties.properties, Radius) @@ -664,7 +664,7 @@ func (properties *propertyList) removeRadiusElement(tag string) { } } -func (properties *propertyList) setRadiusElement(tag string, value interface{}) bool { +func (properties *propertyList) setRadiusElement(tag string, value any) bool { if value == nil { properties.removeRadiusElement(tag) return true @@ -679,7 +679,7 @@ func (properties *propertyList) setRadiusElement(tag string, value interface{}) return false } -func getRadiusElement(style Properties, tag string) interface{} { +func getRadiusElement(style Properties, tag string) any { value := style.Get(Radius) if value != nil { switch value := value.(type) { diff --git a/resizable.go b/resizable.go index d4cb8df..4131ef8 100644 --- a/resizable.go +++ b/resizable.go @@ -108,11 +108,11 @@ func (resizable *resizableData) remove(tag string) { } } -func (resizable *resizableData) Set(tag string, value interface{}) bool { +func (resizable *resizableData) Set(tag string, value any) bool { return resizable.set(strings.ToLower(tag), value) } -func (resizable *resizableData) set(tag string, value interface{}) bool { +func (resizable *resizableData) set(tag string, value any) bool { if value == nil { resizable.remove(tag) return true @@ -183,7 +183,7 @@ func (resizable *resizableData) set(tag string, value interface{}) bool { return resizable.viewData.set(tag, value) } -func (resizable *resizableData) Get(tag string) interface{} { +func (resizable *resizableData) Get(tag string) any { return resizable.get(strings.ToLower(tag)) } @@ -235,7 +235,7 @@ func (resizable *resizableData) getSide() int { return AllSides } -func (resizable *resizableData) setSide(value interface{}) bool { +func (resizable *resizableData) setSide(value any) bool { switch value := value.(type) { case string: if n, err := strconv.Atoi(value); err == nil { diff --git a/resizeEvent.go b/resizeEvent.go index bee0466..5427afb 100644 --- a/resizeEvent.go +++ b/resizeEvent.go @@ -21,7 +21,7 @@ func (view *viewData) onResize(self View, x, y, width, height float64) { func (view *viewData) onItemResize(self View, index string, x, y, width, height float64) { } -func (view *viewData) setFrameListener(tag string, value interface{}) bool { +func (view *viewData) setFrameListener(tag string, value any) bool { if value == nil { delete(view.properties, tag) return true @@ -117,7 +117,7 @@ func (view *viewData) setFrameListener(tag string, value interface{}) bool { } view.properties[tag] = listeners - case []interface{}: + case []any: count := len(value) if count == 0 { delete(view.properties, tag) diff --git a/ruiWriter.go b/ruiWriter.go index bc5471e..7fd47b5 100644 --- a/ruiWriter.go +++ b/ruiWriter.go @@ -13,7 +13,7 @@ type ruiWriter interface { endObject() startArrayProperty(tag string) endObArray() - writeProperty(tag string, value interface{}) + writeProperty(tag string, value any) finish() string } @@ -112,7 +112,7 @@ func (writer *ruiWriterData) endObArray() { writer.buffer.WriteString("],\n") } -func (writer *ruiWriterData) writeValue(value interface{}) { +func (writer *ruiWriterData) writeValue(value any) { switch value := value.(type) { case string: @@ -175,7 +175,7 @@ func (writer *ruiWriterData) writeValue(value interface{}) { writer.buffer.WriteRune(']') } - case []interface{}: + case []any: switch len(value) { case 0: writer.buffer.WriteString("[]\n") @@ -205,7 +205,7 @@ func (writer *ruiWriterData) writeValue(value interface{}) { writer.buffer.WriteString(",\n") } -func (writer *ruiWriterData) writeProperty(tag string, value interface{}) { +func (writer *ruiWriterData) writeProperty(tag string, value any) { writer.writeIndent() writer.writeString(tag) writer.buffer.WriteString(" = ") diff --git a/session.go b/session.go index a85a079..5ec95e5 100644 --- a/session.go +++ b/session.go @@ -59,11 +59,11 @@ type Session interface { RootView() View // Get returns a value of the view (with id defined by the first argument) property with name defined by the second argument. // The type of return value depends on the property. If the property is not set then nil is returned. - Get(viewID, tag string) interface{} + Get(viewID, tag string) any // Set sets the value (third argument) of the property (second argument) of the view with id 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 - Set(viewID, tag string, value interface{}) bool + Set(viewID, tag string, value any) bool // DownloadFile downloads (saves) on the client side the file located at the specified path on the server. DownloadFile(path string) @@ -80,7 +80,7 @@ type Session interface { viewByHTMLID(id string) View nextViewID() string - styleProperty(styleTag, property string) interface{} + styleProperty(styleTag, property string) any setBrige(events chan DataObject, brige WebBrige) writeInitScript(writer *strings.Builder) @@ -219,7 +219,7 @@ func (session *sessionData) close() { } } -func (session *sessionData) styleProperty(styleTag, propertyTag string) interface{} { +func (session *sessionData) styleProperty(styleTag, propertyTag string) any { if style := session.getCurrentTheme().style(styleTag); style != nil { return style.getRaw(propertyTag) } @@ -309,14 +309,14 @@ func (session *sessionData) setIgnoreViewUpdates(ignore bool) { session.ignoreUpdates = ignore } -func (session *sessionData) Get(viewID, tag string) interface{} { +func (session *sessionData) Get(viewID, tag string) any { if view := ViewByID(session.RootView(), viewID); view != nil { return view.Get(tag) } return nil } -func (session *sessionData) Set(viewID, tag string, value interface{}) bool { +func (session *sessionData) Set(viewID, tag string, value any) bool { if view := ViewByID(session.RootView(), viewID); view != nil { return view.Set(tag, value) } diff --git a/shadow.go b/shadow.go index 216f460..5d2825e 100644 --- a/shadow.go +++ b/shadow.go @@ -111,7 +111,7 @@ func (shadow *viewShadowData) Remove(tag string) { delete(shadow.properties, strings.ToLower(tag)) } -func (shadow *viewShadowData) Set(tag string, value interface{}) bool { +func (shadow *viewShadowData) Set(tag string, value any) bool { if value == nil { shadow.Remove(tag) return true @@ -127,7 +127,7 @@ func (shadow *viewShadowData) Set(tag string, value interface{}) bool { return false } -func (shadow *viewShadowData) Get(tag string) interface{} { +func (shadow *viewShadowData) Get(tag string) any { return shadow.propertyList.Get(strings.ToLower(tag)) } @@ -225,7 +225,7 @@ func (shadow *viewShadowData) writeString(buffer *strings.Builder, indent string buffer.WriteString(" }") } -func (properties *propertyList) setShadow(tag string, value interface{}) bool { +func (properties *propertyList) setShadow(tag string, value any) bool { if value == nil { delete(properties.properties, tag) diff --git a/stackLayout.go b/stackLayout.go index 4ecb343..4e1274a 100644 --- a/stackLayout.go +++ b/stackLayout.go @@ -97,11 +97,11 @@ func (layout *stackLayoutData) popFinished(view View, tag string) { } } -func (layout *stackLayoutData) Set(tag string, value interface{}) bool { +func (layout *stackLayoutData) Set(tag string, value any) bool { return layout.set(strings.ToLower(tag), value) } -func (layout *stackLayoutData) set(tag string, value interface{}) bool { +func (layout *stackLayoutData) set(tag string, value any) bool { if value == nil { layout.remove(tag) return true @@ -179,11 +179,11 @@ func (layout *stackLayoutData) remove(tag string) { } } -func (layout *stackLayoutData) Get(tag string) interface{} { +func (layout *stackLayoutData) Get(tag string) any { return layout.get(strings.ToLower(tag)) } -func (layout *stackLayoutData) get(tag string) interface{} { +func (layout *stackLayoutData) get(tag string) any { if tag == Current { return layout.peek } diff --git a/tableAdapter.go b/tableAdapter.go index 4704b20..c3a773f 100644 --- a/tableAdapter.go +++ b/tableAdapter.go @@ -18,7 +18,7 @@ type TableAdapter interface { // * rui.View // * fmt.Stringer // * rui.VerticalTableJoin, rui.HorizontalTableJoin - Cell(row, column int) interface{} + Cell(row, column int) any } // TableColumnStyle describes the style of TableView columns. @@ -59,15 +59,15 @@ type TableAllowRowSelection interface { } // SimpleTableAdapter is implementation of TableAdapter where the content -// defines as [][]interface{}. -// When you assign [][]interface{} value to the "content" property, it is converted to SimpleTableAdapter +// defines as [][]any. +// When you assign [][]any value to the "content" property, it is converted to SimpleTableAdapter type SimpleTableAdapter interface { TableAdapter TableCellStyle } type simpleTableAdapter struct { - content [][]interface{} + content [][]any columnCount int } @@ -94,7 +94,7 @@ type HorizontalTableJoin struct { } // NewSimpleTableAdapter creates the new SimpleTableAdapter -func NewSimpleTableAdapter(content [][]interface{}) SimpleTableAdapter { +func NewSimpleTableAdapter(content [][]any) SimpleTableAdapter { if content == nil { return nil } @@ -125,7 +125,7 @@ func (adapter *simpleTableAdapter) ColumnCount() int { return adapter.columnCount } -func (adapter *simpleTableAdapter) Cell(row, column int) interface{} { +func (adapter *simpleTableAdapter) Cell(row, column int) any { if adapter.content != nil && row >= 0 && row < len(adapter.content) && adapter.content[row] != nil && column >= 0 && column < len(adapter.content[row]) { return adapter.content[row][column] @@ -220,7 +220,7 @@ func (adapter *textTableAdapter) ColumnCount() int { return adapter.columnCount } -func (adapter *textTableAdapter) Cell(row, column int) interface{} { +func (adapter *textTableAdapter) Cell(row, column int) any { if adapter.content != nil && row >= 0 && row < len(adapter.content) && adapter.content[row] != nil && column >= 0 && column < len(adapter.content[row]) { return adapter.content[row][column] @@ -242,7 +242,7 @@ func (style *simpleTableRowStyle) RowStyle(row int) Params { return nil } -func (table *tableViewData) setRowStyle(value interface{}) bool { +func (table *tableViewData) setRowStyle(value any) bool { newSimpleTableRowStyle := func(params []Params) TableRowStyle { if len(params) == 0 { return nil @@ -319,7 +319,7 @@ func (style *simpleTableColumnStyle) ColumnStyle(row int) Params { return nil } -func (table *tableViewData) setColumnStyle(value interface{}) bool { +func (table *tableViewData) setColumnStyle(value any) bool { newSimpleTableColumnStyle := func(params []Params) TableColumnStyle { if len(params) == 0 { return nil diff --git a/tableView.go b/tableView.go index 85b7316..b121e21 100644 --- a/tableView.go +++ b/tableView.go @@ -293,7 +293,7 @@ func (table *tableViewData) Focusable() bool { return GetTableSelectionMode(table, "") != NoneSelection } -func (table *tableViewData) Get(tag string) interface{} { +func (table *tableViewData) Get(tag string) any { return table.get(table.normalizeTag(tag)) } @@ -340,11 +340,11 @@ func (table *tableViewData) remove(tag string) { } } -func (table *tableViewData) Set(tag string, value interface{}) bool { +func (table *tableViewData) Set(tag string, value any) bool { return table.set(table.normalizeTag(tag), value) } -func (table *tableViewData) set(tag string, value interface{}) bool { +func (table *tableViewData) set(tag string, value any) bool { if value == nil { table.remove(tag) return true @@ -356,7 +356,7 @@ func (table *tableViewData) set(tag string, value interface{}) bool { case TableAdapter: table.properties[Content] = value - case [][]interface{}: + case [][]any: table.properties[Content] = NewSimpleTableAdapter(val) case [][]string: @@ -676,7 +676,7 @@ func (table *tableViewData) currentInactiveStyle() string { return "ruiCurrentTableCell" } -func (table *tableViewData) valueToCellListeners(value interface{}) []func(TableView, int, int) { +func (table *tableViewData) valueToCellListeners(value any) []func(TableView, int, int) { if value == nil { return []func(TableView, int, int){} } @@ -706,7 +706,7 @@ func (table *tableViewData) valueToCellListeners(value interface{}) []func(Table } return listeners - case []interface{}: + case []any: listeners := make([]func(TableView, int, int), len(value)) for i, val := range value { if val == nil { @@ -731,7 +731,7 @@ func (table *tableViewData) valueToCellListeners(value interface{}) []func(Table return nil } -func (table *tableViewData) valueToRowListeners(value interface{}) []func(TableView, int) { +func (table *tableViewData) valueToRowListeners(value any) []func(TableView, int) { if value == nil { return []func(TableView, int){} } @@ -761,7 +761,7 @@ func (table *tableViewData) valueToRowListeners(value interface{}) []func(TableV } return listeners - case []interface{}: + case []any: listeners := make([]func(TableView, int), len(value)) for i, val := range value { if val == nil { diff --git a/tableViewUtils.go b/tableViewUtils.go index 73663fe..82257e4 100644 --- a/tableViewUtils.go +++ b/tableViewUtils.go @@ -2,11 +2,11 @@ package rui import "strings" -func (cell *tableCellView) Set(tag string, value interface{}) bool { +func (cell *tableCellView) Set(tag string, value any) bool { return cell.set(strings.ToLower(tag), value) } -func (cell *tableCellView) set(tag string, value interface{}) bool { +func (cell *tableCellView) set(tag string, value any) bool { switch tag { case VerticalAlign: tag = TableVerticalAlign diff --git a/tabsLayout.go b/tabsLayout.go index 3291503..b5a1ff2 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -108,11 +108,11 @@ func (tabsLayout *tabsLayoutData) currentItem(defaultValue int) int { return result } -func (tabsLayout *tabsLayoutData) Get(tag string) interface{} { +func (tabsLayout *tabsLayoutData) Get(tag string) any { return tabsLayout.get(strings.ToLower(tag)) } -func (tabsLayout *tabsLayoutData) get(tag string) interface{} { +func (tabsLayout *tabsLayoutData) get(tag string) any { switch tag { case CurrentTabChangedEvent: return tabsLayout.tabListener @@ -190,11 +190,11 @@ func (tabsLayout *tabsLayoutData) remove(tag string) { tabsLayout.propertyChangedEvent(tag) } -func (tabsLayout *tabsLayoutData) Set(tag string, value interface{}) bool { +func (tabsLayout *tabsLayoutData) Set(tag string, value any) bool { return tabsLayout.set(strings.ToLower(tag), value) } -func (tabsLayout *tabsLayoutData) set(tag string, value interface{}) bool { +func (tabsLayout *tabsLayoutData) set(tag string, value any) bool { if value == nil { tabsLayout.remove(tag) return true @@ -286,7 +286,7 @@ func (tabsLayout *tabsLayoutData) set(tag string, value interface{}) bool { return true } -func (tabsLayout *tabsLayoutData) valueToTabListeners(value interface{}) []func(TabsLayout, int, int) { +func (tabsLayout *tabsLayoutData) valueToTabListeners(value any) []func(TabsLayout, int, int) { if value == nil { return []func(TabsLayout, int, int){} } @@ -388,7 +388,7 @@ func (tabsLayout *tabsLayoutData) valueToTabListeners(value interface{}) []func( } return listeners - case []interface{}: + case []any: listeners := make([]func(TabsLayout, int, int), len(value)) for i, val := range value { if val == nil { @@ -433,7 +433,7 @@ func (tabsLayout *tabsLayoutData) valueToTabListeners(value interface{}) []func( return nil } -func (tabsLayout *tabsLayoutData) valueToCloseListeners(value interface{}) []func(TabsLayout, int) { +func (tabsLayout *tabsLayoutData) valueToCloseListeners(value any) []func(TabsLayout, int) { if value == nil { return []func(TabsLayout, int){} } @@ -463,7 +463,7 @@ func (tabsLayout *tabsLayoutData) valueToCloseListeners(value interface{}) []fun } return listeners - case []interface{}: + case []any: listeners := make([]func(TabsLayout, int), len(value)) for i, val := range value { if val == nil { diff --git a/textView.go b/textView.go index d885d2a..f285922 100644 --- a/textView.go +++ b/textView.go @@ -36,7 +36,7 @@ func (textView *textViewData) String() string { return getViewString(textView) } -func (textView *textViewData) Get(tag string) interface{} { +func (textView *textViewData) Get(tag string) any { return textView.get(strings.ToLower(tag)) } @@ -57,11 +57,11 @@ func (textView *textViewData) remove(tag string) { } } -func (textView *textViewData) Set(tag string, value interface{}) bool { +func (textView *textViewData) Set(tag string, value any) bool { return textView.set(strings.ToLower(tag), value) } -func (textView *textViewData) set(tag string, value interface{}) bool { +func (textView *textViewData) set(tag string, value any) bool { switch tag { case Text: switch value := value.(type) { diff --git a/timePicker.go b/timePicker.go index ace0a60..5edf71e 100644 --- a/timePicker.go +++ b/timePicker.go @@ -114,11 +114,11 @@ func (picker *timePickerData) remove(tag string) { picker.propertyChangedEvent(tag) } -func (picker *timePickerData) Set(tag string, value interface{}) bool { +func (picker *timePickerData) Set(tag string, value any) bool { return picker.set(picker.normalizeTag(tag), value) } -func (picker *timePickerData) set(tag string, value interface{}) bool { +func (picker *timePickerData) set(tag string, value any) bool { if value == nil { picker.remove(tag) return true @@ -250,7 +250,7 @@ func (picker *timePickerData) set(tag string, value interface{}) bool { } picker.timeChangedListeners = listeners - case []interface{}: + case []any: listeners := make([]func(TimePicker, time.Time), len(value)) for i, val := range value { if val == nil { @@ -283,11 +283,11 @@ func (picker *timePickerData) set(tag string, value interface{}) bool { return false } -func (picker *timePickerData) Get(tag string) interface{} { +func (picker *timePickerData) Get(tag string) any { return picker.get(picker.normalizeTag(tag)) } -func (picker *timePickerData) get(tag string) interface{} { +func (picker *timePickerData) get(tag string) any { switch tag { case TimeChangedEvent: return picker.timeChangedListeners @@ -362,7 +362,7 @@ func (picker *timePickerData) handleCommand(self View, command string, data Data } func getTimeProperty(view View, mainTag, shortTag string) (time.Time, bool) { - valueToTime := func(value interface{}) (time.Time, bool) { + valueToTime := func(value any) (time.Time, bool) { if value != nil { switch value := value.(type) { case time.Time: diff --git a/touchEvents.go b/touchEvents.go index bcb3ede..db5c76d 100644 --- a/touchEvents.go +++ b/touchEvents.go @@ -90,7 +90,7 @@ type TouchEvent struct { MetaKey bool } -func valueToTouchListeners(value interface{}) ([]func(View, TouchEvent), bool) { +func valueToTouchListeners(value any) ([]func(View, TouchEvent), bool) { if value == nil { return nil, true } @@ -176,7 +176,7 @@ func valueToTouchListeners(value interface{}) ([]func(View, TouchEvent), bool) { } return listeners, true - case []interface{}: + case []any: count := len(value) if count == 0 { return nil, true @@ -222,7 +222,7 @@ var touchEvents = map[string]struct{ jsEvent, jsFunc string }{ TouchCancel: {jsEvent: "ontouchcancel", jsFunc: "touchCancelEvent"}, } -func (view *viewData) setTouchListener(tag string, value interface{}) bool { +func (view *viewData) setTouchListener(tag string, value any) bool { listeners, ok := valueToTouchListeners(value) if !ok { notCompatibleType(tag, value) diff --git a/videoPlayer.go b/videoPlayer.go index 9fa129b..813997a 100644 --- a/videoPlayer.go +++ b/videoPlayer.go @@ -77,11 +77,11 @@ func (player *videoPlayerData) remove(tag string) { } } -func (player *videoPlayerData) Set(tag string, value interface{}) bool { +func (player *videoPlayerData) Set(tag string, value any) bool { return player.set(strings.ToLower(tag), value) } -func (player *videoPlayerData) set(tag string, value interface{}) bool { +func (player *videoPlayerData) set(tag string, value any) bool { if value == nil { player.remove(tag) return true diff --git a/view.go b/view.go index 070caa9..813dbe0 100644 --- a/view.go +++ b/view.go @@ -54,7 +54,7 @@ type View interface { // 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 - SetAnimated(tag string, value interface{}, animation Animation) bool + SetAnimated(tag string, value any, animation Animation) bool // SetChangeListener set the function to track the change of the View property SetChangeListener(tag string, listener func(View, string)) // HasFocus returns 'true' if the view has focus @@ -290,11 +290,11 @@ func (view *viewData) propertyChangedEvent(tag string) { } -func (view *viewData) Set(tag string, value interface{}) bool { +func (view *viewData) Set(tag string, value any) bool { return view.set(strings.ToLower(tag), value) } -func (view *viewData) set(tag string, value interface{}) bool { +func (view *viewData) set(tag string, value any) bool { if value == nil { view.remove(tag) return true @@ -665,11 +665,11 @@ func viewPropertyChanged(view *viewData, tag string) { } } -func (view *viewData) Get(tag string) interface{} { +func (view *viewData) Get(tag string) any { return view.get(strings.ToLower(tag)) } -func (view *viewData) get(tag string) interface{} { +func (view *viewData) get(tag string) any { if tag == ID { if view.viewID != "" { return view.viewID diff --git a/viewClip.go b/viewClip.go index 0fb37ce..1ed892f 100644 --- a/viewClip.go +++ b/viewClip.go @@ -27,7 +27,7 @@ type circleClip struct { } type polygonClip struct { - points []interface{} + points []any } // InsetClip creates a rectangle View clipping area. @@ -73,9 +73,9 @@ func EllipseClip(x, y, rx, ry SizeUnit) ClipShape { // PolygonClip creates a polygon View clipping area. // The elements of the function argument can be or text constants, // or the text representation of SizeUnit, or elements of SizeUnit type. -func PolygonClip(points []interface{}) ClipShape { +func PolygonClip(points []any) ClipShape { clip := new(polygonClip) - clip.points = []interface{}{} + clip.points = []any{} if clip.Set(Points, points) { return clip } @@ -85,14 +85,14 @@ func PolygonClip(points []interface{}) ClipShape { // PolygonPointsClip creates a polygon View clipping area. func PolygonPointsClip(points []SizeUnit) ClipShape { clip := new(polygonClip) - clip.points = []interface{}{} + clip.points = []any{} if clip.Set(Points, points) { return clip } return nil } -func (clip *insetClip) Set(tag string, value interface{}) bool { +func (clip *insetClip) Set(tag string, value any) bool { switch strings.ToLower(tag) { case Top, Right, Bottom, Left: if value == nil { @@ -168,7 +168,7 @@ func (clip *insetClip) valid(session Session) bool { return false } -func (clip *circleClip) Set(tag string, value interface{}) bool { +func (clip *circleClip) Set(tag string, value any) bool { if value == nil { clip.Remove(tag) } @@ -232,7 +232,7 @@ func (clip *circleClip) valid(session Session) bool { return true } -func (clip *ellipseClip) Set(tag string, value interface{}) bool { +func (clip *ellipseClip) Set(tag string, value any) bool { if value == nil { clip.Remove(tag) } @@ -302,23 +302,23 @@ func (clip *ellipseClip) valid(session Session) bool { return rx.Value != 0 && ry.Value != 0 } -func (clip *polygonClip) Get(tag string) interface{} { +func (clip *polygonClip) Get(tag string) any { if Points == strings.ToLower(tag) { return clip.points } return nil } -func (clip *polygonClip) getRaw(tag string) interface{} { +func (clip *polygonClip) getRaw(tag string) any { return clip.Get(tag) } -func (clip *polygonClip) Set(tag string, value interface{}) bool { +func (clip *polygonClip) Set(tag string, value any) bool { if Points == strings.ToLower(tag) { switch value := value.(type) { - case []interface{}: + case []any: result := true - clip.points = make([]interface{}, len(value)) + clip.points = make([]any, len(value)) for i, val := range value { switch val := val.(type) { case string: @@ -343,7 +343,7 @@ func (clip *polygonClip) Set(tag string, value interface{}) bool { return result case []SizeUnit: - clip.points = make([]interface{}, len(value)) + clip.points = make([]any, len(value)) for i, point := range value { clip.points[i] = point } @@ -352,7 +352,7 @@ func (clip *polygonClip) Set(tag string, value interface{}) bool { case string: result := true values := strings.Split(value, ",") - clip.points = make([]interface{}, len(values)) + clip.points = make([]any, len(values)) for i, val := range values { val = strings.Trim(val, " \t\n\r") if isConstantName(val) { @@ -370,18 +370,18 @@ func (clip *polygonClip) Set(tag string, value interface{}) bool { return false } -func (clip *polygonClip) setRaw(tag string, value interface{}) { +func (clip *polygonClip) setRaw(tag string, value any) { clip.Set(tag, value) } func (clip *polygonClip) Remove(tag string) { if Points == strings.ToLower(tag) { - clip.points = []interface{}{} + clip.points = []any{} } } func (clip *polygonClip) Clear() { - clip.points = []interface{}{} + clip.points = []any{} } func (clip *polygonClip) AllTags() []string { @@ -422,7 +422,7 @@ func (clip *polygonClip) cssStyle(session Session) string { buffer := allocStringBuilder() defer freeStringBuilder(buffer) - writePoint := func(value interface{}) { + writePoint := func(value any) { switch value := value.(type) { case string: if val, ok := session.resolveConstants(value); ok { @@ -501,7 +501,7 @@ func parseClipShape(obj DataObject) ClipShape { return nil } -func (style *viewStyle) setClipShape(tag string, value interface{}) bool { +func (style *viewStyle) setClipShape(tag string, value any) bool { switch value := value.(type) { case ClipShape: style.properties[tag] = value diff --git a/viewFilter.go b/viewFilter.go index 09225f7..734aabb 100644 --- a/viewFilter.go +++ b/viewFilter.go @@ -130,7 +130,7 @@ func newViewFilter(obj DataObject) ViewFilter { return nil } -func (filter *viewFilter) Set(tag string, value interface{}) bool { +func (filter *viewFilter) Set(tag string, value any) bool { if value == nil { filter.Remove(tag) return true @@ -224,7 +224,7 @@ func (filter *viewFilter) cssStyle(session Session) string { return buffer.String() } -func (style *viewStyle) setFilter(tag string, value interface{}) bool { +func (style *viewStyle) setFilter(tag string, value any) bool { switch value := value.(type) { case ViewFilter: style.properties[tag] = value diff --git a/viewStyle.go b/viewStyle.go index 9052fe3..f8799ea 100644 --- a/viewStyle.go +++ b/viewStyle.go @@ -442,7 +442,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) { } } -func valueToOrientation(value interface{}, session Session) (int, bool) { +func valueToOrientation(value any, session Session) (int, bool) { if value != nil { switch value := value.(type) { case int: @@ -471,11 +471,11 @@ func valueToOrientation(value interface{}, session Session) (int, bool) { return 0, false } -func (style *viewStyle) Get(tag string) interface{} { +func (style *viewStyle) Get(tag string) any { return style.get(strings.ToLower(tag)) } -func (style *viewStyle) get(tag string) interface{} { +func (style *viewStyle) get(tag string) any { switch tag { case Border, CellBorder: return getBorder(&style.propertyList, tag) @@ -539,7 +539,7 @@ func (style *viewStyle) AllTags() []string { return result } -func supportedPropertyValue(value interface{}) bool { +func supportedPropertyValue(value any) bool { switch value.(type) { case string: case []string: @@ -551,7 +551,7 @@ func supportedPropertyValue(value interface{}) bool { case fmt.Stringer: case []ViewShadow: case []View: - case []interface{}: + case []any: case map[string]Animation: default: return false @@ -559,7 +559,7 @@ func supportedPropertyValue(value interface{}) bool { return true } -func writePropertyValue(buffer *strings.Builder, tag string, value interface{}, indent string) { +func writePropertyValue(buffer *strings.Builder, tag string, value any, indent string) { writeString := func(text string) { simple := (tag != Text && tag != Title && tag != Summary) @@ -697,7 +697,7 @@ func writePropertyValue(buffer *strings.Builder, tag string, value interface{}, buffer.WriteRune(']') } - case []interface{}: + case []any: switch count := len(value); count { case 0: buffer.WriteString("[]") @@ -755,7 +755,7 @@ func writeViewStyle(name string, view ViewStyle, buffer *strings.Builder, indent buffer.WriteString(" {\n") indent += "\t" - writeProperty := func(tag string, value interface{}) { + writeProperty := func(tag string, value any) { if supportedPropertyValue(value) { buffer.WriteString(indent) buffer.WriteString(tag) diff --git a/viewStyleSet.go b/viewStyleSet.go index 7f70c9a..a35d33f 100644 --- a/viewStyleSet.go +++ b/viewStyleSet.go @@ -4,7 +4,7 @@ import ( "strings" ) -func (style *viewStyle) setRange(tag string, value interface{}) bool { +func (style *viewStyle) setRange(tag string, value any) bool { switch value := value.(type) { case string: if strings.Contains(value, "@") { @@ -31,7 +31,7 @@ func (style *viewStyle) setRange(tag string, value interface{}) bool { return true } -func (style *viewStyle) setBackground(value interface{}) bool { +func (style *viewStyle) setBackground(value any) bool { switch value := value.(type) { case BackgroundElement: style.properties[Background] = []BackgroundElement{value} @@ -122,11 +122,11 @@ func (style *viewStyle) remove(tag string) { } } -func (style *viewStyle) Set(tag string, value interface{}) bool { +func (style *viewStyle) Set(tag string, value any) bool { return style.set(strings.ToLower(tag), value) } -func (style *viewStyle) set(tag string, value interface{}) bool { +func (style *viewStyle) set(tag string, value any) bool { if value == nil { style.remove(tag) return true diff --git a/viewUtils.go b/viewUtils.go index e49d3e8..82ff43a 100644 --- a/viewUtils.go +++ b/viewUtils.go @@ -3,7 +3,7 @@ package rui // Get returns a value of the property with name "tag" of the "rootView" subview with "viewID" id value. // The type of return value depends on the property. // If the subview don't exists or the property is not set then nil is returned. -func Get(rootView View, viewID, tag string) interface{} { +func Get(rootView View, viewID, tag string) any { var view View if viewID != "" { view = ViewByID(rootView, viewID) @@ -19,7 +19,7 @@ func Get(rootView View, viewID, tag string) interface{} { // Set sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result: // true - success, // false - error (incompatible type or invalid format of a string value, see AppLog). -func Set(rootView View, viewID, tag string, value interface{}) bool { +func Set(rootView View, viewID, tag string, value any) bool { var view View if viewID != "" { view = ViewByID(rootView, viewID) @@ -976,9 +976,9 @@ func GetNotTranslate(view View, subviewID string) bool { return false } -func valueFromStyle(view View, tag string) interface{} { +func valueFromStyle(view View, tag string) any { session := view.Session() - getValue := func(styleTag string) interface{} { + getValue := func(styleTag string) any { if style, ok := stringProperty(view, styleTag, session); ok { if style, ok := session.resolveConstants(style); ok { return session.styleProperty(style, tag) diff --git a/viewsContainer.go b/viewsContainer.go index 1e0b2d8..b92bb3a 100644 --- a/viewsContainer.go +++ b/viewsContainer.go @@ -172,11 +172,11 @@ func (container *viewsContainerData) remove(tag string) { } } -func (container *viewsContainerData) Set(tag string, value interface{}) bool { +func (container *viewsContainerData) Set(tag string, value any) bool { return container.set(strings.ToLower(tag), value) } -func (container *viewsContainerData) set(tag string, value interface{}) bool { +func (container *viewsContainerData) set(tag string, value any) bool { if value == nil { container.remove(tag) return true @@ -224,7 +224,7 @@ func (container *viewsContainerData) set(tag string, value interface{}) bool { } container.views = views - case []interface{}: + case []any: views := []View{} for _, v := range value { switch v := v.(type) { @@ -279,11 +279,11 @@ func (container *viewsContainerData) set(tag string, value interface{}) bool { return true } -func (container *viewsContainerData) Get(tag string) interface{} { +func (container *viewsContainerData) Get(tag string) any { return container.get(strings.ToLower(tag)) } -func (container *viewsContainerData) get(tag string) interface{} { +func (container *viewsContainerData) get(tag string) any { switch tag { case Content: return container.views