Skip to content

Commit 49918cb

Browse files
committed
Android changes
1 parent 43a213c commit 49918cb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

android/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ class TitleAndButtonsContainer(context: Context) : ViewGroup(context) {
155155
val rightBarWidth = rightButtonBar.measuredWidth
156156
val leftBarWidth = leftButtonBar.measuredWidth
157157
val isCenter = titleComponentAlignment == Alignment.Center
158+
val isFill = titleComponentAlignment == Alignment.Fill
158159
val titleHeightMeasureSpec = MeasureSpec.makeMeasureSpec(containerHeight, MeasureSpec.AT_MOST)
159-
val titleWidthMeasureSpec = makeTitleAtMostWidthMeasureSpec(containerWidth, rightBarWidth, leftBarWidth, isCenter)
160+
val titleWidthMeasureSpec = makeTitleAtMostWidthMeasureSpec(containerWidth, rightBarWidth, leftBarWidth, isCenter, isFill)
160161
if (titleComponent is TitleBarReactView) {
161162
titleComponent.centered = isCenter
162163
}

android/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsMeasurer.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ typealias TitleRight = Int
1515
typealias TitleTop = Int
1616
typealias TitleBottom = Int
1717

18-
fun makeTitleAtMostWidthMeasureSpec(containerWidth: Int, rightBarWidth: Int, leftBarWidth: Int, isCenter: Boolean): Int {
18+
fun makeTitleAtMostWidthMeasureSpec(containerWidth: Int, rightBarWidth: Int, leftBarWidth: Int, isCenter: Boolean, isFill: Boolean = false): Int {
1919
return if (isCenter) {
2020
View.MeasureSpec.makeMeasureSpec(containerWidth, View.MeasureSpec.AT_MOST)
2121
} else {
22-
View.MeasureSpec.makeMeasureSpec(containerWidth - rightBarWidth - leftBarWidth - 2 * DEFAULT_LEFT_MARGIN_PX, View.MeasureSpec.AT_MOST)
22+
val availableWidth = containerWidth - rightBarWidth - leftBarWidth - 2 * DEFAULT_LEFT_MARGIN_PX
23+
if (isFill) {
24+
View.MeasureSpec.makeMeasureSpec(availableWidth, View.MeasureSpec.EXACTLY)
25+
} else {
26+
View.MeasureSpec.makeMeasureSpec(availableWidth, View.MeasureSpec.AT_MOST)
27+
}
2328
}
2429
}
2530

0 commit comments

Comments
 (0)