فهرست منبع

update date picker

Liu Yanbo 6 سال پیش
والد
کامیت
8d930d9f5b
5فایلهای تغییر یافته به همراه10 افزوده شده و 14 حذف شده
  1. 2 1
      CHANGELOG.md
  2. 1 1
      example/lib/main.dart
  3. 1 1
      lib/flutter_datetime_picker.dart
  4. 5 10
      lib/src/date_model.dart
  5. 1 1
      pubspec.yaml

+ 2 - 1
CHANGELOG.md

@@ -21,4 +21,5 @@
 ## [1.0.9] - fix readme
 ## [1.1.0] - fix readme
 ## [1.1.1] - add 3 more languages
-## [1.1.2] - add Portuguese
+## [1.1.2] - add Portuguese
+## [1.1.3] - update date picker format

+ 1 - 1
example/lib/main.dart

@@ -43,7 +43,7 @@ class HomePage extends StatelessWidget {
                     print('change $date');
                   }, onConfirm: (date) {
                     print('confirm $date');
-                  }, currentTime: DateTime.now(), locale: LocaleType.zh);
+                  }, currentTime: DateTime.now(), locale: LocaleType.ru);
                 },
                 child: Text(
                   'show date picker(custom theme &date time range)',

+ 1 - 1
lib/flutter_datetime_picker.dart

@@ -384,7 +384,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
   Widget _renderTitleActionsView(DatePickerTheme theme) {
     String done = _localeDone();
     String cancel = _localeCancel();
-    
+
     return Container(
       height: theme.titleHeight,
       decoration: BoxDecoration(color: theme.backgroundColor ?? Colors.white),

+ 5 - 10
lib/src/date_model.dart

@@ -181,14 +181,8 @@ class DatePickerModel extends CommonPickerModel {
     int minMonth = _minMonthOfCurrentYear();
     int maxMonth = _maxMonthOfCurrentYear();
 
-    List monthStrings = i18nObjInLocale(locale)['monthLong'];
-    
     this.middleList = List.generate(maxMonth - minMonth + 1, (int index) {
-      if (locale == LocaleType.zh) {
-        return '${minMonth + index}${_localeMonth()}';
-      } else {
-        return monthStrings[minMonth + index - 1];
-      }
+      return '${_localeMonth(minMonth + index)}';
     });
   }
 
@@ -312,11 +306,12 @@ class DatePickerModel extends CommonPickerModel {
     }
   }
 
-  String _localeMonth() {
+  String _localeMonth(int month) {
     if (locale == LocaleType.zh) {
-      return '月';
+      return '$month月';
     } else {
-      return '';
+      List monthStrings = i18nObjInLocale(locale)['monthLong'];
+      return monthStrings[month - 1];
     }
   }
 

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: flutter_datetime_picker
 description: A date time picker for flutter, you can choose date / time / date&time in English Dutch and Chinese, and you can also custom your own picker content
-version: 1.1.2
+version: 1.1.3
 author: Realank <realank@126.com>
 homepage: https://github.com/Realank/flutter_datetime_picker