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

feat(android): add separate lock mode for left and right drawers #11271

Merged
merged 5 commits into from Nov 9, 2020

Conversation

drauggres
Copy link
Contributor

@drauggres drauggres commented Oct 9, 2019

JIRA: https://jira.appcelerator.org/browse/TIMOB-25556

Main goal of the ticket (as I see it):

allow users to set the lock mode individually for each view

Two new properties (methods) for Ti.UI.Android.DrawerLayout:

  • leftDrawerLockMode
  • rightDrawerLockMode

NOTICE: defined (not MODE_UNDEFINED) individual lock mode (e.g. leftDrawerLockMode=MODE_UNLOCKED or leftDrawerLockMode=MODE_LOCKED_CLOSED) will prevail over defined general (drawerLockMode) lock mode. This is native implementation feature.

TEST CASE

const win = Ti.UI.createWindow(),
    leftView = Ti.UI.createView({
        backgroundColor: "#333",
        layout: "vertical"
    }),
    centerView = Ti.UI.createView({
        backgroundColor: "#fff"
    }),
    rightView = Ti.UI.createView({
        backgroundColor: "#333"
    }),
    drawer = Ti.UI.Android.createDrawerLayout({
        leftView: leftView,
        centerView: centerView,
        rightView: rightView
    }),
    menu = Ti.UI.createView({
        layout: "vertical"
    }),
    btn1 = Ti.UI.createButton({
        title: 'Open Left'
    }),
    btn2 = Ti.UI.createButton({
        title: 'Open Right'
    }),
    btn3 = Ti.UI.createButton({
        title: 'All MODE_LOCKED_CLOSED'
    }),
    btn4 = Ti.UI.createButton({
        title: 'Left MODE_LOCKED_CLOSED'
    }),
    btn5 = Ti.UI.createButton({
        title: 'Right MODE_LOCKED_CLOSED'
    }),
    btn6 = Ti.UI.createButton({
        title: 'Left MODE_UNLOCKED'
    }),
    btn7 = Ti.UI.createButton({
        title: 'Right MODE_UNLOCKED'
    }),
    btn8 = Ti.UI.createButton({
        title: 'All MODE_UNLOCKED'
    }),
    btn9 = Ti.UI.createButton({
        title: 'Left MODE_UNDEFINED'
    }),
    btn10 = Ti.UI.createButton({
        title: 'Right MODE_UNDEFINED'
    }),
    btn11 = Ti.UI.createButton({
        title: 'All MODE_UNDEFINED'
    });


for (let i = 0; i < 10; ++i) {
    leftView.add(Ti.UI.createLabel({
        color: "#fff",
        text: "Item",
        top: 10,
        bottom: 10,
        height: Ti.UI.SIZE
    }));
}

btn2.addEventListener('click', function() {
    drawer.toggleRight();
});
btn1.addEventListener('click', function() {
    drawer.toggleLeft();
});
btn3.addEventListener('click', function() {
    drawer.drawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
});
btn4.addEventListener('click', function() {
    drawer.leftDrawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
});
btn5.addEventListener('click', function() {
    drawer.rightDrawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
});
btn6.addEventListener('click', function() {
    drawer.leftDrawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNLOCKED;
});
btn7.addEventListener('click', function() {
    drawer.rightDrawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNLOCKED;
});
btn8.addEventListener('click', function() {
    drawer.drawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNLOCKED;
});
btn9.addEventListener('click', function() {
    drawer.leftDrawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNDEFINED;
});
btn10.addEventListener('click', function() {
    drawer.rightDrawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNDEFINED;
});
btn11.addEventListener('click', function() {
    drawer.drawerLockMode = Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNDEFINED;
});

centerView.add(menu);
menu.add(btn1);
menu.add(btn2);
menu.add(btn3);
menu.add(btn4);
menu.add(btn5);
menu.add(btn6);
menu.add(btn7);
menu.add(btn8);
menu.add(btn9);
menu.add(btn10);
menu.add(btn11);

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

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

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

@build
Copy link
Contributor

build commented Oct 9, 2019

Fails
🚫

🔬 There are library changes, but no changes to the unit tests. That's OK as long as you're refactoring existing code, but will require an admin to merge this PR. Please see README.md#unit-tests for docs on unit testing.

🚫 Tests have failed, see below for more information.
Messages
📖

💾 Here's the generated SDK zipfile.

📖 🎉 Another contribution from our awesome community member, drauggres! Thanks again for helping us make Titanium SDK better. 👍
📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖 ❌ 9 tests have failed There are 9 tests failing and 964 skipped out of 12521 total tests.

Tests:

ClassnameNameTimeError
ios.macos.Titanium.Blobimage dimensions should be reported in pixels (10.15.7)0.061
Error: expected 6 to be 11
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.blob.test.js:483:33
ios.macos.Titanium.UI.Semantic Colorsuse semantic colors via color properties (10.15.7)0.008
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/systemredcolor_light.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.test.js:363:34
ios.macos.Titanium.UI.View.borderRadius corners1 value with shadow effect (10.15.7)0.006
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadiusWithShadow30px_1x.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1232:39
ios.macos.Titanium.UI.View.borderRadius corners1 value to create circle (10.15.7)0.005
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadius30px.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1200:39
ios.macos.Titanium.UI.View.borderRadius cornersset property post layout (10.15.7)0.006
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadius12px_12_1x.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1169:39
ios.macos.Titanium.UI.View.borderRadius corners2 values in Array (10.15.7)0.004
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadius12px_12_1x.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1135:41
ios.macos.Titanium.UI.View.borderRadius corners2 values in String (10.15.7)0.005
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadius12px_12_1x.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1101:41
ios.macos.Titanium.UI.View.borderRadius corners4 values in Array (10.15.7)0.005
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadius12px_12_12dp_12_1x.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1068:41
ios.macos.Titanium.UI.View.borderRadius corners4 values in String (10.15.7)0.011
Error: expected 'Ti.UI.View' view to match snapshot image: snapshots/borderRadius12px_12_12dp_12_1x.png
    width
fail@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:275:23
value@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/node_modules/should/cjs/should.js:356:23
postlayout@file:///Users/build/jenkins/workspace/ium-sdk_titanium_mobile_PR-11271/tmp/mocha/build/iphone/build/Products/Debug-maccatalyst/mocha.app/Contents/Resources/ti.ui.view.test.js:1034:41

Generated by 🚫 dangerJS against 232c00d

@sgtcoolguy sgtcoolguy removed this from the 8.3.0 milestone Dec 10, 2019
@sgtcoolguy
Copy link
Contributor

@garymathews Should this PR be used in preference to #10970 ? If so, can you do a CR?

@build build added this to the 9.3.0 milestone Nov 6, 2020
@ssekhri
Copy link

ssekhri commented Nov 6, 2020

FR Passed.
The individual drawer lock mode defined using leftDrawerLockMode and rightDrawerLockMode working fine.
As mentioned in the comments above the lock mode on an individual drawer would prevail over the general drawer lock mode.

Verified on:
Mac OS: 10.15.4
SDK: 9.3.0.v20201105170329
Appc CLI: 8.1.1
JDK: 11.0.6
Node: 12.16.1
Studio: 6.0.0.202005141803
Device: Nexus4(v5.1.1) device, Pixel 3 XL(v11.0) emulator

@sgtcoolguy sgtcoolguy merged commit e51c84b into tidev:master Nov 9, 2020
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