Skip to content

Commit

Permalink
feat(android): add collapseToolbar support (#1360)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga authored Mar 11, 2023
1 parent 792ba0f commit c3f5e95
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.parse = function(node, state) {
_.extend(state, {
proxyPropertyDefinition: {
parents: [
'Ti.UI.Android.CollapseToolbar',
'Ti.UI.iPad.Popover'
]
}
});
return require('./Ti.UI.Android.CollapseToolbar._ProxyProperty').parse(node, state);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const _ = require('lodash');

exports.parse = function(node, state) {
_.extend(state, {
proxyPropertyDefinition: {
parents: [
'Ti.UI.Android.CollapseToolbar',
'Ti.UI.iPad.Popover'
]
}
});
return require('./Alloy.Abstract._ProxyProperty').parse(node, state);
};
34 changes: 34 additions & 0 deletions Alloy/commands/compile/parsers/Ti.UI.Android.CollapseToolbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const _ = require('lodash'),
U = require('../../../utils'),
MIN_VERSION = '12.1.0';

exports.parse = function(node, state) {
return require('./base').parse(node, state, parse);
};

function parse(node, state, args) {
const tiappSdkVersion = tiapp.getSdkVersion();
if (tiapp.version.lt(tiappSdkVersion, MIN_VERSION)) {
U.die(`Ti.UI.Android.CollapseToolbar requires Titanium SDK ${MIN_VERSION}+`);
}

var children = U.XML.getElementsFromNodes(node.childNodes),
code = '',
extras = [],
proxyProperties = {};

// add all proxy properties at creation time
_.each(proxyProperties, function(v, k) {
extras.push([k, v]);
});

// if we got any extras, add them to the state
if (extras.length) {
state.extraStyle = styler.createVariableStyle(extras);
}

viewState = require('./default').parse(node, state);
viewState.code = code + viewState.code;

return viewState;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var _ = require('lodash');

exports.parse = function(node, state) {
console.log(' Ti.UI.Android.DrawerLayout');
_.extend(state, {
proxyPropertyDefinition: {
parents: [
Expand Down
6 changes: 4 additions & 2 deletions Alloy/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ exports.IMPLICIT_NAMESPACES = {
TitleControl: 'Ti.UI.Window',
WindowToolbar: 'Ti.UI.Window',

// Ti.UI.iPad.Popover
ContentView: 'Ti.UI.iPad.Popover',
ContentView: isTitanium && Ti.Platform.osname === 'android' ?
'Ti.UI.Android.CollapseToolbar' : 'Ti.UI.iPad.Popover',

CollapseToolbar: 'Ti.UI.Android',

DrawerLayout: 'Ti.UI.Android',
LeftView: 'Ti.UI.Android.DrawerLayout',
Expand Down

0 comments on commit c3f5e95

Please sign in to comment.