|
|
|
|
|
|
Alignment alignCenterLeft; |
|
|
|
Alignment alignCenterRight; |
|
|
|
|
|
|
|
int selectedHour = 0; |
|
|
|
int selectedMinute = 0; |
|
|
|
int selectedSecond = 0; |
|
|
|
int selectedHour; |
|
|
|
int selectedMinute; |
|
|
|
int selectedSecond; |
|
|
|
int lastSelectedHour = 0; |
|
|
|
int lastSelectedMinute = 0; |
|
|
|
int lastSelectedSecond = 0; |
|
|
|
int lastSelectedHour; |
|
|
|
int lastSelectedMinute; |
|
|
|
int lastSelectedSecond; |
|
|
|
float numberLabelWidth = 0f; |
|
|
|
float numberLabelHeight = 0f; |
|
|
|
float numberLabelBaseline = 0f; |
|
|
|
float numberLabelWidth; |
|
|
|
float numberLabelHeight; |
|
|
|
float numberLabelBaseline; |
|
|
|
|
|
|
|
if (widget.mode != CupertinoTimerPickerMode.ms) { |
|
|
|
selectedHour = (int) widget.initialTimerDuration.TotalHours; |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange); |
|
|
|
} |
|
|
|
void _handleSystemFontsChange() { |
|
|
|
setState(() =>{ |
|
|
|
|
|
|
numberLabelWidth = textPainter.maxIntrinsicWidth; |
|
|
|
numberLabelHeight = textPainter.height; |
|
|
|
numberLabelBaseline = textPainter.computeDistanceToActualBaseline(TextBaseline.alphabetic); |
|
|
|
} |
|
|
|
} |
|
|
|
EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( |
|
|
|
start: numberLabelWidth |
|
|
|
+ CupertinoDatePickerUtils._kTimerPickerLabelPadSize |
|
|
|
+ pickerPadding.start |
|
|
|
EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( |
|
|
|
start: numberLabelWidth |
|
|
|
+ CupertinoDatePickerUtils._kTimerPickerLabelPadSize |
|
|
|
+ pickerPadding.start |
|
|
|
child: new Container( |
|
|
|
alignment: AlignmentDirectional.centerStart.resolve(textDirection), |
|
|
|
padding: padding.resolve(textDirection), |
|
|
|
child: new SizedBox( |
|
|
|
height: numberLabelHeight, |
|
|
|
child: new Baseline( |
|
|
|
baseline: numberLabelBaseline, |
|
|
|
baselineType: TextBaseline.alphabetic, |
|
|
|
child: new Text( |
|
|
|
text, |
|
|
|
style: new TextStyle( |
|
|
|
fontSize: CupertinoDatePickerUtils._kTimerPickerLabelFontSize, |
|
|
|
fontWeight: FontWeight.w600), |
|
|
|
maxLines: 1, |
|
|
|
softWrap: false))) |
|
|
|
)); |
|
|
|
} |
|
|
|
Widget _buildPickerNumberLabel(string text, EdgeInsetsDirectional padding) { |
|
|
|
return new Container( |
|
|
|
width: CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth + padding.horizontal, |
|
|
|
child: new Container( |
|
|
|
alignment: AlignmentDirectional.centerStart.resolve(textDirection), |
|
|
|
alignment: AlignmentDirectional.centerStart.resolve(textDirection), |
|
|
|
child: new Container( |
|
|
|
width: numberLabelWidth, |
|
|
|
alignment: AlignmentDirectional.centerEnd.resolve(textDirection), |
|
|
|
child: new Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible) |
|
|
|
child: new SizedBox( |
|
|
|
height: numberLabelHeight, |
|
|
|
child: new Baseline( |
|
|
|
baseline: numberLabelBaseline, |
|
|
|
baselineType: TextBaseline.alphabetic, |
|
|
|
child: new Text( |
|
|
|
text, |
|
|
|
style: new TextStyle( |
|
|
|
fontSize: CupertinoDatePickerUtils._kTimerPickerLabelFontSize, |
|
|
|
fontWeight: FontWeight.w600 |
|
|
|
), |
|
|
|
maxLines: 1, |
|
|
|
softWrap: false |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
Widget _buildHourPicker(EdgeInsetsDirectional additionalPadding) { |
|
|
|
List<Widget> widgets = new List<Widget>(); |
|
|
|
for (int index = 0; index < 24; index++) { |
|
|
|
string semanticsLabel = textDirectionFactor == 1 |
|
|
|
? localizations.timerPickerHour(index) + localizations.timerPickerHourLabel(index) |
|
|
|
: localizations.timerPickerHourLabel(index) + localizations.timerPickerHour(index); |
|
|
|
} |
|
|
|
widgets.Add( _buildPickerNumberLabel(localizations.timerPickerHour(index), additionalPadding)); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildPickerNumberLabel(string text, EdgeInsetsDirectional padding) { |
|
|
|
return new Container( |
|
|
|
width: CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth + padding.horizontal, |
|
|
|
padding: padding.resolve(textDirection), |
|
|
|
alignment: AlignmentDirectional.centerStart.resolve(textDirection), |
|
|
|
child: new Container( |
|
|
|
width: numberLabelWidth, |
|
|
|
alignment: AlignmentDirectional.centerEnd.resolve(textDirection), |
|
|
|
child: new Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible) |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
Widget _buildHourPicker(EdgeInsetsDirectional additionalPadding) { |
|
|
|
scrollController: new FixedExtentScrollController(initialItem: selectedHour), |
|
|
|
offAxisFraction: -0.5f * textDirectionFactor, |
|
|
|
itemExtent: CupertinoDatePickerUtils._kItemExtent, |
|
|
|
backgroundColor: ((CupertinoTimerPicker)widget).backgroundColor, |
|
|
|
squeeze: CupertinoDatePickerUtils._kSqueeze, |
|
|
|
onSelectedItemChanged: (int index)=> { |
|
|
|
setState(()=> { |
|
|
|
selectedHour = index; |
|
|
|
widget.onTimerDurationChanged( |
|
|
|
new TimeSpan( |
|
|
|
hours: selectedHour, |
|
|
|
minutes: selectedMinute, |
|
|
|
seconds: selectedSecond != 0 ? selectedSecond : 0)); |
|
|
|
scrollController: new FixedExtentScrollController(initialItem: selectedHour), |
|
|
|
offAxisFraction: -0.5f * textDirectionFactor, |
|
|
|
itemExtent: CupertinoDatePickerUtils._kItemExtent, |
|
|
|
backgroundColor: widget.backgroundColor, |
|
|
|
squeeze: CupertinoDatePickerUtils._kSqueeze, |
|
|
|
onSelectedItemChanged: (int index)=> { |
|
|
|
setState(() =>{ |
|
|
|
selectedHour = index; |
|
|
|
widget.onTimerDurationChanged( |
|
|
|
new TimeSpan( |
|
|
|
hours: selectedHour, |
|
|
|
minutes: selectedMinute, |
|
|
|
seconds: selectedSecond == 0 ? 0 : selectedHour)); |
|
|
|
}, |
|
|
|
children: widgets |
|
|
|
}, |
|
|
|
children: CupertinoDatePickerUtils.listGenerate(24, (int index) => { |
|
|
|
string semanticsLabel = textDirectionFactor == 1 |
|
|
|
? localizations.timerPickerHour(index) + localizations.timerPickerHourLabel(index) |
|
|
|
: localizations.timerPickerHourLabel(index) + localizations.timerPickerHour(index); |
|
|
|
|
|
|
|
return _buildPickerNumberLabel(localizations.timerPickerHour(index), additionalPadding); |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildHourColumn(EdgeInsetsDirectional additionalPadding) { |
|
|
|
Widget _buildHourColumn(EdgeInsetsDirectional additionalPadding) { |
|
|
|
children: new List<Widget>{ |
|
|
|
new NotificationListener<ScrollEndNotification>( |
|
|
|
onNotification: (ScrollEndNotification notification)=> { |
|
|
|
setState(()=> { lastSelectedHour = selectedHour; }); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
child: _buildHourPicker(additionalPadding) |
|
|
|
), |
|
|
|
_buildLabel( |
|
|
|
localizations.timerPickerHourLabel(lastSelectedHour == 0 ? selectedHour : lastSelectedHour), |
|
|
|
additionalPadding |
|
|
|
), |
|
|
|
}); |
|
|
|
} |
|
|
|
Widget _buildMinutePicker(EdgeInsetsDirectional additionalPadding) { |
|
|
|
List<Widget> widgets = new List<Widget>(); |
|
|
|
for (int index = 0; index < (int)(60 / widget.minuteInterval); index++) { |
|
|
|
int minute = index * widget.minuteInterval; |
|
|
|
children: new List<Widget>{ |
|
|
|
new NotificationListener<ScrollEndNotification>( |
|
|
|
onNotification: (ScrollEndNotification notification)=> { |
|
|
|
setState(()=> { lastSelectedHour = selectedHour; }); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
child: _buildHourPicker(additionalPadding) |
|
|
|
), |
|
|
|
_buildLabel( |
|
|
|
localizations.timerPickerHourLabel(lastSelectedHour == 0 ? selectedHour : lastSelectedHour), |
|
|
|
additionalPadding |
|
|
|
), |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
string semanticsLabel = textDirectionFactor == 1 |
|
|
|
? localizations.timerPickerMinute(minute) + localizations.timerPickerMinuteLabel(minute) |
|
|
|
: localizations.timerPickerMinuteLabel(minute) + localizations.timerPickerMinute(minute); |
|
|
|
|
|
|
|
widgets.Add(_buildPickerNumberLabel(localizations.timerPickerMinute(minute), additionalPadding) |
|
|
|
); |
|
|
|
} |
|
|
|
Widget _buildMinutePicker(EdgeInsetsDirectional additionalPadding) { |
|
|
|
switch (widget.mode) { |
|
|
|
case CupertinoTimerPickerMode.hm: |
|
|
|
offAxisFraction = 0.5f * textDirectionFactor; |
|
|
|
switch (widget.mode) { |
|
|
|
case CupertinoTimerPickerMode.hm: |
|
|
|
offAxisFraction = 0.5f * textDirectionFactor; |
|
|
|
case CupertinoTimerPickerMode.hms: |
|
|
|
case CupertinoTimerPickerMode.hms: |
|
|
|
case CupertinoTimerPickerMode.ms: |
|
|
|
case CupertinoTimerPickerMode.ms: |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
scrollController: new FixedExtentScrollController( |
|
|
|
initialItem: (int) (selectedMinute / widget.minuteInterval) |
|
|
|
), |
|
|
|
offAxisFraction: offAxisFraction, |
|
|
|
itemExtent: CupertinoDatePickerUtils._kItemExtent, |
|
|
|
backgroundColor: widget.backgroundColor, |
|
|
|
squeeze: CupertinoDatePickerUtils._kSqueeze, |
|
|
|
looping: true, |
|
|
|
onSelectedItemChanged: (int index) => { |
|
|
|
setState(() => { |
|
|
|
selectedMinute = index * widget.minuteInterval; |
|
|
|
widget.onTimerDurationChanged( |
|
|
|
new TimeSpan( |
|
|
|
hours: selectedHour == 0 ? 0 : selectedHour, |
|
|
|
minutes: selectedMinute, |
|
|
|
seconds: selectedSecond == 0 ? 0 : selectedSecond)); |
|
|
|
}); |
|
|
|
}, |
|
|
|
children: widgets |
|
|
|
); |
|
|
|
scrollController: new FixedExtentScrollController( |
|
|
|
initialItem: (int)selectedMinute / widget.minuteInterval |
|
|
|
), |
|
|
|
offAxisFraction: offAxisFraction, |
|
|
|
itemExtent: CupertinoDatePickerUtils._kItemExtent, |
|
|
|
backgroundColor: widget.backgroundColor, |
|
|
|
squeeze: CupertinoDatePickerUtils._kSqueeze, |
|
|
|
looping: true, |
|
|
|
onSelectedItemChanged: (int index) => { |
|
|
|
setState(() =>{ |
|
|
|
selectedMinute = index * widget.minuteInterval; |
|
|
|
widget.onTimerDurationChanged( |
|
|
|
new TimeSpan( |
|
|
|
hours: selectedHour == 0 ? 0 : selectedHour, |
|
|
|
minutes: selectedMinute, |
|
|
|
seconds: selectedSecond == 0 ? 0 : selectedSecond )); |
|
|
|
}); |
|
|
|
}, |
|
|
|
children: CupertinoDatePickerUtils.listGenerate((int)(60 / widget.minuteInterval), (int index) => { |
|
|
|
int minute = index * widget.minuteInterval; |
|
|
|
string semanticsLabel = textDirectionFactor == 1 |
|
|
|
? localizations.timerPickerMinute(minute) + localizations.timerPickerMinuteLabel(minute) |
|
|
|
: localizations.timerPickerMinuteLabel(minute) + localizations.timerPickerMinute(minute); |
|
|
|
} |
|
|
|
Widget _buildMinuteColumn(EdgeInsetsDirectional additionalPadding) { |
|
|
|
return _buildPickerNumberLabel(localizations.timerPickerMinute(minute), additionalPadding); |
|
|
|
|
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildMinuteColumn(EdgeInsetsDirectional additionalPadding) { |
|
|
|
setState(()=> { lastSelectedMinute = selectedMinute; }); |
|
|
|
setState(() => { lastSelectedMinute = selectedMinute; }); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
child: _buildMinutePicker(additionalPadding) |
|
|
|
|
|
|
), |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
Widget _buildSecondPicker(EdgeInsetsDirectional additionalPadding) { |
|
|
|
float offAxisFraction = 0.5f * textDirectionFactor; |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildSecondPicker(EdgeInsetsDirectional additionalPadding) { |
|
|
|
float offAxisFraction = 0.5f * textDirectionFactor; |
|
|
|
|
|
|
|
scrollController: new FixedExtentScrollController( |
|
|
|
initialItem: (int)(selectedSecond / widget.secondInterval) |
|
|
|
), |
|
|
|
offAxisFraction: offAxisFraction, |
|
|
|
itemExtent: CupertinoDatePickerUtils._kItemExtent, |
|
|
|
backgroundColor: widget.backgroundColor, |
|
|
|
squeeze: CupertinoDatePickerUtils._kSqueeze, |
|
|
|
looping: true, |
|
|
|
onSelectedItemChanged: (int index) =>{ |
|
|
|
setState(()=> { |
|
|
|
selectedSecond = index * widget.secondInterval; |
|
|
|
widget.onTimerDurationChanged( |
|
|
|
new TimeSpan( |
|
|
|
hours: selectedHour == 0 ? 0 : selectedHour, |
|
|
|
minutes: selectedMinute, |
|
|
|
seconds: selectedSecond)); |
|
|
|
}); |
|
|
|
}, |
|
|
|
children: CupertinoDatePickerUtils.listGenerate((int)60 / widget.secondInterval, (int index)=> { |
|
|
|
int second = index * widget.secondInterval; |
|
|
|
string semanticsLabel = textDirectionFactor == 1 |
|
|
|
? localizations.timerPickerSecond(second) + localizations.timerPickerSecondLabel(second) |
|
|
|
: localizations.timerPickerSecondLabel(second) + localizations.timerPickerSecond(second); |
|
|
|
scrollController: new FixedExtentScrollController( |
|
|
|
initialItem: (int) selectedSecond / widget.secondInterval |
|
|
|
), |
|
|
|
offAxisFraction: offAxisFraction, |
|
|
|
itemExtent: CupertinoDatePickerUtils._kItemExtent, |
|
|
|
backgroundColor: widget.backgroundColor, |
|
|
|
squeeze: CupertinoDatePickerUtils._kSqueeze, |
|
|
|
looping: true, |
|
|
|
onSelectedItemChanged: (int index)=> { |
|
|
|
setState(() => { |
|
|
|
selectedSecond = index * widget.secondInterval; |
|
|
|
widget.onTimerDurationChanged( |
|
|
|
new TimeSpan( |
|
|
|
hours: selectedHour == 0 ? 0 : selectedHour, |
|
|
|
minutes: selectedMinute, |
|
|
|
seconds: selectedSecond)); |
|
|
|
}); |
|
|
|
}, |
|
|
|
children: CupertinoDatePickerUtils.listGenerate((int) (60 / widget.secondInterval), (int index)=> { |
|
|
|
int second = index * widget.secondInterval; |
|
|
|
return _buildPickerNumberLabel(localizations.timerPickerSecond(second), additionalPadding); |
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
Widget _buildSecondColumn(EdgeInsetsDirectional additionalPadding) { |
|
|
|
string semanticsLabel = textDirectionFactor == 1 |
|
|
|
? localizations.timerPickerSecond(second) + localizations.timerPickerSecondLabel(second) |
|
|
|
: localizations.timerPickerSecondLabel(second) + localizations.timerPickerSecond(second); |
|
|
|
|
|
|
|
return _buildPickerNumberLabel(localizations.timerPickerSecond(second), additionalPadding); |
|
|
|
|
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildSecondColumn(EdgeInsetsDirectional additionalPadding) { |
|
|
|
children: new List<Widget>{ |
|
|
|
new NotificationListener<ScrollEndNotification>( |
|
|
|
onNotification: (ScrollEndNotification notification)=> { |
|
|
|
setState(()=> { lastSelectedSecond = selectedSecond; }); |
|
|
|
return false; |
|
|
|
children: new List<Widget>{ |
|
|
|
new NotificationListener<ScrollEndNotification>( |
|
|
|
onNotification: (ScrollEndNotification notification)=> { |
|
|
|
setState(() => { lastSelectedSecond = selectedSecond; }); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
child: _buildSecondPicker(additionalPadding) |
|
|
|
), |
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
TextStyle _textStyleFrom(BuildContext context) { |
|
|
|
} |
|
|
|
|
|
|
|
TextStyle _textStyleFrom(BuildContext context) { |
|
|
|
.pickerTextStyle.merge( |
|
|
|
new TextStyle( |
|
|
|
fontSize: CupertinoDatePickerUtils._kTimerPickerNumberLabelFontSize |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
.pickerTextStyle.merge( |
|
|
|
new TextStyle( |
|
|
|
fontSize: CupertinoDatePickerUtils._kTimerPickerNumberLabelFontSize |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
List<Widget> columns = new List<Widget>(); |
|
|
|
float paddingValue = CupertinoDatePickerUtils._kPickerWidth - 2 * CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth - 2 * CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding; |
|
|
|
|
|
|
|
float totalWidth = CupertinoDatePickerUtils._kPickerWidth; |
|
|
|
D.assert(paddingValue >= 0); |
|
|
|
|
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
List<Widget> columns = new List<Widget>(); |
|
|
|
float paddingValue = CupertinoDatePickerUtils._kPickerWidth - |
|
|
|
2 * CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth - 2 * CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding; |
|
|
|
float totalWidth = CupertinoDatePickerUtils._kPickerWidth; |
|
|
|
D.assert(paddingValue >= 0); |
|
|
|
switch (widget.mode) { |
|
|
|
case CupertinoTimerPickerMode.hm: |
|
|
|
|
|
|
|
columns = new List<Widget>{ |
|
|
|
_buildHourColumn(EdgeInsetsDirectional.only(start: paddingValue / 2, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildMinuteColumn(EdgeInsetsDirectional.only(start:CupertinoDatePickerUtils. _kTimerPickerHalfColumnPadding, end: paddingValue / 2)),}; |
|
|
|
break; |
|
|
|
case CupertinoTimerPickerMode.ms: |
|
|
|
columns = new List<Widget>{ |
|
|
|
_buildMinuteColumn(EdgeInsetsDirectional.only(start: paddingValue / 2, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildSecondColumn(EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: paddingValue / 2)), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
break; |
|
|
|
case CupertinoTimerPickerMode.hms: |
|
|
|
float _paddingValue = CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding * 2; |
|
|
|
totalWidth = CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth * 3 + 4 * CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding + _paddingValue; |
|
|
|
columns = new List<Widget>{ |
|
|
|
_buildHourColumn(EdgeInsetsDirectional.only(start: _paddingValue / 2, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildMinuteColumn(EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildSecondColumn(EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: _paddingValue / 2)), |
|
|
|
switch (widget.mode) { |
|
|
|
case CupertinoTimerPickerMode.hm: |
|
|
|
// Pad the widget to make it as wide as `_kPickerWidth`.
|
|
|
|
columns = new List<Widget>{ |
|
|
|
_buildHourColumn( EdgeInsetsDirectional.only(start: paddingValue / 2, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildMinuteColumn( EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: paddingValue / 2)), |
|
|
|
}; |
|
|
|
break; |
|
|
|
case CupertinoTimerPickerMode.ms: |
|
|
|
// Pad the widget to make it as wide as `_kPickerWidth`.
|
|
|
|
columns = new List<Widget>{ |
|
|
|
_buildMinuteColumn( EdgeInsetsDirectional.only(start: paddingValue / 2, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildSecondColumn( EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: paddingValue / 2)), |
|
|
|
}; |
|
|
|
break; |
|
|
|
case CupertinoTimerPickerMode.hms: |
|
|
|
float _paddingValue = CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding * 2; |
|
|
|
totalWidth = CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth * 3 + 4 * CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding + _paddingValue; |
|
|
|
columns = new List<Widget>{ |
|
|
|
_buildHourColumn( EdgeInsetsDirectional.only(start: _paddingValue / 2, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildMinuteColumn( EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding)), |
|
|
|
_buildSecondColumn( EdgeInsetsDirectional.only(start: CupertinoDatePickerUtils._kTimerPickerHalfColumnPadding, end: _paddingValue / 2)), |
|
|
|
break; |
|
|
|
break; |
|
|
|
CupertinoThemeData themeData = CupertinoTheme.of(context); |
|
|
|
List<Widget> results = new List<Widget>(); |
|
|
|
foreach (var result in columns.Select((Widget child) => new Expanded(child: child)).ToList()) { |
|
|
|
results.Add((Widget)result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CupertinoThemeData themeData = CupertinoTheme.of(context); |
|
|
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0f), |
|
|
|
child: new CupertinoTheme( |
|
|
|
data: themeData.copyWith( |
|
|
|
textTheme: themeData.textTheme.copyWith(pickerTextStyle: _textStyleFrom(context)) |
|
|
|
), |
|
|
|
child: new Align( |
|
|
|
alignment: widget.alignment, |
|
|
|
child: new Container( |
|
|
|
color: CupertinoDynamicColor.resolve(widget.backgroundColor, context), |
|
|
|
width: totalWidth, |
|
|
|
height: CupertinoDatePickerUtils._kPickerHeight, |
|
|
|
child: new DefaultTextStyle( |
|
|
|
style: _textStyleFrom(context), |
|
|
|
child: new Row(children: results |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
// The native iOS picker's text scaling is fixed, so we will also fix it
|
|
|
|
// as well in our picker.
|
|
|
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0f), |
|
|
|
child: new CupertinoTheme( |
|
|
|
data: themeData.copyWith( |
|
|
|
textTheme: themeData.textTheme.copyWith( |
|
|
|
pickerTextStyle: _textStyleFrom(context) |
|
|
|
) |
|
|
|
), |
|
|
|
child: new Align( |
|
|
|
alignment: widget.alignment, |
|
|
|
child: new Container( |
|
|
|
color: CupertinoDynamicColor.resolve(widget.backgroundColor, context), |
|
|
|
width: totalWidth, |
|
|
|
height: CupertinoDatePickerUtils._kPickerHeight, |
|
|
|
child: new DefaultTextStyle( |
|
|
|
style: _textStyleFrom(context), |
|
|
|
child: new Row( |
|
|
|
children: |
|
|
|
columns.Select((Widget child) => { |
|
|
|
var result = new Expanded(child: child); |
|
|
|
return (Widget) result; |
|
|
|
}).ToList() |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |