Skip to content

Commit f18e1e9

Browse files
committed
Fix for issue 5, yet again
1 parent 5f64ab3 commit f18e1e9

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

app/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"os:mobileweb": {},
1010
"os:windows": {},
1111
"dependencies": {
12-
"com.skypanther.segmentedcontrol": "1.0.4"
12+
"com.skypanther.segmentedcontrol": "1.0.5"
1313
}
1414
}

app/widgets/com.skypanther.segmentedcontrol/controllers/widget.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ exports.init = function (labels, cb) {
5050
} else if (OS_IOS) {
5151
if ($.segCtrlWrapper.width.slice(-1) === '%') {
5252
calculatedWidth = Ti.Platform.displayCaps.platformWidth * parseInt($.segCtrlWrapper.width) / 100;
53-
console.log('Calculated the width of ' + args.id + ' to be ' + calculatedWidth);
53+
// console.log('Calculated the width of ' + args.id + ' to be ' + calculatedWidth);
5454
} else if (isNaN(parseInt($.segCtrlWrapper.width))) {
5555
// iOS handles rotation, but the wrapper width needs to be calculated to be
5656
// the smaller of the height or width to avoid layout issues
@@ -69,10 +69,11 @@ exports.init = function (labels, cb) {
6969

7070
// make our buttons
7171
for (var i = 0, j = labels.length; i < j; i++) {
72-
if (!wrapperWidthIsCalculated && i === j - 1 && !ios8Plus()) {
72+
if (!wrapperWidthIsCalculated && i === j - 1 && !onThreeDPDevice()) {
7373
// if an explicit width has been set, we need to shrink the last button
7474
// by 1 or it will be too wide for the container and won't be shown
7575
btnWidth = (parseInt(btnWidth) - 1);
76+
7677
if (OS_ANDROID) {
7778
btnWidth += 'dp';
7879
}
@@ -97,11 +98,13 @@ exports.init = function (labels, cb) {
9798

9899
// add the button dividers, if desired
99100
if (args.withDividers) {
101+
var left;
100102
for (var i = 0, j = labels.length - 1; i < j; i++) { // jshint ignore:line
103+
left = OS_ANDROID ? ((parseInt(btnWidth) * (i + 1) + 1) + 'dp') : (btnWidth * (i + 1) + (!onThreeDPDevice() ? 1 : -1));
101104
$.segCtrlWrapper.add(Ti.UI.createView({
102105
width: OS_ANDROID ? '1dp' : 1,
103106
height: height,
104-
left: OS_ANDROID ? ((parseInt(btnWidth) * (i + 1) + 1) + 'dp') : (btnWidth * (i + 1) + (!ios8Plus() ? 1 : -1)),
107+
left: left,
105108
backgroundColor: selectedButtonColor,
106109
zIndex: 10
107110
}));
@@ -232,10 +235,7 @@ exports.enableAllButtons = function () {
232235
};
233236

234237

235-
function ios8Plus() {
236-
if (OS_IOS && parseInt(Ti.Platform.version.split(".")[0]) >= 7) {
237-
return true;
238-
} else {
239-
return false;
240-
}
238+
function onThreeDPDevice() {
239+
//if we are on a 3DP device (6+ or 6s+) we need to slightly adjust the button width
240+
return OS_IOS && parseInt(Ti.Platform.displayCaps.logicalDensityFactor) === 3;
241241
}

app/widgets/com.skypanther.segmentedcontrol/widget.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "com.skypanther.segmentedcontrol",
44
"description": "Cross-platform tabbed bar (segmented control) component for Appcelerator Titanium Alloy projects.",
55
"author": "Tim Poulsen, @skypanther",
6-
"version": "1.0.4",
6+
"version": "1.0.5",
77
"copyright": "Copyright (c) 2016, Tim Poulsen",
88
"license": "MIT",
99
"min-alloy-version": "1.5.1",

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $ gittio install com.skypanther.segmentedcontrol
2525

2626
```json
2727
"dependencies": {
28-
"com.skypanther.segmentedcontrol": "1.0.4"
28+
"com.skypanther.segmentedcontrol": "1.0.5"
2929
}
3030
```
3131

@@ -99,7 +99,8 @@ Additionally, most other properties you set on the widget (via its xml tag or id
9999

100100
# History
101101

102-
* 29-Feb-2016: Ver 1.0.3 resolves #5, thanks Will Dent! (last button in set not filling entire area on iPhone 6s+)
102+
* 3-Mar-2016: Ver 1.0.5 resolves #5, yet another attempt! (it would help if I owned more iOS devices, donations welcome 😀)
103+
* 29-Feb-2016: Ver 1.0.4 resolves #5, thanks Will Dent! (last button in set not filling entire area on iPhone 6s+)
103104
* 16-Feb-2016: Ver 1.0.3 resolves last button in set not filling entire area on iPhone 6s+
104105
* 08-Feb-2016: Ver 1.0.2 resolves issue where selecting/setIndexing a button didn't deselect the other buttons
105106
* 05-Feb-2016: Ver 1.0.1 resolves layout issues on larger iOS devices when using percentage-based widths

0 commit comments

Comments
 (0)