Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): allow ability to set drawer gravity #10970

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Jun 17, 2019

  • Implement ability to specify drawer gravity
    • Ti.UI.Android.DrawerLayout.drawerGravity
TEST CASE
const win = Ti.UI.createWindow(),
	leftView = Ti.UI.createView({
		backgroundColor: "#333",
		layout: "vertical"
	}),
	centerView = Ti.UI.createView({
		backgroundColor: "#fff"
	}),
	rightView = Ti.UI.createView({
		backgroundColor: "#333"
	}),
	drawer = Ti.UI.Android.createDrawerLayout({
		leftView: leftView,
		centerView: centerView,
		rightView: rightView
	}),
	menu = Ti.UI.createView({
		layout: "vertical"
	}),
	btn1 = Ti.UI.createButton({
		title: 'Open Left'
	}),
	btn2 = Ti.UI.createButton({
		title: 'Open Right'
	}),
	btn3 = Ti.UI.createButton({
		title: 'Lock All'
	}),
	btn4 = Ti.UI.createButton({
		title: 'Lock Left'
	}),
	btn5 = Ti.UI.createButton({
		title: 'Lock Right'
	}),
	btn6 = Ti.UI.createButton({
		title: 'Unlock All'
	});

for (let i = 0; i < 10; ++i) {
	leftView.add(Ti.UI.createLabel({
        color: "#fff",
        text: "Item",
        top: 10,
        bottom: 10,
        height: Ti.UI.SIZE
    }));
}

btn2.addEventListener('click', function() {
	drawer.toggleRight();
});
btn1.addEventListener('click', function() {
	drawer.toggleLeft();
});
btn3.addEventListener('click', function() {
	drawer.setDrawerLockMode(Titanium.UI.Android.DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
});
btn4.addEventListener('click', function() {
    drawer.setDrawerGravity(Titanium.UI.Android.DrawerLayout.GRAVITY_LEFT);
	drawer.setDrawerLockMode(Titanium.UI.Android.DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
});
btn5.addEventListener('click', function() {
    drawer.setDrawerGravity(Titanium.UI.Android.DrawerLayout.GRAVITY_RIGHT);
	drawer.setDrawerLockMode(Titanium.UI.Android.DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
});
btn6.addEventListener('click', function() {
	drawer.setDrawerLockMode(Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNLOCKED);
});

centerView.add(menu);
menu.add(btn1);
menu.add(btn2);
menu.add(btn3);
menu.add(btn4);
menu.add(btn5);
menu.add(btn6);

win.addEventListener('open', function() {
	const activity = win.getActivity(),
		actionbar = activity.getActionBar();

	if (actionbar) {
		actionbar.displayHomeAsUp = true;
		actionbar.onHomeIconItemSelected = function() {
			drawer.toggleLeft();
		};
	}
});

win.add(drawer);
win.open();

JIRA Ticket

@garymathews garymathews added this to the 8.2.0 milestone Jun 17, 2019
@build build requested review from a team June 17, 2019 21:17
@build build added the docs label Jun 17, 2019
@build
Copy link
Contributor

build commented Jun 17, 2019

Warnings
⚠️

🔍 Can't find junit reports at ./junit.*.xml, skipping generating JUnit Report.

Messages
📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.

Generated by 🚫 dangerJS against 5a4124c

@m1ga
Copy link
Contributor

m1ga commented Jun 18, 2019

@garymathews think this one should then be closed: #9627

@garymathews garymathews modified the milestones: 8.2.0, 8.3.0 Aug 1, 2019
@garymathews garymathews changed the base branch from master to 8_3_X September 3, 2019 18:37
@sgtcoolguy sgtcoolguy changed the base branch from 8_3_X to master September 9, 2019 17:49
@build build added the ios label Sep 9, 2019
Copy link
Contributor

@sgtcoolguy sgtcoolguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ssekhri
Copy link

ssekhri commented Sep 12, 2019

@garymathews Noticed the following scenarios using the sample app with this PR:

  1. Lock left side drawer only using "Lock Left" button. The left drawer gets locked. Now press "Lock All". The left drawer remains locked but right drawer doesn't gets locked. (same scenario if you lock Right drawer only first)
  2. When we lock both side drawers one by one but not together then "Unlock All" doesn't unlock both the drawers. For eg: press "Lock Left" the press "Lock Right". Both gets locked successfully. Now press "Unlock All". Only the last locked drawer gets unlocked.
    If instead we use "Lock All" to lock both side drawers then "Unlock All" unlocks both the drawers.
    Note: Programmatic open of both side drawers works fine whether we lock them one by one or together.

@garymathews garymathews modified the milestones: 8.3.0, 9.0.0 Oct 16, 2019
@ewanharris ewanharris modified the milestones: 9.0.0, 9.1.0 Feb 12, 2020
@sgtcoolguy sgtcoolguy modified the milestones: 9.1.0, 9.3.0 Aug 5, 2020
@sgtcoolguy sgtcoolguy modified the milestones: 9.3.0, 10.0.0 Nov 20, 2020
@hansemannn hansemannn removed this from the 10.0.0 milestone Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants