Skip to content

Commit 4b79301

Browse files
authored
Android: Fix ordering of top-bar left-hand button layout (#7848)
1 parent 0be34f9 commit 4b79301

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

e2e/Buttons.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import Utils from './Utils';
22
import TestIDs from '../playground/src/testIDs';
33

4-
const { elementById, elementByLabel } = Utils;
4+
const {
5+
elementById,
6+
elementByLabel,
7+
elementTopBar,
8+
expectImagesToBeEqual,
9+
} = Utils;
510

611
describe('Buttons', () => {
712
beforeEach(async () => {
@@ -10,6 +15,12 @@ describe('Buttons', () => {
1015
await elementById(TestIDs.GOTO_BUTTONS_SCREEN).tap();
1116
});
1217

18+
it.e2e('should render top/navigation-bar buttons in the right order', async () => {
19+
const snapshottedImagePath = `./e2e/assets/buttons_navbar.${device.getPlatform()}.png`;
20+
const actual = await elementTopBar().takeScreenshot('buttons_navbar');
21+
expectImagesToBeEqual(actual, snapshottedImagePath)
22+
});
23+
1324
it(':android: should not effect left buttons when hiding back button', async () => {
1425
await elementById(TestIDs.TOGGLE_BACK).tap();
1526
await expect(elementById(TestIDs.LEFT_BUTTON)).toBeVisible();

e2e/Utils.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ const utils = {
1515
// return element(by.label(label)).atIndex(0);
1616
return element(by.text(label));
1717
},
18-
elementById: (id) => {
19-
return element(by.id(id));
20-
},
21-
elementByTraits: (traits) => {
22-
return element(by.traits(traits));
18+
elementById: (id) => element(by.id(id)),
19+
elementByTraits: (traits) => element(by.traits(traits)),
20+
elementByType: (type) => element(by.type(type)),
21+
elementTopBar: () => {
22+
const elementType = (device.getPlatform() === 'ios') ?
23+
'UINavigationBar' :
24+
'com.reactnativenavigation.views.stack.topbar.TopBar';
25+
return utils.elementByType(elementType);
2326
},
2427
tapBackIos: () => {
2528
try {
12.2 KB
Loading

e2e/assets/buttons_navbar.ios.png

16.8 KB
Loading

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class TitleAndButtonsContainer(context: Context) : ViewGroup(context) {
7171
component?.layoutDirection = layoutDirection
7272
titleSubTitleBar.layoutDirection = layoutDirection
7373
rightButtonBar.layoutDirection = layoutDirection
74-
leftButtonBar.layoutDirection = if(isRTL()) View.LAYOUT_DIRECTION_LTR else View.LAYOUT_DIRECTION_RTL
74+
leftButtonBar.layoutDirection = if (isRTL()) View.LAYOUT_DIRECTION_RTL else layoutDirection
7575
}
7676

7777
fun setSubTitleTextAlignment(alignment: Alignment) = titleSubTitleBar.setSubTitleAlignment(alignment)

0 commit comments

Comments
 (0)