From a7d1567b7eb179958ff15065c4168da04b5cf064 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Thu, 2 Jul 2026 14:51:36 -0300 Subject: [PATCH 1/2] feat(core): support max-width and max-height CSS properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `max-width` / `max-height` style properties on iOS and Android, accepting fixed lengths and percentages (e.g. `max-width: 100%`), the CSS-standard complement to the existing `min-width` / `min-height`. Because percentages resolve against the parent size, the properties follow the `width`/`height` pattern rather than `min-*`: the effective pixel value is computed at measure time in `_updateEffectiveLayoutValues` (stored as `effectiveMaxWidth`/`effectiveMaxHeight`, defaulting to Infinity = unconstrained). Applied after the min clamp so `max` wins when `min > max`, matching CSS. iOS: measure-time clamps in the base view, all layout containers, and a central cap in `ViewHelper.getMeasureSpec`; wires up the long-dead `MAX_SIZE /* lp.maxWidth */` flexbox placeholders. Android: enforced natively in the widgets library — `maxWidth`/`maxHeight` (+percent) on `CommonLayoutParams`, clamped in `getMeasureSpec` and resolved in `adjustChildrenLayoutParams`, exposed via new `ViewHelper` setters. Removes the now-shadowing `maxWidth`/`maxHeight` fields from `FlexboxLayout.LayoutParams` so flexbox inherits the unified fields and honors the properties (including percent). Requires rebuilding `widgets-release.aar`. Adds automated tests for style-property parsing/sync, flexbox measure (enabling four previously-stubbed tests), StackLayout measure, and Label max-width/height including percent. --- apps/automated/src/ui/label/label-tests.ts | 76 ++++++++++++++++++ .../src/ui/layouts/flexbox-layout-tests.ts | 56 +++++++++++-- .../src/ui/layouts/stack-layout-tests.ts | 29 +++++++ .../src/ui/styling/style-properties-tests.ts | 32 ++++++++ packages/core/ui/core/view-base/index.ts | 5 ++ packages/core/ui/core/view/index.android.ts | 24 +++++- packages/core/ui/core/view/index.d.ts | 16 ++++ packages/core/ui/core/view/index.ios.ts | 9 ++- packages/core/ui/core/view/view-common.ts | 33 ++++++++ .../view/view-helper/view-helper-common.ts | 24 +++++- .../ui/layouts/absolute-layout/index.ios.ts | 4 + .../core/ui/layouts/dock-layout/index.ios.ts | 4 + .../ui/layouts/flexbox-layout/index.ios.ts | 24 +++--- .../core/ui/layouts/grid-layout/index.ios.ts | 4 + .../core/ui/layouts/stack-layout/index.ios.ts | 4 + .../core/ui/layouts/wrap-layout/index.ios.ts | 4 + packages/core/ui/styling/style-properties.ts | 26 +++++++ packages/core/ui/styling/style/index.ts | 2 + .../lib/android/org.nativescript.widgets.d.ts | 13 ++++ .../widgets/CommonLayoutParams.java | 56 +++++++++++++ .../nativescript/widgets/FlexboxLayout.java | 22 ++---- .../org/nativescript/widgets/ViewHelper.java | 78 +++++++++++++++++++ 22 files changed, 505 insertions(+), 40 deletions(-) diff --git a/apps/automated/src/ui/label/label-tests.ts b/apps/automated/src/ui/label/label-tests.ts index 508e0f7d87..c765a8c10c 100644 --- a/apps/automated/src/ui/label/label-tests.ts +++ b/apps/automated/src/ui/label/label-tests.ts @@ -232,6 +232,82 @@ export class LabelTest extends testModule.UITest