Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20403] iOS: ProgressBar tracker position not set correctly before layout

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-03-28T21:26:03.000+0000
Affected Version/sRelease 5.2.0
Fix Version/sRelease 5.4.0
ComponentsiOS
Labelsprogressbar, qe-5.4.0
ReporterFokke Zandbergen
AssigneeHans Knöchel
Created2016-02-15T13:04:51.000+0000
Updated2016-06-10T00:10:16.000+0000

Description

The following code sample and attached screenshots shows that the min and max property are ignored when setting the tracker position at creation. Not until after layout will setting the value result in the proper position. In the code we hardcode the default 0/1 min/max and then calculate the value back to this using the min/max set bij the user. It seems like we don't do this at creation and any value > the hardcoded max will show as a full progress bar. https://github.com/appcelerator/titanium_mobile/blob/1607237763f9e490e41d98b8d711ac49eeb01043/iphone/Classes/TiUIProgressBar.m#L159
var win = Ti.UI.createWindow({
  backgroundColor: 'white'
});

// OK: default min:0, max:1 with value:0.5
win.add(Ti.UI.createProgressBar({
  top: 50,
  width: 250,
  value: 0.5
}));

// OK: set min:0, max:1 with value:0.5
win.add(Ti.UI.createProgressBar({
  top: 100,
  width: 250,
  min: 0,
  max: 1,
  value: 0.5
}));

// WRONG: min:0, max:10 with value:5 (shows as value:10)
win.add(Ti.UI.createProgressBar({
  top: 150,
  width: 250,
  min: 0,
  max: 10,
  value: 5
}));

// WRONG: min:0, max:10 with value:0.5 (shows above is because at creation min/max are ignored to calculate value position)
win.add(Ti.UI.createProgressBar({
  top: 200,
  width: 250,
  min: 0,
  max: 10,
  value: 0.5
}));

// WRONG: min:0, max:10 with value:5 (shows it not just fails at creation)
var pb1 = Ti.UI.createProgressBar({
  top: 250,
  width: 250,
  min: 0,
  max: 10,
  value: 5
});
pb1.value = 5;
win.add(pb1);

// OK: min:0, max:10 with value:5 (shows it fails before layout)
var pb2 = Ti.UI.createProgressBar({
  top: 300,
  width: 250,
  min: 0,
  max: 10,
  value: 5
});
win.add(pb2);

win.open();
pb2.value = 5;

Attachments

FileDateSize
Simulator Screen Shot 15 Feb 2016 14.01.38.png2016-02-15T13:01:42.000+000016896

Comments

  1. Chee Kiat Ng 2016-02-15

    Do we know if this is a regression?
  2. Fokke Zandbergen 2016-02-16

    No, same result with 5.1.2.GA
  3. Hans Knöchel 2016-03-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/7887
  4. Harry Bryant 2016-06-10

    Verified as fixed, compared the progress bars against the correct positions stated in the comments of the sample code, and found no inconsistencies. Tested On: iPhone 6S (9.3.2) Device Mac OSX El Capitan 10.11.5 Ti SDK: 5.4.0.v20160608165242 Appc Studio: 4.6.0.201605201934 Appc NPM: 4.2.7-2 App CLI: 5.4.0-15 Xcode 7.3 Node v4.2.6 *Closing ticket.*

JSON Source