[TIMOB-25459] iOS: toImage method needs parity with Android & Windows
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2017-11-10T01:05:07.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 7.0.0 |
| Components | Android |
| Labels | Android, toImage |
| Reporter | Jorge Macias Garcia |
| Assignee | Hans Knöchel |
| Created | 2017-10-30T13:28:08.000+0000 |
| Updated | 2017-11-15T05:26:33.000+0000 |
Description
When use toImage method on View we have a discrepance between iOS and the Android / Windows callback parameter
Sample:
index.js
$.addListener($.index, 'postlayout', function (e) {
$.box.toImage(function (e) {
if (OS_IOS) {
//e is a Event object who has a blob key: e.blob
$.img.setImage(e.blob);
} else if (OS_ANDROID || OS_WINDOWS) {
//e is a Ti.Blob instead a Event object
//e.blob -> undefined
$.img.setImage(e);
}
});
});
$.index.open();
index.xml
<Alloy>
<Window layout="vertical" backgroundColor="white">
<View id="box" width="Ti.UI.SIZE" height="Ti.UI.SIZE" backgroundColor="pink" layout="vertical" top="25">
<Label id="sample" text="This is my label" color="red"/>
<ImageView image="/images/some_sample_image.jpg"/>
</View>
<ImageView id="img"/>
</Window>
</Alloy>
This should be a doc-ticket. No callback should return values directly but inside a dictionary. Please confirm that Android also works with "e.blob", otherwise Android needs an adjustment.
No, Android doesn't works with e.blob notation.
To be considered for 7.0.0 as it's a breaking change.
PR: https://github.com/appcelerator/titanium_mobile/pull/9583 Test-Case:
var win = Ti.UI.createWindow(); var view = Ti.UI.createView({backgroundColor: 'green', width: 150, height: 150, top: 100}); var content = Ti.UI.createView({backgroundColor: 'blue', width: 45, height: 45}); var imageView = Ti.UI.createImageView({width: 150, height: 150, top: 300}); view.add(content); win.add(view); win.addEventListener('postlayout', function() { view.toImage(function(blob) { imageView.setImage(blob); }); }) win.add(imageView); win.open();FR Passed. PR merged.
[~bimmel] This is a breaking change, we should add it to the list of major changes.
[~hknoechel], consider it done.
Changes are in SDK 7.0.0.v20171114202841.