Skip to content

Commit

Permalink
Merge pull request #149 from HiroyukiTamura/master
Browse files Browse the repository at this point in the history
add suffixes for hour, minute and second on DateTimePickerAdapter
  • Loading branch information
yangyxd authored Jun 7, 2021
2 parents cf57b14 + 377df6f commit f006c88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ class _MyHomePageState extends State<MyHomePage> {
yearSuffix: "年",
monthSuffix: "月",
daySuffix: "日",
hourSuffix: "時",
minuteSuffix: "分",
secondSuffix: "秒",
minValue: DateTime.now(),
minuteInterval: 30,
minHour: 1,
Expand Down Expand Up @@ -453,6 +456,9 @@ class _MyHomePageState extends State<MyHomePage> {
yearSuffix: "年",
monthSuffix: "月",
daySuffix: "日",
hourSuffix: "時",
minuteSuffix: "分",
secondSuffix: "秒",
minHour: 8,
maxHour: 19,
yearBegin: 1950,
Expand Down
13 changes: 8 additions & 5 deletions lib/Picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ class DateTimePickerAdapter extends PickerAdapter<DateTime> {
final int? minuteInterval;

/// Year, month, day suffix
final String? yearSuffix, monthSuffix, daySuffix;
final String? yearSuffix, monthSuffix, daySuffix, hourSuffix, minuteSuffix, secondSuffix;

/// use two-digit year, 2019, displayed as 19
final bool twoDigitYear;
Expand Down Expand Up @@ -1171,6 +1171,9 @@ class DateTimePickerAdapter extends PickerAdapter<DateTime> {
this.maxValue,
this.minHour,
this.maxHour,
this.secondSuffix,
this.minuteSuffix,
this.hourSuffix,
this.yearSuffix,
this.monthSuffix,
this.daySuffix,
Expand Down Expand Up @@ -1395,16 +1398,16 @@ class DateTimePickerAdapter extends PickerAdapter<DateTime> {
_text = "${index + 1}${_checkStr(daySuffix)}";
break;
case 3:
_text = "${intToStr(index + (minHour ?? 0))}";
_text = "${intToStr(index + (minHour ?? 0))}${_checkStr(hourSuffix)}";
break;
case 5:
_text = "${intToStr(index)}";
_text = "${intToStr(index)}${_checkStr(secondSuffix)}";
break;
case 4:
if (minuteInterval == null || minuteInterval! < 2)
_text = "${intToStr(index)}";
_text = "${intToStr(index)}${_checkStr(minuteSuffix)}";
else
_text = "${intToStr(index * minuteInterval!)}";
_text = "${intToStr(index * minuteInterval!)}${_checkStr(minuteSuffix)}";
break;
case 6:
List? _ampm = strAMPM ?? PickerLocalizations.of(context).ampm;
Expand Down

0 comments on commit f006c88

Please sign in to comment.