Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24264] iOS: Support ListView editActions with "image" property

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterFrancisco Ruaro Varisco
AssigneeUnknown
Created2016-12-29T01:46:17.000+0000
Updated2018-02-28T19:55:32.000+0000

Description

Hey, That's the first time I'm trying to contribute to Titanium SDK and I want to enable the SDK to put images on the background of the listViewActionRow. When you swipe left if opens what you have set up on your 'editActions' component. Today this component only accepts the following properties: * color * identifier * style * title I'd like to have the property "image" there as well and once you set it shows the image in the background of the "button". This is possible to create and I've forked the Titanium SDK framework and made a test (Check the TODO comments): https://github.com/xicovarisco/titanium_mobile/commit/b4ce3930023eebed5f9f20f465a6da6a9a1f4249 In this case I've changed the file 'TiUIListView.m' in accordance with this post: http://stackoverflow.com/questions/29421894/uitableviewrowaction-image-for-title The result can be found in the attachment. The only thing I'm not sure how you guys deal with is: * Should I get this image as a property like the other items? (e.g. TiColor* color = [TiUtils colorValue:@"color" properties:prop]; ) * If so, I saw that you don't have a method called imageValue on your TiUtils file. Should we create it? If we sort this out we can easily release this new feature to everyone else. I'm sure everyone will appreciate it.

Attachments

FileDateSize
Screen Shot 2016-12-29 at 11.42.31 am.png2016-12-29T01:42:42.000+0000159370
Simulator Screen Shot 29 Dec 2016, 12.05.26.png2016-12-29T11:05:51.000+000025022

Comments

  1. Matthew Delmarter 2016-12-29

    Looks great Francisco - can't wait to use this feature.
  2. Hans Knöchel 2016-12-29

    Cool idea. Here is a hint on the [possible implementation](https://github.com/appcelerator/titanium_mobile/compare/master...hansemannn:TIMOB-24264?expand=1). Some general problems with this idea: - The image uses a pattern, so smaller images are always repeated - The width of the action is determined by the title, so without a "blank title" it looks odd - You cannot set the color property when using the image property because it would override it (actually fixed that with a hack in [this commit](https://github.com/hansemannn/titanium_mobile/commit/10f02d01c6e87726f335e4144f3dcf59a012465b)) This are native problems, not Titanium-specific ones. Example:
       var window = Ti.UI.createWindow();
       window.add(Ti.UI.createListView({
           sections: [Ti.UI.createListSection({
               items: [{
                   properties: {
                       title: "Test 1",
                       canEdit: true,
                       editActions: [{
                           title: "     ",
                           color: "orange",
                           image: "images/close3.png"
                       }]
                   }
               }]
           })]
       })) 
       
       var nav = Ti.UI.iOS.createNavigationWindow({
           window: window
       })
       nav.open();
       
    !Simulator Screen Shot 29 Dec 2016, 12.05.26.png|thumbnail!
  3. Francisco Ruaro Varisco 2016-12-30

    That's good @hans. Some thoughts: 1) I don't think it would be a problem to ask Titanium developer to put "blank titles" if they want to use images on editActions. (As long as we have it documented well) 2) We could create a hacky way to input blank characters to the title if the developer doesn't set the property 'title' (We could calculate the image size and based on some algorithm we input the blank spaces to fit the image), but I don't think this is a good solution, because we will be going against what Apple provides us today. I would stick to what we can do. 3) Probably in the future Apple will revise this API and change some things to make it more "maintainable" for developers, and when this happens we better not have it hacked. Other problem I found with this solution: 1) The image needs to have all the specific-sizes (@2x, @3x) to get it to work, otherwise it doesn't load the image. (I'm not sure if this is an Apple restriction for it or a Titanium-specific stuff) I'll create a pull request with the code you have created. Thanks

JSON Source