mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(button-android): use setMinWidth to set TextView widgets min-width (#7804)
* fix: setMinimumWidth does not really set the minWidth for TextView widgets * chore: fix versions * refactor(android): default minWidth/Height values for button * reafctor: reset minWidth when view is in flexbox for backcompat * refactor: ensure back-compatible layout for btns * chore: cut 6.5.0 release (#8443) * release: cut 6.5.0 release * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com> Co-authored-by: vakrilov <alexander.vakrilov@telerik.com> Co-authored-by: Dimitar Topuzov <dtopuzov@gmail.com> Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1f04469fb3
commit
66cc8a477e
@@ -7,7 +7,9 @@ import {
|
||||
flexShrinkProperty, FlexShrink,
|
||||
flexWrapBeforeProperty, FlexWrapBefore,
|
||||
alignSelfProperty, AlignSelf,
|
||||
flexDirectionProperty, flexWrapProperty, justifyContentProperty, alignItemsProperty, alignContentProperty
|
||||
flexDirectionProperty, flexWrapProperty, justifyContentProperty, alignItemsProperty, alignContentProperty,
|
||||
minWidthProperty, minHeightProperty,
|
||||
CssProperty
|
||||
} from "./flexbox-layout-common";
|
||||
|
||||
export * from "./flexbox-layout-common";
|
||||
@@ -137,6 +139,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
public _updateNativeLayoutParams(child: View): void {
|
||||
super._updateNativeLayoutParams(child);
|
||||
|
||||
// NOTE: If minWidth/Height is not set, the next code will clear the default native values for minWidth/Height.
|
||||
// Flex box will not respect the button default min width. Keeping this behavior for back-compatibility.
|
||||
this._setChildMinWidthNative(child, child.minWidth);
|
||||
this._setChildMinHeightNative(child, child.minHeight);
|
||||
|
||||
const lp = <org.nativescript.widgets.FlexboxLayout.LayoutParams>child.nativeViewProtected.getLayoutParams();
|
||||
const style = child.style;
|
||||
lp.order = style.order;
|
||||
@@ -147,22 +154,30 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
child.nativeViewProtected.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
public _setChildMinWidthNative(child: View): void {
|
||||
child._setMinWidthNative(0);
|
||||
public _setChildMinWidthNative(child: View, value: Length): void {
|
||||
// Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804
|
||||
if (!child._ignoreFlexMinWidthHeightReset) {
|
||||
child._setMinWidthNative(0);
|
||||
}
|
||||
|
||||
const nativeView = child.nativeViewProtected;
|
||||
const lp = nativeView.getLayoutParams();
|
||||
if (lp instanceof widgetLayoutParams) {
|
||||
lp.minWidth = Length.toDevicePixels(child.style.minWidth, 0);
|
||||
lp.minWidth = Length.toDevicePixels(value, 0);
|
||||
nativeView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
public _setChildMinHeightNative(child: View): void {
|
||||
child._setMinHeightNative(0);
|
||||
public _setChildMinHeightNative(child: View, value: Length): void {
|
||||
// Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804
|
||||
if (!child._ignoreFlexMinWidthHeightReset) {
|
||||
child._setMinHeightNative(0);
|
||||
}
|
||||
|
||||
const nativeView = child.nativeViewProtected;
|
||||
const lp = nativeView.getLayoutParams();
|
||||
if (lp instanceof widgetLayoutParams) {
|
||||
lp.minHeight = Length.toDevicePixels(child.style.minHeight, 0);
|
||||
lp.minHeight = Length.toDevicePixels(value, 0);
|
||||
nativeView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user