Skip to content

Commit 4977ddb

Browse files
author
Ahmed Awaad
committed
feat(android): add support for layout direction in ReactBottomNavigationView
1 parent 8867d42 commit 4977ddb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
127127
layout(left, top, right, bottom)
128128
}
129129

130+
fun applyDirection(dir: Int) {
131+
bottomNavigation.layoutDirection = dir
132+
}
133+
130134
override fun requestLayout() {
131135
super.requestLayout()
132136
@Suppress("SENSELESS_COMPARISON") // layoutCallback can be null here since this method can be called in init

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabViewManager.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ class RCTTabViewManager(context: ReactApplicationContext) :
167167
view.isHapticFeedbackEnabled = value
168168
}
169169

170+
override fun setLayoutDirection(view: ReactBottomNavigationView, value: String?) {
171+
val direction = when (value) {
172+
"rtl" -> View.LAYOUT_DIRECTION_RTL
173+
"ltr" -> View.LAYOUT_DIRECTION_LTR
174+
else -> View.LAYOUT_DIRECTION_LOCALE
175+
}
176+
view.applyDirection(direction)
177+
}
178+
170179
override fun setFontFamily(view: ReactBottomNavigationView?, value: String?) {
171180
view?.setFontFamily(value)
172181
}

0 commit comments

Comments
 (0)