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

[TIMOB-15910] Android: Implement Ti.UI.Android.DrawerLayout #9091

Merged
merged 9 commits into from Aug 23, 2017

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented May 26, 2017

TEST CASE
var win = Ti.UI.createWindow(),
    leftView = Ti.UI.createView({backgroundColor:'red'}),
    centerView = Ti.UI.createView({backgroundColor:'yellow'}),
    rightView = Ti.UI.createView({backgroundColor:'orange'}),
    drawer = Ti.UI.Android.createDrawerLayout({
        leftView: leftView,
        centerView: centerView,
        rightView: rightView
    }),
    btn = Ti.UI.createButton({title: 'RIGHT'});

btn.addEventListener('click', function() {
    drawer.toggleRight();
});

centerView.add(btn);

win.addEventListener('open', function(){
    var activity = win.getActivity(),
        actionbar = activity.getActionBar();

    if (actionbar) {
        actionbar.displayHomeAsUp = true;
        actionbar.onHomeIconItemSelected = function() {
            drawer.toggleLeft();
        };
    }
});

win.add(drawer);
win.open();

JIRA Ticket

/**
* @module.api
*/
public static final String EVENT_DRAWER_SLIDE = "drawerslide";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name it open, close and slide instead? Feels more unified with other related API's. Thx!

@jquick-axway
Copy link
Contributor

jquick-axway commented Aug 22, 2017

@garymathews, I have an interesting idea.

I suspect that many Titanium developers may want to implement a tab group like feature via your new navigation drawer feature since that type of interface is commonly implemented on Android. Theoretically, we should be able to do this now by using a Ti.UI.TabGroup with the tabs hidden via the TabGroup.disableTabNavigation(true) method... and when a DrawerLayout button has been tapped, it can display one of the tabs via code. If we can prove that this will work, then it'll be worth documenting. What do you think?

Edit:
This can be done via a ScrollableView instead of a TabGroup. I have a working example here...
https://jira.appcelerator.org/browse/TIMOB-25535#comment-436105

import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove wildcard import.

Copy link
Contributor

@ypbnv ypbnv left a comment

Choose a reason for hiding this comment

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

Besides the import everything else looks good.

@lokeshchdhry
Copy link
Contributor

FR Passed.

The drawer layout works as expected. The left, middle & the right views are shown with the appropriate way of unhiding them. Also, different views like imageView, Label, TextView, tableview, listview etc can be successfully added to the left, middle & right drawer views.
The properties & methods seem to work as expected.

Studio Ver: 4.9.1.201707200100
SDK Ver: 7.0.0 Local build
OS Ver: 10.12.3
Xcode Ver: Xcode 8.3.3
Appc NPM: 4.2.9
Appc CLI: 6.2.3
Ti CLI Ver: 5.0.14
Alloy Ver: 1.9.13
Node Ver: 6.10.1
Java Ver: 1.8.0_101
Devices: ⇨ google Nexus 5 --- Android 6.0.1
⇨ google Pixel --- Android 7.1.1
Emulator: Android 4.4.2

@lokeshchdhry lokeshchdhry merged commit 111153d into tidev:master Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants