Skip to content

Commit fd2888b

Browse files
author
vakrilov
committed
refactor: ensure back-compatible layout for btns
1 parent 1f8c3fd commit fd2888b

5 files changed

Lines changed: 22 additions & 2 deletions

File tree

api-reports/NativeScript.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,8 @@ export abstract class ViewBase extends Observable {
28492849
public _goToVisualState(state: string): void;
28502850
public id: string;
28512851
// (undocumented)
2852+
public _ignoreFlexMinWidthHeightReset: boolean;
2853+
// (undocumented)
28522854
_inheritStyleScope(styleScope: any /* StyleScope */): void;
28532855
initNativeView(): void;
28542856
// (undocumented)

nativescript-core/ui/button/button.android.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,5 @@ export class Button extends ButtonBase {
190190
return 4; // 4dp @dimen/button_pressed_z_material
191191
}
192192
}
193+
194+
Button.prototype._ignoreFlexMinWidthHeightReset = true;

nativescript-core/ui/core/view-base/view-base.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,17 @@ export abstract class ViewBase extends Observable {
432432
* @private
433433
*/
434434
public recycleNativeView: "always" | "never" | "auto";
435+
435436
/**
436437
* @private
437438
*/
438439
public _isPaddingRelative: boolean;
440+
441+
/**
442+
* @private
443+
*/
444+
public _ignoreFlexMinWidthHeightReset: boolean;
445+
439446
public _styleScope: any;
440447

441448
/**

nativescript-core/ui/core/view-base/view-base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
227227
_oldTop: number;
228228
_oldRight: number;
229229
_oldBottom: number;
230+
_ignoreFlexMinWidthHeightReset: boolean;
230231

231232
public effectiveMinWidth: number;
232233
public effectiveMinHeight: number;

nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.android.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
155155
}
156156

157157
public _setChildMinWidthNative(child: View, value: Length): void {
158-
child._setMinWidthNative(0);
158+
// Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804
159+
if (!child._ignoreFlexMinWidthHeightReset) {
160+
child._setMinWidthNative(0);
161+
}
162+
159163
const nativeView = child.nativeViewProtected;
160164
const lp = nativeView.getLayoutParams();
161165
if (lp instanceof widgetLayoutParams) {
@@ -165,7 +169,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
165169
}
166170

167171
public _setChildMinHeightNative(child: View, value: Length): void {
168-
child._setMinHeightNative(0);
172+
// Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804
173+
if (!child._ignoreFlexMinWidthHeightReset) {
174+
child._setMinHeightNative(0);
175+
}
176+
169177
const nativeView = child.nativeViewProtected;
170178
const lp = nativeView.getLayoutParams();
171179
if (lp instanceof widgetLayoutParams) {

0 commit comments

Comments
 (0)