基础组件库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

156 rindas
3.5 KiB

  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/foundation.dart';
  3. ///语言(主要解决cupertino控件不能显示中文的问题)
  4. class CommonLocalizationsDelegate
  5. extends LocalizationsDelegate<CupertinoLocalizations> {
  6. const CommonLocalizationsDelegate();
  7. @override
  8. bool isSupported(Locale locale) =>
  9. <String>['zh', 'CN'].contains(locale.languageCode);
  10. @override
  11. SynchronousFuture<_DefaultCupertinoLocalizations> load(Locale locale) {
  12. return SynchronousFuture<_DefaultCupertinoLocalizations>(
  13. _DefaultCupertinoLocalizations(locale.languageCode));
  14. }
  15. @override
  16. bool shouldReload(CommonLocalizationsDelegate old) => false;
  17. }
  18. class _DefaultCupertinoLocalizations extends CupertinoLocalizations {
  19. _DefaultCupertinoLocalizations(this._languageCode)
  20. : assert(_languageCode != null);
  21. final String _languageCode;
  22. static const List<String> _shortWeekdays = <String>[
  23. '周一',
  24. '周二',
  25. '周三',
  26. '周四',
  27. '周五',
  28. '周六',
  29. '周日',
  30. ];
  31. static const List<String> _shortMonths = <String>[
  32. '一月',
  33. '二月',
  34. '三月',
  35. '四月',
  36. '五月',
  37. '六月',
  38. '七月',
  39. '八月',
  40. '九月',
  41. '十月',
  42. '十一月',
  43. '十二月',
  44. ];
  45. static const List<String> _months = <String>[
  46. '一月',
  47. '二月',
  48. '三月',
  49. '四月',
  50. '五月',
  51. '六月',
  52. '七月',
  53. '八月',
  54. '九月',
  55. '十月',
  56. '十一月',
  57. '十二月',
  58. ];
  59. @override
  60. String get alertDialogLabel => '提醒';
  61. @override
  62. String get anteMeridiemAbbreviation => "上午";
  63. @override
  64. String get postMeridiemAbbreviation => "下午";
  65. @override
  66. String get copyButtonLabel => "复制";
  67. @override
  68. String get cutButtonLabel => "剪切";
  69. @override
  70. String get pasteButtonLabel => "粘贴";
  71. @override
  72. String get selectAllButtonLabel => "全选";
  73. @override
  74. DatePickerDateOrder get datePickerDateOrder => DatePickerDateOrder.ymd;
  75. @override
  76. DatePickerDateTimeOrder get datePickerDateTimeOrder =>
  77. DatePickerDateTimeOrder.date_time_dayPeriod;
  78. @override
  79. String datePickerDayOfMonth(int dayIndex) => dayIndex.toString();
  80. @override
  81. String datePickerHour(int hour) => hour.toString();
  82. @override
  83. String datePickerHourSemanticsLabel(int hour) => hour.toString();
  84. @override
  85. String datePickerMediumDate(DateTime date) {
  86. return '${_shortWeekdays[date.weekday - DateTime.monday]} '
  87. '${_shortMonths[date.month - DateTime.january]} '
  88. '${date.day.toString().padRight(2)}';
  89. }
  90. @override
  91. String datePickerMinute(int minute) => minute.toString().padLeft(2, '0');
  92. @override
  93. String datePickerMinuteSemanticsLabel(int minute) {
  94. if (minute == 1) return '1 分钟';
  95. return minute.toString() + ' 分钟';
  96. }
  97. @override
  98. String datePickerMonth(int monthIndex) => _months[monthIndex - 1];
  99. @override
  100. String datePickerYear(int yearIndex) => yearIndex.toString();
  101. @override
  102. String timerPickerHour(int hour) => hour.toString();
  103. @override
  104. String timerPickerHourLabel(int hour) => '时';
  105. @override
  106. String timerPickerMinute(int minute) => minute.toString();
  107. @override
  108. String timerPickerMinuteLabel(int minute) => '分';
  109. @override
  110. String timerPickerSecond(int second) => second.toString();
  111. @override
  112. String timerPickerSecondLabel(int second) => '秒';
  113. @override
  114. String get todayLabel => "今天";
  115. @override
  116. // TODO: implement modalBarrierDismissLabel
  117. String get modalBarrierDismissLabel => "关闭";
  118. @override
  119. String tabSemanticsLabel({int tabIndex, int tabCount}) {
  120. }
  121. }