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

fix(android): navigationWindow open/close event #11607

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public NavigationWindowProxy()
public void open(@Kroll.argument(optional = true) Object arg)
{
// FIXME: Shouldn't this complain/blow up if window isn't specified?
if (getProperties().containsKeyAndNotNull(TiC.PROPERTY_WINDOW)) {
if (!opened && getProperties().containsKeyAndNotNull(TiC.PROPERTY_WINDOW)) {
opened = true;
Object rootView = getProperties().get(TiC.PROPERTY_WINDOW);
if (rootView instanceof WindowProxy || rootView instanceof TabGroupProxy) {
openWindow(rootView, arg);
fireEvent(TiC.EVENT_OPEN, null);
}
return;
}
Expand All @@ -56,8 +57,12 @@ public void popToRootWindow(@Kroll.argument(optional = true) Object arg)
@Kroll.method
public void close(@Kroll.argument(optional = true) Object arg)
{
popToRootWindow(arg);
closeWindow(windows.get(0), arg); // close the root window
if (opened) {
opened = false;
popToRootWindow(arg);
closeWindow(windows.get(0), arg); // close the root window
fireEvent(TiC.EVENT_CLOSE, null);
}
super.close(arg);
}

Expand Down
39 changes: 39 additions & 0 deletions tests/Resources/ti.ui.navigationwindow.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2017-Present by Axway. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';

describe.windowsMissing('Titanium.UI.NavigationWindow', _ => {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • ⚠️ tests/Resources/ti.ui.navigationwindow.addontest.js line 11 – '' is defined but never used. Allowed unused args must match /^.+/u. (no-unused-vars)

let nav;

this.timeout(10000);

afterEach(function () {
if (nav) {
nav.close();
}
nav = null;
});

it('open/close events', finish => {
const window = Ti.UI.createWindow();
Copy link
Contributor

Choose a reason for hiding this comment

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

  • 🚫 tests/Resources/ti.ui.navigationwindow.addontest.js line 24 – Expected indentation of 2 tabs but found 8 spaces. (indent)


Copy link
Contributor

Choose a reason for hiding this comment

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

  • 🚫 tests/Resources/ti.ui.navigationwindow.addontest.js line 25 – Trailing spaces not allowed. (no-trailing-spaces)

nav = Ti.UI.createNavigationWindow({
window: window
});

nav.addEventListener('open', _ => {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • ⚠️ tests/Resources/ti.ui.navigationwindow.addontest.js line 30 – '' is defined but never used. Allowed unused args must match /^.+/u. (no-unused-vars)

navigation.close();
});
nav.addEventListener('close', _ => {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • ⚠️ tests/Resources/ti.ui.navigationwindow.addontest.js line 33 – '' is defined but never used. Allowed unused args must match /^.+/u. (no-unused-vars)

finish();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

  • 🚫 tests/Resources/ti.ui.navigationwindow.addontest.js line 35 – Expected indentation of 2 tabs but found 8 spaces. (indent)


nav.open();
});
});