Skip to content

Commit

Permalink
minHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed May 4, 2024
1 parent c97480f commit 1473b8b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public enum LayoutArrangement {
private int viewMinWidth = -1;
private int viewMaxWidth = -1;
private int viewMaxHeight = -1;
private int viewMinHeight = -1;
int[] horizontal = new int[2];
int[] vertical = new int[2];
/**
Expand Down Expand Up @@ -653,6 +654,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
if (viewMaxHeight != -1 && measuredHeight > viewMaxHeight) {
measuredHeight = viewMaxHeight;
}
if (viewMinHeight != -1 && measuredHeight < viewMinHeight) {
measuredHeight = viewMinHeight;
}
setMeasuredDimension(measuredWidth, measuredHeight);
}

Expand Down Expand Up @@ -1262,6 +1266,10 @@ public void setMaxHeight(Integer value)
{
viewMaxHeight = value;
}
public void setMinHeight(Integer value)
{
viewMinHeight = value;
}

public void setEnableHorizontalWrap(boolean enable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public abstract class TiUIView implements KrollProxyListener, OnFocusChangeListe
protected TiBackgroundDrawable background;
private int minWidth = -1;
private int maxWidth = -1;
private int minHeight = -1;
private int maxHeight = -1;

public TiBackgroundDrawable getBackground()
Expand Down Expand Up @@ -793,6 +794,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
setMinWidth(newValue, hasBorder(proxy.getProperties()));
} else if (key.equals("maxHeight")) {
setMaxHeight(newValue, hasBorder(proxy.getProperties()));
} else if (key.equals("minHeight")) {
setMinHeight(newValue, hasBorder(proxy.getProperties()));
} else if (key.equals(TiC.PROPERTY_VISIBLE)) {
newValue = (newValue == null) ? false : newValue;
this.setVisibility(TiConvert.toBoolean(newValue) ? View.VISIBLE : View.INVISIBLE);
Expand Down Expand Up @@ -1072,6 +1075,9 @@ public void processProperties(KrollDict d)
if (d.containsKey("maxHeight")) {
setMaxHeight(d.get("maxHeight"), hasBorder(d));
}
if (d.containsKey("minHeight")) {
setMinHeight(d.get("minHeight"), hasBorder(d));
}
initializeBorder(d, bgColor);

if (d.containsKey(TiC.PROPERTY_OPACITY) && !nativeViewNull) {
Expand Down Expand Up @@ -1205,6 +1211,20 @@ private void setMaxHeight(Object value, Boolean hasBorder)
Log.w(TAG, "You can only use maxHeight for Views without borders");
}
}
private void setMinHeight(Object value, Boolean hasBorder)
{
minHeight = -1;
if (value != null) {
minHeight = TiConvert.toTiDimension(TiConvert.toInt(value),
TiDimension.TYPE_HEIGHT).getAsPixels(nativeView);
}

if (!hasBorder) {
((TiCompositeLayout) nativeView).setMinHeight(minHeight);
} else {
Log.w(TAG, "You can only use maxHeight for Views without borders");
}
}

private void setAnchor(HashMap point)
{
Expand Down

0 comments on commit 1473b8b

Please sign in to comment.