Skip to content

Commit 448e020

Browse files
manucorporatadamdbradley
authored andcommitted
fix(picker): making touchable fill all the available space
1 parent 446287e commit 448e020

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

src/components/datetime/datetime.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,17 +682,16 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
682682

683683
if (columns.length === 2) {
684684
var width = Math.max(columns[0], columns[1]);
685-
pickerColumns[0].columnWidth = pickerColumns[1].columnWidth = `${width * 16}px`;
685+
pickerColumns[0].align = 'right';
686+
pickerColumns[1].align = 'left';
687+
pickerColumns[0].optionsWidth = pickerColumns[1].optionsWidth = `${width * 17}px`;
686688

687689
} else if (columns.length === 3) {
688690
var width = Math.max(columns[0], columns[2]);
689-
pickerColumns[1].columnWidth = `${columns[1] * 16}px`;
690-
pickerColumns[0].columnWidth = pickerColumns[2].columnWidth = `${width * 16}px`;
691-
692-
} else if (columns.length > 3) {
693-
columns.forEach((col, i) => {
694-
pickerColumns[i].columnWidth = `${col * 12}px`;
695-
});
691+
pickerColumns[0].align = 'right';
692+
pickerColumns[1].columnWidth = `${columns[1] * 17}px`;
693+
pickerColumns[0].optionsWidth = pickerColumns[2].optionsWidth = `${width * 17}px`;
694+
pickerColumns[2].align = 'left';
696695
}
697696
}
698697

src/components/picker/picker-component.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { GestureController, BlockerDelegate, BLOCK_ALL } from '../../gestures/ge
2121
selector: '.picker-col',
2222
template:
2323
'<div *ngIf="col.prefix" class="picker-prefix" [style.width]="col.prefixWidth">{{col.prefix}}</div>' +
24-
'<div class="picker-opts" #colEle [style.width]="col.optionsWidth">' +
24+
'<div class="picker-opts" #colEle [style.max-width]="col.optionsWidth">' +
2525
'<button *ngFor="let o of col.options; let i=index"' +
2626
'[class.picker-opt-disabled]="o.disabled" ' +
2727
'class="picker-opt" disable-activated (click)="optClick($event, i)">' +
@@ -30,7 +30,7 @@ import { GestureController, BlockerDelegate, BLOCK_ALL } from '../../gestures/ge
3030
'</div>' +
3131
'<div *ngIf="col.suffix" class="picker-suffix" [style.width]="col.suffixWidth">{{col.suffix}}</div>',
3232
host: {
33-
'[style.min-width]': 'col.columnWidth',
33+
'[style.max-width]': 'col.columnWidth',
3434
'[class.picker-opts-left]': 'col.align=="left"',
3535
'[class.picker-opts-right]': 'col.align=="right"',
3636
}
@@ -497,9 +497,6 @@ export class PickerCmp {
497497

498498
// clean up dat data
499499
data.columns = data.columns.map(column => {
500-
if (!isPresent(column.columnWidth)) {
501-
column.columnWidth = (100 / data.columns.length) + '%';
502-
}
503500
if (!isPresent(column.options)) {
504501
column.options = [];
505502
}
@@ -642,4 +639,4 @@ let pickerIds = -1;
642639
const PICKER_OPT_SELECTED = 'picker-opt-selected';
643640
const DECELERATION_FRICTION = 0.97;
644641
const FRAME_MS = (1000 / 60);
645-
const MAX_PICKER_SPEED = 50;
642+
const MAX_PICKER_SPEED = 60;

src/components/picker/picker.scss

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,29 @@ ion-picker-cmp {
5555
position: relative;
5656
display: flex;
5757

58-
max-height: 100%;
58+
flex: 1;
59+
justify-content: center;
60+
61+
height: 100%;
62+
63+
box-sizing: content-box;
5964
}
6065

6166
.picker-opts {
6267
position: relative;
6368

64-
width: 100%;
65-
min-width: 50px;
69+
flex: 1;
70+
6671
max-width: 100%;
6772
}
6873

6974
.picker-prefix {
7075
position: relative;
7176

72-
flex: 1;
77+
flex: 2;
7378

7479
min-width: 45%;
80+
max-width: 50%;
7581

7682
text-align: right;
7783
white-space: nowrap;
@@ -80,9 +86,10 @@ ion-picker-cmp {
8086
.picker-suffix {
8187
position: relative;
8288

83-
flex: 1;
89+
flex: 2;
8490

8591
min-width: 45%;
92+
max-width: 50%;
8693

8794
text-align: left;
8895
white-space: nowrap;
@@ -115,11 +122,11 @@ ion-picker-cmp {
115122
opacity: 0;
116123
}
117124

118-
.picker-opts-left .picker-opt {
125+
.picker-opts-left {
119126
justify-content: flex-start;
120127
}
121128

122-
.picker-opts-right .picker-opt {
129+
.picker-opts-right {
123130
justify-content: flex-end;
124131
}
125132

src/components/picker/test/basic/app-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ export class E2EPage {
183183
picker.addColumn({
184184
name: 'hour',
185185
suffix: 'hour',
186-
columnWidth: '30%',
187186
optionsWidth: '50px',
187+
align: 'right',
188188
options: Array.apply(null, {length: 23}).map(Number.call, Number)
189189
});
190190

@@ -200,8 +200,8 @@ export class E2EPage {
200200
picker.addColumn({
201201
name: 'min',
202202
suffix: 'min',
203-
columnWidth: '40%',
204203
optionsWidth: '80px',
204+
align: 'left',
205205
options: minuteOptions
206206
});
207207

0 commit comments

Comments
 (0)