[TIMOB-24817] Android: ListView item template support CommonJS modules
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-10-12T22:30:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | TiAPI |
Labels | demo_app |
Reporter | Feon Sua Xin Miao |
Assignee | Gary Mathews |
Created | 2017-06-13T21:30:39.000+0000 |
Updated | 2018-11-28T18:25:55.000+0000 |
Description
According to [http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ListItem], the ListView item template only supports a limited set of view classes from the Ti.UI namespace. The
type
property sets the Ti.UI view to be used, i.e 'Ti.UI.Label'
var template = {
childTemplates: [
{
type: 'Ti.UI.ImageView',
bindId: '',
properties: { }
},
{
type: 'Ti.UI.Label',
bindId: '',
properties: { }
}
// supported views http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ListItem
],
events: { }
};
Instead of composing the listview's UI repeatedly, I would like to be able to use a javascript module in list template, i.e:
function Controller() {
var $ = this;
$.__views.container = Ti.UI.createView({
layout: "horizontal",
width: Ti.UI.SIZE,
backgroundColor: "transparent"
});
$.__views.rname = Ti.UI.createLabel({
text: "row"
});
$.__views.rimg = Ti.UI.createImageView({
image: 'img.png'
});
$.__views.container.add($.__views.rname);
$.__views.container.add($.__views.rimg);
_.extend($, $.__views);
_.extend($, exports);
}
module.exports = Controller;
Attachments
File | Date | Size |
---|---|---|
test.widget.zip | 2018-04-05T23:05:15.000+0000 | 3644 |
master: https://github.com/appcelerator/titanium_mobile/pull/9955
alloy: https://github.com/appcelerator/alloy/pull/892
holding off for equivalent iOS ticket: TIMOB-24776
Reopening ticket, it does not work properly with Alloy.
[~hknoechel] What does not work correctly?
I was unable to add a map-view instance (from Ti.Map) to a list-item template. I tried to export the view via a common-js module (
exports.getView = (args) => { return Map.createView(args)
, unfortunately without success.Verified the fix with SDK 7.5.0.v20181114112657 & CLI 7.0.8-master.4. Closing. Studio Ver: 5.1.2.201810301430 SDK Ver: 7.5.0.v20181114112657 OS Ver: 10.14 Xcode Ver: Xcode 10.1 Appc NPM: 4.2.13 Appc CLI: 7.0.8-master.4 Daemon Ver: 1.1.3 Ti CLI Ver: 5.1.1 Alloy Ver: 1.13.4 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 10.0.2 Devices: ⇨ google Nexus 5 (Android 6.0.1) ⇨ google Nexus 6P (Android 8.1.0)
I am also facing the same issue as Michael has reported above. Luckily Michael has provided a solution as well, but not sure when we can expect a 7.5.1 release as it's holding us not to use 7.5.0 at all because there are numerous apps using av.imageview rather than custom widgets.
I think we're experiencing same issue on android Error: Requested module not found: /alloy/widgets/AvImageview.ImageView/controllers/widget
fix is currently scheduled for 8.0.0 (https://github.com/appcelerator/titanium_mobile/pull/10491). You can change the listview.js yourself and create a custom 7.5.X if you need it now already. I've went back to the old listview.js since I don't use widgets inside a listview and it worked again for me.
Thanks Michael. The fact is that we (Richard Lustemberg, me and others) have a fork on which I'm fixing because this has broken our app on Android when using Av.ImageView module. Anyhow, the fix (https://github.com/appcelerator/titanium_mobile/pull/10491) is only for iOS, isn't it?
sorry, wrong PR. This one is the fix for Android: https://github.com/appcelerator/titanium_mobile/pull/10479
Thanks again Michael. By now, reverting the changes (https://github.com/appcelerator/titanium_mobile/pull/9955/files#diff-d91f84ce1f8aba65f9302707f8d4c438L83) is working, but other things are crashing. We've got review deeply to be able to move to 7.5 on android.