[TIMOB-24582] Android: Navigation parity for a cross-platform Ti.UI.NavigationWindow
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | High |
| Status | Closed |
| Resolution | Done |
| Resolution Date | 2019-01-11T02:17:29.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 8.0.0 |
| Components | Android |
| Labels | NavigationWindow, android, parity |
| Reporter | Hans Knöchel |
| Assignee | Gary Mathews |
| Created | 2017-04-16T18:32:58.000+0000 |
| Updated | 2019-01-11T02:17:32.000+0000 |
Description
On iOS, we have the
Ti.UI.iOS.NavigationWindow to handle a stack of windows that can be opened and closed. Unfortunately, on Android and Windows, we have to do that manually and it required the (Alloy) developer to either write custom (per platform) logic or use plugins like [xp.ui](https://github.com/FokkeZB/UTiL/blob/master/app/lib/xp.ui.js).
Proposed API-changes:
* iOS: Deprecate Ti.UI.iOS.NavigationWindow in favor of Ti.UI.NavigationWindow
* Android / Windows: Support NavigationWindow, add the native [back button](https://developer.android.com/training/implementing-navigation/temporal.html)
* Android / Windows: Expose the openWindow, closeWindow and popToRootWindow if possible
* Adjust Alloy to make the <NavigationWindow> tag available for all platforms
Attachments
| File | Date | Size |
|---|---|---|
| nav-bar-example.png | 2018-09-18T18:22:10.000+0000 | 17661 |
| Untitled-2.png | 2018-09-18T18:21:33.000+0000 | 17661 |
Cloned to TIMOB-25537 for Windows so we can track the ticket independently.
Pushed mocha testbed for
Ti.UI.NavigationWindowthat is meant to be cross-platform. https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/31. Just implemented few basic navigation tests and we can start from there.Just my two cents on this topic since my mic seemed to be broken during our recent discussion. We should also think of this as a common abstraction of the Android ActionBar and the iOS NavigationWindow (and whatever it is called on Windows^^). So apart from handling the window stack and navigation, this should also include setting bar items. Ideally it would rely on
leftNavButtonsandrightNavButtonson iOS andTi.Android.Menuon Android exposed as a unified API. I have something like this in mind for configuring the ActionBar/UINavigationBar:or programmatically configurable via a<window> <!-- ActionBar/NavigationWindow setup --> <navigation-bar title="Example"> <nav-item @click="shareMyStuff" :ios:systemIcon="Ti.UI.iOS.SystemButton.ACTION" ios:position="left" :android:systemIcon="Ti.Android.R.drawable.ic_menu_share" android:position="actionBar"></nav-item> <nav-item @click="deleteMyStuff" :ios:systemIcon="Ti.UI.iOS.SystemButton.TRASH" ios:position="right" android:text="Delete" android:position="menu"></nav-item> </navigation-bar> <!-- The rest of the content --> <label>Content</label> </window>navigationBarproperty onTi.UI.Windowfor example. This would result in: !nav-bar-example.png|thumbnail! For the general navigation functionality in our apps we could build upon [titanium-navigator](https://github.com/appcelerator/titanium-navigator), which exposes a set of APIs for navigation through an app. It's currently tailored to handle components from Angular and Vue. Behind the scenes it inspects the root view of that component and handles navigation accordingly so it should be easy to make it work for Alloy or Classic apps too. Some pseudo code demonstrating the usage:Internallyimport { NavigationManager } from 'titanium-navigator'; const navigationManager = new NavigationManager(); // assuming Ti.UI.createNavigationWindow is the factory for our new cross-platform stacked window management const rootWindow = Ti.UI.createNavigationWindow({}); const child1 = Ti.UI.createWindow({}); const child2 = Ti.UI.createWindow({}); rootWindow.push(child1); // Open the root window. Will call open() on rootWindow navigationManager.open(rootWindow); // open subsequent windows. Will push the child view to the window stack and open it. navigationManager.open(child2); // programmatically navigate back, will close the last window in the stack. navigationManager.back();titanium-navigatorhas a set of rules so it knows how to handle navigation. See [AbstractNavigator](https://github.com/appcelerator/titanium-navigator/blob/master/src/navigators/AbstractNavigator.ts) and [NavigationManager.open()](https://github.com/appcelerator/titanium-navigator/blob/master/src/NavigationManager.ts#L145) to get a rough idea how it works.master: https://github.com/appcelerator/titanium_mobile/pull/10375
FR passed. Waiting for CR To Merge.
Already FR'd before merge