Code Monkey home page Code Monkey logo

drawersandnavigation's Introduction

DrawersAndNavigation

This is a widget that provides a common navigation between iPhone, iPad, and Android. It uses NavigationWindow on iOS and supports back button and ActionBar on Android. It also provides a drawer that is common to all screens.

View on Android, iPhone

Use this framework to navigate through a tree-structured set of screens, switch between trees, and open a drawer on the left side of the screen.

Getting started

git clone [email protected]:appcelerator-services/DrawersAndNavigation.git

This git provides a sample app to explore. It starts with a dummy login screen; upon login the navigation starts. Note that all the code necessary to start the app is in index.html. The drawer content is in the drawer controller, and each window (window1, window2, ... window5, altwin1, ...) set their own navigation paths.

Initialize the widget

var nav = Alloy.createWidget("com.capnajax.navigation");
nav.init({
	drawerContent: Alloy.createController('drawer').getView()
});

The init() method sets the drawer content. This drawer controller remains constant for the life of the widget. It does not change due to navigation inside a tree or moving to a separate navigation tree.

Alloy.Globals.navigation = nav;

You may want to great a global reference to this navigation so that other screens can define their own navigation paths.

Set up the root of the tree

var firstController = Alloy.createController("window1");
nav.advance(firstController.getView());

The navigation has to start somewhere. Create a controller to define the first view in the navigation and advance into it. The advance() method moves deeper into the navigation tree, that is, navigates to the right.

Dive into the tree

Alloy.Globals.navigation.advance(Alloy.createController("window2").getView());

Again, use the advance method to navigate deeper into the tree.

Go back

Alloy.Globals.navigation.retreat();

The opposite of advance, this method goes back in the tree. If no parameters are provided, it'll go back one level in the tree. However it can also go back to a specific level in the tree (parameter is a positive integer), a specific number of steps back in the tree (parameter is a negative integer), or a specific view in the tree (parameter is a Ti.UI.View).

Go home. New home or old home?

Alloy.Globals.navigation.home(view);

This takes the navigation back to the top of the tree. If the view parameter is not provided, then this will take you to the root of the current navigation tree. If the view is provided however, the existing tree is destroyed and replaced with a new tree with the provided Yiew at its root.

drawersandnavigation's People

Contributors

thomasdelbert avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.