Преглед изворни кода

Uses month name (instead of number) for DatePicker

Kevin пре 6 година
родитељ
комит
a8dbf842ff

+ 17 - 0
example/android/.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>android</name>
+	<comment>Project android created by Buildship.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+	</natures>
+</projectDescription>

+ 2 - 0
example/android/.settings/org.eclipse.buildship.core.prefs

@@ -0,0 +1,2 @@
+connection.project.dir=
+eclipse.preferences.version=1

+ 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.en);
                 },
                 child: Text(
                   'show date picker(custom theme &date time range)',

+ 9 - 1
lib/src/date_model.dart

@@ -149,6 +149,7 @@ class DatePickerModel extends CommonPickerModel {
 
   void _fillLeftLists() {
     this.leftList = List.generate(maxTime.year - minTime.year + 1, (int index) {
+      print('LEFT LIST... ${minTime.year + index}${_localeYear()}');
       return '${minTime.year + index}${_localeYear()}';
     });
   }
@@ -179,8 +180,15 @@ class DatePickerModel extends CommonPickerModel {
   void _fillMiddleLists() {
     int minMonth = _minMonthOfCurrentYear();
     int maxMonth = _maxMonthOfCurrentYear();
+
+    List monthStrings = i18nObjInLocale(locale)['monthLong'];
+    
     this.middleList = List.generate(maxMonth - minMonth + 1, (int index) {
-      return '${minMonth + index}${_localeMonth()}';
+      if (locale == LocaleType.zh) {
+        return '${minMonth + index}${_localeMonth()}';
+      } else {
+        return monthStrings[minMonth + index - 1];
+      }
     });
   }