diff --git a/example/android/build.gradle b/example/android/build.gradle index 791c01b..c45ad12 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 595fb86..6b66533 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/example/lib/main.dart b/example/lib/main.dart index 619683a..1335cb2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -97,7 +97,7 @@ class _WidgetPageState extends State { dateFormat: // "MM-dd(E)", "dd/MMMM/yyyy", - locale: DatePicker.localeFromString('th'), + locale: DatePicker.localeFromString('lo'), onChange: (DateTime newDate, _) { setState(() { _selectedDate = newDate; @@ -109,6 +109,9 @@ class _WidgetPageState extends State { itemTextStyle: TextStyle(color: Colors.white, fontSize: 19), dividerColor: Colors.white, + // pickerHeight: 400, + // itemHeight: 80, + // titleHeight: 400, ), ), ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 8128794..e8d2484 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,7 @@ description: flutter_holo_date_picker package exmaple project version: 1.0.0 environment: - sdk: '>=2.18.2 <3.0.0' + sdk: ">=2.18.2 <3.0.0" dependencies: flutter: @@ -33,13 +33,11 @@ dev_dependencies: flutter_test: sdk: flutter - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/lib/date_picker.dart b/lib/date_picker.dart index b66312d..3c0b28e 100644 --- a/lib/date_picker.dart +++ b/lib/date_picker.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_holo_date_picker/widget/date_ext.dart'; -import 'date_picker_theme.dart'; import 'date_picker_constants.dart'; +import 'date_picker_theme.dart'; import 'i18n/date_picker_i18n.dart'; import 'widget/date_picker_widget.dart'; @@ -92,6 +92,9 @@ class DatePicker { case 'pl': return DateTimePickerLocale.pl; + case 'lo': + return DateTimePickerLocale.lo; + default: return DateTimePickerLocale.en_us; } diff --git a/lib/date_picker_theme.dart b/lib/date_picker_theme.dart index 30b4f91..79261a4 100644 --- a/lib/date_picker_theme.dart +++ b/lib/date_picker_theme.dart @@ -23,6 +23,8 @@ const Color DATETIME_PICKER_ITEM_TEXT_COLOR = Colors.black; const double DATETIME_PICKER_ITEM_TEXT_SIZE_SMALL = 15; const double DATETIME_PICKER_ITEM_TEXT_SIZE_BIG = 17; +const double DATETIME_PICKER_DIVIDER_THICKNESS = 2; + /// To support both stable and beta channels until /// 'DiagnosticableMixin' is officially deprecated. class DateTimePickerTheme { diff --git a/lib/i18n/date_picker_i18n.dart b/lib/i18n/date_picker_i18n.dart index 8eee631..b0cd40a 100644 --- a/lib/i18n/date_picker_i18n.dart +++ b/lib/i18n/date_picker_i18n.dart @@ -1,59 +1,34 @@ import 'dart:math'; part 'strings_ar.dart'; - part 'strings_bn.dart'; - +part 'strings_cz.dart'; part 'strings_de.dart'; - part 'strings_en_us.dart'; - part 'strings_es.dart'; - +part 'strings_fr.dart'; part 'strings_he.dart'; - +part 'strings_ht.dart'; part 'strings_hu.dart'; - part 'strings_id.dart'; - part 'strings_it.dart'; - part 'strings_jp.dart'; - part 'strings_ko.dart'; - +part 'strings_lo.dart'; +part 'strings_lt.dart'; +part 'strings_nl.dart'; part 'strings_no_nb.dart'; - part 'strings_no_nn.dart'; - +part 'strings_pl.dart'; part 'strings_pt_br.dart'; - part 'strings_ro.dart'; - part 'strings_ru.dart'; - +part 'strings_sr.dart'; +part 'strings_sv.dart'; +part 'strings_th.dart'; part 'strings_tr.dart'; - part 'strings_zh_cn.dart'; -part 'strings_fr.dart'; - -part 'strings_th.dart'; - -part 'strings_lt.dart'; - -part 'strings_nl.dart'; - -part 'strings_ht.dart'; - -part 'strings_sv.dart'; - -part 'strings_cz.dart'; - -part 'strings_pl.dart'; - -part 'strings_sr.dart'; - abstract class _StringsI18n { const _StringsI18n(); @@ -154,6 +129,9 @@ enum DateTimePickerLocale { /// Serbian (SR) sr, + + /// Lao (LO) + lo, } /// Default value of date locale @@ -188,6 +166,7 @@ const Map datePickerI18n = { DateTimePickerLocale.cz: const _StringsCz(), DateTimePickerLocale.pl: const _StringsPl(), DateTimePickerLocale.sr: const _StringsSr(), + DateTimePickerLocale.lo: const _StringsLo(), }; class DatePickerI18n { diff --git a/lib/i18n/strings_lo.dart b/lib/i18n/strings_lo.dart new file mode 100644 index 0000000..ba6a9ad --- /dev/null +++ b/lib/i18n/strings_lo.dart @@ -0,0 +1,60 @@ +part of 'date_picker_i18n.dart'; + +/// Lao (LO) Lao +class _StringsLo extends _StringsI18n { + const _StringsLo(); + + @override + String getCancelText() { + return 'Cancel'; + } + + @override + String getDoneText() { + return 'Done'; + } + + @override + List getMonths() { + return [ + "ມັງກອນ", // January + "ກຸມພາ", // February + "ມີນາ", // March + "ເມສາ", // April + "ພຶດສະພາ", // May + "ມິຖຸນາ", // June + "ກໍລະກົດ", // July + "ສິງຫາ", // August + "ກັນຍາ", // September + "ຕຸລາ", // October + "ພະຈິກ", // November + "ທັນວາ" // December + ]; + } + + @override + List getWeeksFull() { + return [ + "ວັນຈັນ", // Monday + "ວັນອັງຄານ", // Tuesday + "ວັນພຸດ", // Wednesday + "ວັນພະຫັດ", // Thursday + "ວັນສຸກ", // Friday + "ວັນເສົາ", // Saturday + "ວັນອາທິດ", // Sunday + ]; + } + + @override + List getWeeksShort() { + return [ + "ຈັນ", // Monday + "ອັງຄານ", // Tuesday + "ພຸດ", // Wednesday + "ພະຫັດ", // Thursday + "ສຸກ", // Friday + "ເສົາ", // Saturday + "ອາທິດ", // Sunday + ]; + } +} diff --git a/lib/widget/date_picker_widget.dart b/lib/widget/date_picker_widget.dart index cf92932..7dd7240 100644 --- a/lib/widget/date_picker_widget.dart +++ b/lib/widget/date_picker_widget.dart @@ -1,11 +1,12 @@ import 'dart:math'; + import 'package:auto_size_text/auto_size_text.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; -import '../date_time_formatter.dart'; -import '../date_picker_theme.dart'; import '../date_picker_constants.dart'; +import '../date_picker_theme.dart'; +import '../date_time_formatter.dart'; import '../i18n/date_picker_i18n.dart'; /// Solar months of 31 days. @@ -103,12 +104,9 @@ class _DatePickerWidgetState extends State { @override Widget build(BuildContext context) { - return Container( - //padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 0), - child: GestureDetector( - child: Material( - color: Colors.transparent, child: _renderPickerView(context)), - ), + return Material( + color: Colors.transparent, + child: _renderPickerView(context), ); } @@ -181,85 +179,98 @@ class _DatePickerWidgetState extends State { pickers.add(pickerColumn); }); return Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: pickers); + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: pickers, + ); } - Widget _renderDatePickerColumnComponent( - {required FixedExtentScrollController? scrollCtrl, - required List valueRange, - required String format, - required ValueChanged valueChanged, - double? fontSize}) { + Widget _renderDatePickerColumnComponent({ + required FixedExtentScrollController? scrollCtrl, + required List valueRange, + required String format, + required ValueChanged valueChanged, + double? fontSize, + }) { return Expanded( flex: 1, child: Stack( fit: StackFit.loose, children: [ Positioned( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 7, vertical: 18), - height: widget.pickerTheme!.pickerHeight, - decoration: - BoxDecoration(color: widget.pickerTheme!.backgroundColor), - child: CupertinoPicker( - selectionOverlay: Container(), - backgroundColor: widget.pickerTheme!.backgroundColor, - scrollController: scrollCtrl, - squeeze: 0.95, - diameterRatio: 1.5, - itemExtent: widget.pickerTheme!.itemHeight, - onSelectedItemChanged: valueChanged, - looping: widget.looping, - children: List.generate( - valueRange.last - valueRange.first + 1, - (index) { - return _renderDatePickerItemComponent( - valueRange.first + index, - format, - fontSize, - ); - }, + child: Center( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 7, vertical: 18), + height: widget.pickerTheme!.pickerHeight, + decoration: + BoxDecoration(color: widget.pickerTheme!.backgroundColor), + child: CupertinoPicker( + selectionOverlay: Container(), + backgroundColor: widget.pickerTheme!.backgroundColor, + scrollController: scrollCtrl, + squeeze: 0.95, + diameterRatio: 1.5, + itemExtent: widget.pickerTheme!.itemHeight, + onSelectedItemChanged: valueChanged, + looping: widget.looping, + children: List.generate( + valueRange.last - valueRange.first + 1, + (index) { + return _renderDatePickerItemComponent( + valueRange.first + index, + format, + fontSize, + ); + }, + ), ), ), ), ), Positioned( child: Container( - margin: const EdgeInsets.only(top: 63), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(width: MediaQuery.of(context).size.width * 0.02), - Expanded( - child: Divider( - color: widget.pickerTheme!.dividerColor ?? - widget.pickerTheme!.itemTextStyle.color, - height: 1, - thickness: 2, - ), + margin: EdgeInsets.only( + top: (widget.pickerTheme!.pickerHeight / 2) - + (widget.pickerTheme!.itemHeight / 2), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(width: MediaQuery.of(context).size.width * 0.02), + Expanded( + child: Divider( + color: widget.pickerTheme!.dividerColor ?? + widget.pickerTheme!.itemTextStyle.color, + height: 1, + thickness: 2, ), - SizedBox(width: MediaQuery.of(context).size.width * 0.02) - ], - )), + ), + SizedBox(width: MediaQuery.of(context).size.width * 0.02) + ], + ), + ), ), Positioned( child: Container( - margin: const EdgeInsets.only(top: 99), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(width: MediaQuery.of(context).size.width * 0.02), - Expanded( - child: Divider( - color: widget.pickerTheme!.dividerColor ?? - widget.pickerTheme!.itemTextStyle.color, - height: 1, - thickness: 2, - ), + margin: EdgeInsets.only( + top: (widget.pickerTheme!.pickerHeight / 2) + + (widget.pickerTheme!.itemHeight / 2), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(width: MediaQuery.of(context).size.width * 0.02), + Expanded( + child: Divider( + color: widget.pickerTheme!.dividerColor ?? + widget.pickerTheme!.itemTextStyle.color, + height: 1, + thickness: 2, ), - SizedBox(width: MediaQuery.of(context).size.width * 0.02), - ], - )), + ), + SizedBox(width: MediaQuery.of(context).size.width * 0.02), + ], + ), + ), ), ], ),