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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): parity for Tab.popToRootWindow() #13976

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Jan 29, 2024

An iOS TabGroup opens Windows inside of it and you can use Tab.popToRootWindow() to close all those tabs. Since Android is opening new windows we don't have that stack and can close them.

The idea is to emulate that behavior by looking at the first activity and check if it is a TabGroup. If so loop through all activity above it and close them.
Works with style: Titanium.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION too.

Test:

var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
	title: "open"
})
win.add(btn);

btn.addEventListener("click", function() {
	createWindow();
})

function createWindow() {
	let newWin = Ti.UI.createWindow({});
	newWin.open();
	let newButton = Ti.UI.createButton({
		title: "close",
		bottom: 0
	})
	let newButton2 = Ti.UI.createButton({
		title: "new"
	})
	newWin.add([newButton, newButton2]);
	newButton.addEventListener("click", function() {
		tab1.popToRootWindow();
	});
	newButton2.addEventListener("click", function() {
		createWindow()
	});
}

var tab1 = Ti.UI.createTab({
		window: win,
		title: 'a'
	}),
	tab2 = Ti.UI.createTab({
		window: Ti.UI.createWindow(),
		title: 'b'
	}),
	tabGroup = Ti.UI.createTabGroup({
		tabs: [tab1, tab2]
	});
tabGroup.open();
  • start the app.
  • open some windows and then press close
  • you should go back to the TabGroup again

Todo:

  • Test it 馃槃 Draft for now as I only tested it with the small demo above
simplescreenrecorder-2024-01-29_21.14.34.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant