@@ -38,16 +38,13 @@ public static List<Widget> listGenerate(int count, listGenerateDelegate func) {
38
38
39
39
public class _DatePickerLayoutDelegate : MultiChildLayoutDelegate {
40
40
public _DatePickerLayoutDelegate (
41
- List < float > columnWidths ,
42
- int textDirectionFactor
41
+ List < float > columnWidths
43
42
) {
44
43
D . assert ( columnWidths != null ) ;
45
44
this . columnWidths = columnWidths ;
46
- this . textDirectionFactor = textDirectionFactor ;
47
45
}
48
46
49
47
public readonly List < float > columnWidths ;
50
- public readonly int textDirectionFactor ;
51
48
52
49
public override void performLayout ( Size size ) {
53
50
float remainingWidth = size . width ;
@@ -57,21 +54,19 @@ public override void performLayout(Size size) {
57
54
58
55
float currentHorizontalOffset = 0.0f ;
59
56
for ( int i = 0 ; i < this . columnWidths . Count ; i ++ ) {
60
- int index = this . textDirectionFactor == 1 ? i : this . columnWidths . Count - i - 1 ;
61
- float childWidth = this . columnWidths [ index ] + CupertinoDatePickerUtils . _kDatePickerPadSize * 2 ;
62
- if ( index == 0 || index == this . columnWidths . Count - 1 ) {
57
+ float childWidth = this . columnWidths [ i ] + CupertinoDatePickerUtils . _kDatePickerPadSize * 2 ;
58
+ if ( i == 0 || i == this . columnWidths . Count - 1 ) {
63
59
childWidth += remainingWidth / 2 ;
64
60
}
65
61
66
- this . layoutChild ( index , BoxConstraints . tight ( new Size ( childWidth , size . height ) ) ) ;
67
- this . positionChild ( index , new Offset ( currentHorizontalOffset , 0.0f ) ) ;
62
+ this . layoutChild ( i , BoxConstraints . tight ( new Size ( childWidth , size . height ) ) ) ;
63
+ this . positionChild ( i , new Offset ( currentHorizontalOffset , 0.0f ) ) ;
68
64
currentHorizontalOffset += childWidth ;
69
65
}
70
66
}
71
67
72
68
public override bool shouldRelayout ( MultiChildLayoutDelegate oldDelegate ) {
73
- return this . columnWidths != ( ( _DatePickerLayoutDelegate ) oldDelegate ) . columnWidths
74
- || this . textDirectionFactor != ( ( _DatePickerLayoutDelegate ) oldDelegate ) . textDirectionFactor ;
69
+ return this . columnWidths != ( ( _DatePickerLayoutDelegate ) oldDelegate ) . columnWidths ;
75
70
}
76
71
}
77
72
@@ -231,8 +226,7 @@ BuildContext context
231
226
text : new TextSpan (
232
227
style : DefaultTextStyle . of ( context ) . style ,
233
228
text : longestText
234
- ) ,
235
- textDirection : Directionality . of ( context )
229
+ )
236
230
) ;
237
231
238
232
@@ -244,7 +238,6 @@ BuildContext context
244
238
delegate Widget _ColumnBuilder ( float offAxisFraction , TransitionBuilder itemPositioningBuilder ) ;
245
239
246
240
class _CupertinoDatePickerDateTimeState : State < CupertinoDatePicker > {
247
- public int textDirectionFactor ;
248
241
public CupertinoLocalizations localizations ;
249
242
public Alignment alignCenterLeft ;
250
243
public Alignment alignCenterRight ;
@@ -288,11 +281,10 @@ public override void didUpdateWidget(StatefulWidget oldWidget) {
288
281
289
282
public override void didChangeDependencies ( ) {
290
283
base . didChangeDependencies ( ) ;
291
- this . textDirectionFactor = Directionality . of ( this . context ) == TextDirection . ltr ? 1 : - 1 ;
292
284
293
285
this . localizations = CupertinoLocalizations . of ( this . context ) ;
294
- this . alignCenterLeft = this . textDirectionFactor == 1 ? Alignment . centerLeft : Alignment . centerRight ;
295
- this . alignCenterRight = this . textDirectionFactor == 1 ? Alignment . centerRight : Alignment . centerLeft ;
286
+ this . alignCenterLeft = Alignment . centerLeft ;
287
+ this . alignCenterRight = Alignment . centerRight ;
296
288
estimatedColumnWidths . Clear ( ) ;
297
289
}
298
290
@@ -486,21 +478,17 @@ public override Widget build(BuildContext context) {
486
478
var _i = i ;
487
479
float offAxisFraction = 0.0f ;
488
480
if ( _i == 0 ) {
489
- offAxisFraction = - 0.5f * this . textDirectionFactor ;
481
+ offAxisFraction = - 0.5f ;
490
482
}
491
483
else if ( _i >= 2 || columnWidths . Count == 2 ) {
492
- offAxisFraction = 0.5f * this . textDirectionFactor ;
484
+ offAxisFraction = 0.5f ;
493
485
}
494
486
495
487
EdgeInsets padding = EdgeInsets . only ( right : CupertinoDatePickerUtils . _kDatePickerPadSize ) ;
496
488
if ( _i == columnWidths . Count - 1 ) {
497
489
padding = padding . flipped ;
498
490
}
499
491
500
- if ( this . textDirectionFactor == - 1 ) {
501
- padding = padding . flipped ;
502
- }
503
-
504
492
pickers . Add ( new LayoutId (
505
493
id : _i ,
506
494
child : pickerBuilders [ _i ] (
@@ -532,8 +520,7 @@ public override Widget build(BuildContext context) {
532
520
style : CupertinoDatePickerUtils . _kDefaultPickerTextStyle ,
533
521
child : new CustomMultiChildLayout (
534
522
layoutDelegate : new _DatePickerLayoutDelegate (
535
- columnWidths : columnWidths ,
536
- textDirectionFactor : this . textDirectionFactor
523
+ columnWidths : columnWidths
537
524
) ,
538
525
children : pickers
539
526
)
@@ -543,7 +530,6 @@ public override Widget build(BuildContext context) {
543
530
}
544
531
545
532
class _CupertinoDatePickerDateState : State < CupertinoDatePicker > {
546
- int textDirectionFactor ;
547
533
CupertinoLocalizations localizations ;
548
534
549
535
Alignment alignCenterLeft ;
@@ -566,10 +552,9 @@ public override void initState() {
566
552
567
553
public override void didChangeDependencies ( ) {
568
554
base . didChangeDependencies ( ) ;
569
- this . textDirectionFactor = Directionality . of ( this . context ) == TextDirection . ltr ? 1 : - 1 ;
570
555
this . localizations = CupertinoLocalizations . of ( this . context ) ;
571
- this . alignCenterLeft = this . textDirectionFactor == 1 ? Alignment . centerLeft : Alignment . centerRight ;
572
- this . alignCenterRight = this . textDirectionFactor == 1 ? Alignment . centerRight : Alignment . centerLeft ;
556
+ this . alignCenterLeft = Alignment . centerLeft ;
557
+ this . alignCenterRight = Alignment . centerRight ;
573
558
this . estimatedColumnWidths [ ( int ) _PickerColumnType . dayOfMonth ] = CupertinoDatePicker . _getColumnWidth (
574
559
_PickerColumnType . dayOfMonth , this . localizations , this . context ) ;
575
560
@@ -747,11 +732,8 @@ public override Widget build(BuildContext context) {
747
732
List < Widget > pickers = new List < Widget > ( ) ;
748
733
for ( int i = 0 ; i < columnWidths . Count ; i ++ ) {
749
734
var _i = i ;
750
- float offAxisFraction = ( _i - 1 ) * 0.3f * this . textDirectionFactor ;
735
+ float offAxisFraction = ( _i - 1 ) * 0.3f ;
751
736
EdgeInsets padding = EdgeInsets . only ( right : CupertinoDatePickerUtils . _kDatePickerPadSize ) ;
752
- if ( this . textDirectionFactor == - 1 ) {
753
- padding = EdgeInsets . only ( left : CupertinoDatePickerUtils . _kDatePickerPadSize ) ;
754
- }
755
737
756
738
pickers . Add ( new LayoutId (
757
739
id : _i ,
@@ -782,8 +764,7 @@ public override Widget build(BuildContext context) {
782
764
style : CupertinoDatePickerUtils . _kDefaultPickerTextStyle ,
783
765
child : new CustomMultiChildLayout (
784
766
layoutDelegate : new _DatePickerLayoutDelegate (
785
- columnWidths : columnWidths ,
786
- textDirectionFactor : this . textDirectionFactor
767
+ columnWidths : columnWidths
787
768
) ,
788
769
children :
789
770
pickers
@@ -834,7 +815,6 @@ public override State createState() {
834
815
}
835
816
836
817
class _CupertinoTimerPickerState : State < CupertinoTimerPicker > {
837
- int textDirectionFactor ;
838
818
CupertinoLocalizations localizations ;
839
819
Alignment alignCenterLeft ;
840
820
Alignment alignCenterRight ;
@@ -864,16 +844,15 @@ Widget _buildLabel(string text) {
864
844
865
845
public override void didChangeDependencies ( ) {
866
846
base . didChangeDependencies ( ) ;
867
- this . textDirectionFactor = Directionality . of ( this . context ) == TextDirection . ltr ? 1 : - 1 ;
868
847
this . localizations = CupertinoLocalizations . of ( this . context ) ;
869
- this . alignCenterLeft = this . textDirectionFactor == 1 ? Alignment . centerLeft : Alignment . centerRight ;
870
- this . alignCenterRight = this . textDirectionFactor == 1 ? Alignment . centerRight : Alignment . centerLeft ;
848
+ this . alignCenterLeft = Alignment . centerLeft ;
849
+ this . alignCenterRight = Alignment . centerRight ;
871
850
}
872
851
873
852
Widget _buildHourPicker ( ) {
874
853
return new CupertinoPicker (
875
854
scrollController : new FixedExtentScrollController ( initialItem : this . selectedHour ) ,
876
- offAxisFraction : - 0.5f * this . textDirectionFactor ,
855
+ offAxisFraction : - 0.5f ,
877
856
itemExtent : CupertinoDatePickerUtils . _kItemExtent ,
878
857
backgroundColor : CupertinoDatePickerUtils . _kBackgroundColor ,
879
858
onSelectedItemChanged : ( int index ) => {
@@ -890,14 +869,9 @@ Widget _buildHourPicker() {
890
869
float hourLabelWidth = this . widget . mode == CupertinoTimerPickerMode . hm
891
870
? CupertinoDatePickerUtils . _kPickerWidth / 4
892
871
: CupertinoDatePickerUtils . _kPickerWidth / 6 ;
893
- string semanticsLabel = this . textDirectionFactor == 1
894
- ? this . localizations . timerPickerHour ( index ) + this . localizations . timerPickerHourLabel ( index )
895
- : this . localizations . timerPickerHourLabel ( index ) + this . localizations . timerPickerHour ( index ) ;
896
872
return new Container (
897
873
alignment : this . alignCenterRight ,
898
- padding : this . textDirectionFactor == 1
899
- ? EdgeInsets . only ( right : hourLabelWidth )
900
- : EdgeInsets . only ( left : hourLabelWidth ) ,
874
+ padding : EdgeInsets . only ( right : hourLabelWidth ) ,
901
875
child : new Container (
902
876
alignment : this . alignCenterRight ,
903
877
padding : EdgeInsets . symmetric ( horizontal : 2.0f ) ,
@@ -933,13 +907,13 @@ Widget _buildHourColumn() {
933
907
Widget _buildMinutePicker ( ) {
934
908
float offAxisFraction ;
935
909
if ( this . widget . mode == CupertinoTimerPickerMode . hm ) {
936
- offAxisFraction = 0.5f * this . textDirectionFactor ;
910
+ offAxisFraction = 0.5f ;
937
911
}
938
912
else if ( this . widget . mode == CupertinoTimerPickerMode . hms ) {
939
913
offAxisFraction = 0.0f ;
940
914
}
941
915
else {
942
- offAxisFraction = - 0.5f * this . textDirectionFactor ;
916
+ offAxisFraction = - 0.5f ;
943
917
}
944
918
945
919
return new CupertinoPicker (
@@ -961,17 +935,10 @@ Widget _buildMinutePicker() {
961
935
} ,
962
936
children : CupertinoDatePickerUtils . listGenerate ( 60 / this . widget . minuteInterval , ( int index ) => {
963
937
int minute = index * this . widget . minuteInterval ;
964
- string semanticsLabel = this . textDirectionFactor == 1
965
- ? this . localizations . timerPickerMinute ( minute ) +
966
- this . localizations . timerPickerMinuteLabel ( minute )
967
- : this . localizations . timerPickerMinuteLabel ( minute ) +
968
- this . localizations . timerPickerMinute ( minute ) ;
969
938
if ( this . widget . mode == CupertinoTimerPickerMode . ms ) {
970
939
return new Container (
971
940
alignment : this . alignCenterRight ,
972
- padding : this . textDirectionFactor == 1
973
- ? EdgeInsets . only ( right : CupertinoDatePickerUtils . _kPickerWidth / 4 )
974
- : EdgeInsets . only ( left : CupertinoDatePickerUtils . _kPickerWidth / 4 ) ,
941
+ padding : EdgeInsets . only ( right : CupertinoDatePickerUtils . _kPickerWidth / 4 ) ,
975
942
child : new Container (
976
943
alignment : this . alignCenterRight ,
977
944
padding : EdgeInsets . symmetric ( horizontal : 2.0f ) ,
@@ -1003,9 +970,7 @@ Widget _buildMinuteColumn() {
1003
970
minuteLabel = new IgnorePointer (
1004
971
child : new Container (
1005
972
alignment : this . alignCenterLeft ,
1006
- padding : this . textDirectionFactor == 1
1007
- ? EdgeInsets . only ( left : CupertinoDatePickerUtils . _kPickerWidth / 10 )
1008
- : EdgeInsets . only ( right : CupertinoDatePickerUtils . _kPickerWidth / 10 ) ,
973
+ padding : EdgeInsets . only ( left : CupertinoDatePickerUtils . _kPickerWidth / 10 ) ,
1009
974
child : new Container (
1010
975
alignment : this . alignCenterLeft ,
1011
976
padding : EdgeInsets . symmetric ( horizontal : 2.0f ) ,
@@ -1039,7 +1004,7 @@ Widget _buildMinuteColumn() {
1039
1004
}
1040
1005
1041
1006
Widget _buildSecondPicker ( ) {
1042
- float offAxisFraction = 0.5f * this . textDirectionFactor ;
1007
+ float offAxisFraction = 0.5f ;
1043
1008
float secondPickerWidth = this . widget . mode == CupertinoTimerPickerMode . ms
1044
1009
? CupertinoDatePickerUtils . _kPickerWidth / 10
1045
1010
: CupertinoDatePickerUtils . _kPickerWidth / 6 ;
@@ -1062,11 +1027,6 @@ Widget _buildSecondPicker() {
1062
1027
} ,
1063
1028
children : CupertinoDatePickerUtils . listGenerate ( 60 / this . widget . secondInterval , ( int index ) => {
1064
1029
int second = index * this . widget . secondInterval ;
1065
- string semanticsLabel = this . textDirectionFactor == 1
1066
- ? this . localizations . timerPickerSecond ( second ) +
1067
- this . localizations . timerPickerSecondLabel ( second )
1068
- : this . localizations . timerPickerSecondLabel ( second ) +
1069
- this . localizations . timerPickerSecond ( second ) ;
1070
1030
return new Container (
1071
1031
alignment : this . alignCenterLeft ,
1072
1032
child : new Container (
@@ -1087,9 +1047,7 @@ Widget _buildSecondColumn() {
1087
1047
Widget secondLabel = new IgnorePointer (
1088
1048
child : new Container (
1089
1049
alignment : this . alignCenterLeft ,
1090
- padding : this . textDirectionFactor == 1
1091
- ? EdgeInsets . only ( left : secondPickerWidth )
1092
- : EdgeInsets . only ( right : secondPickerWidth ) ,
1050
+ padding : EdgeInsets . only ( left : secondPickerWidth ) ,
1093
1051
child : new Container (
1094
1052
alignment : this . alignCenterLeft ,
1095
1053
padding : EdgeInsets . symmetric ( horizontal : 2.0f ) ,
0 commit comments