Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25522

iOS: Expose navigation-window instance property to Ti.UI.Window

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.3.0
    • Component/s: iOS
    • Labels:
    • Story Points:
      8
    • Sprint:
      2018 Sprint 06 SDK, 2018 Sprint 07 SDK, 2018 Sprint 08 SDK, 2018 Sprint 09 SDK, 2018 Sprint 10 SDK, 2018 Sprint 11 SDK

      Description

      In a production app, there are many cases where the developer would like to know the navigation-window context he/she is currently in. For example, when going through a set of windows to select a configuration, the developer calls "openWindow(nextWindow)) to open the next window ("push it") into the current context.

      Right now, developers either store a global reference, e.g.

      Alloy.Globals.navWindow = nav;
      

      -> [BAD]
      or pass the navigation-window to each new window being created, e.g.

      Alloy.createController('nextWindow', {  
        navigationWindow: nav 
      });
      

      -> [BAD]

      I am proposing a solution where the developer can reference the current navigation-window using the "navigationWindow" instance property. See the following test-case for an example:

      var win = Ti.UI.createWindow({
          backgroundColor: '#fff'
      });
       
      var nav = Ti.UI.iOS.createNavigationWindow({
        window: win
      });
       
      var btn = Ti.UI.createButton({
          title: 'Open next window'
      });
       
      btn.addEventListener('click', function() {
          win.navigationWindow.openWindow(Ti.UI.createWindow({
            title: 'Next Window!',
            backgroundColor: 'green'
          }));
      });
       
      win.add(btn);
      nav.open();
      

      While the developer could still just use the "nav" property, it will get more complex when using a multi-level application which scope changes during the navigation-flow. Ideally, once we move the navigation-window to the universal Ti.UI.NavigationWindow namespace, we could expose the same for Android (cc Joshua Quick) and Windows (cc Kota Iguchi).

      Requirements of this API:

      • Return existing references only, no copies
      • Make the property read-only
      • Only return a navigation-window if one exists, error else

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              hknoechel Hans Knöchel
              Reviewer:
              Vijay Singh
              Tester:
              Samir Mohammed
            • Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code