Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24817] Android: ListView item template support CommonJS modules

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-10-12T22:30:07.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsTiAPI
Labelsdemo_app
ReporterFeon Sua Xin Miao
AssigneeGary Mathews
Created2017-06-13T21:30:39.000+0000
Updated2018-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

FileDateSize
test.widget.zip2018-04-05T23:05:15.000+00003644

Comments

  1. Gary Mathews 2018-03-28

    master: https://github.com/appcelerator/titanium_mobile/pull/9955
  2. Gary Mathews 2018-03-30

    alloy: https://github.com/appcelerator/alloy/pull/892
  3. Christopher Williams 2018-05-23

    holding off for equivalent iOS ticket: TIMOB-24776
  4. Hans Knöchel 2018-08-03

    Reopening ticket, it does not work properly with Alloy.
  5. Gary Mathews 2018-08-09

    [~hknoechel] What does not work correctly?
  6. Hans Knöchel 2018-08-09

    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.
  7. Lokesh Choudhary 2018-11-14

    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)
  8. Michael Gangolf 2018-11-17

  9. Prashant Saini 2018-11-18

    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.
  10. Rodrigo Farfán 2018-11-28

    I think we're experiencing same issue on android Error: Requested module not found: /alloy/widgets/AvImageview.ImageView/controllers/widget
  11. Michael Gangolf 2018-11-28

    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.
  12. Rodrigo Farfán 2018-11-28

    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?
  13. Michael Gangolf 2018-11-28

    sorry, wrong PR. This one is the fix for Android: https://github.com/appcelerator/titanium_mobile/pull/10479
  14. Rodrigo Farfán 2018-11-28

    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.

JSON Source