From 38180504b2db56b752ce872c94b7c258abb0c1f2 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 29 Oct 2020 19:29:18 +0000 Subject: [PATCH 1/5] Update flutter_cupertino_data_picker.dart added prefix --- lib/flutter_cupertino_data_picker.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/flutter_cupertino_data_picker.dart b/lib/flutter_cupertino_data_picker.dart index 57dbd3f..8638d32 100644 --- a/lib/flutter_cupertino_data_picker.dart +++ b/lib/flutter_cupertino_data_picker.dart @@ -21,6 +21,7 @@ class DataPicker { int selectedIndex: 0, DateChangedCallback onChanged, DateChangedCallback onConfirm, + prefix: '', suffix: '', title: '', locale: 'zh', @@ -34,6 +35,7 @@ class DataPicker { onChanged: onChanged, onConfirm: onConfirm, locale: locale, + prefix: prefix, suffix: suffix, title: title, theme: Theme.of(context, shadowThemeOnly: true), @@ -53,6 +55,7 @@ class _DatePickerRoute extends PopupRoute { this.theme, this.barrierLabel, this.locale, + this.prefix, this.suffix, this.title, RouteSettings settings, @@ -65,6 +68,7 @@ class _DatePickerRoute extends PopupRoute { final DateChangedCallback onConfirm; final ThemeData theme; final String locale; + fianl String prefix; final String suffix; final String title; @@ -101,6 +105,7 @@ class _DatePickerRoute extends PopupRoute { datas: datas, onChanged: onChanged, locale: locale, + prefix: prefix, suffix: suffix, title: title, route: this, @@ -121,6 +126,7 @@ class _DataPickerComponent extends StatefulWidget { this.datas, this.onChanged, this.locale, + this.prefix, this.suffix, this.title, }); @@ -132,6 +138,7 @@ class _DataPickerComponent extends StatefulWidget { final _DatePickerRoute route; final String locale; + final String prefix; final String suffix; final String title; @@ -202,7 +209,7 @@ class _DatePickerState extends State<_DataPickerComponent> { return itemView; } - Widget _renderDataPickerComponent(String suffixAppend) { + Widget _renderDataPickerComponent(String prefixAppend, String suffixAppend) { return new Expanded( flex: 1, child: Container( @@ -224,7 +231,7 @@ class _DatePickerState extends State<_DataPickerComponent> { children: [ new Expanded( child: Text( - '${widget.datas[index]}$suffixAppend', + '$prefixAppend${widget.datas[index]}$suffixAppend', style: TextStyle( color: Color(0xFF000046), fontSize: _kDatePickerFontSize), @@ -241,7 +248,7 @@ class _DatePickerState extends State<_DataPickerComponent> { } Widget _renderItemView() { - return _renderDataPickerComponent(widget.suffix); + return _renderDataPickerComponent(widget.prefix, widget.suffix); } // Title View From 61bf11bb907797b07bea101f4cf6b37e2533ab83 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 29 Oct 2020 19:31:27 +0000 Subject: [PATCH 2/5] Added prefix parameter --- lib/flutter_cupertino_data_picker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/flutter_cupertino_data_picker.dart b/lib/flutter_cupertino_data_picker.dart index 8638d32..016fffa 100644 --- a/lib/flutter_cupertino_data_picker.dart +++ b/lib/flutter_cupertino_data_picker.dart @@ -68,7 +68,7 @@ class _DatePickerRoute extends PopupRoute { final DateChangedCallback onConfirm; final ThemeData theme; final String locale; - fianl String prefix; + final String prefix; final String suffix; final String title; From 58422bd0c5f12e8341bda38067b7d6ec752684f5 Mon Sep 17 00:00:00 2001 From: Thomas Lilley Date: Fri, 30 Oct 2020 15:36:02 +0000 Subject: [PATCH 3/5] added data theme --- lib/flutter_cupertino_data_picker.dart | 37 ++++++++++++-------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/flutter_cupertino_data_picker.dart b/lib/flutter_cupertino_data_picker.dart index 016fffa..3dc7754 100644 --- a/lib/flutter_cupertino_data_picker.dart +++ b/lib/flutter_cupertino_data_picker.dart @@ -25,6 +25,7 @@ class DataPicker { suffix: '', title: '', locale: 'zh', + dataStyle: const TextStyle(color: Color(0xFF000046), fontSize: _kDatePickerFontSize), }) { Navigator.push( context, @@ -39,8 +40,8 @@ class DataPicker { suffix: suffix, title: title, theme: Theme.of(context, shadowThemeOnly: true), - barrierLabel: - MaterialLocalizations.of(context).modalBarrierDismissLabel, + dataStyle: dataStyle, + barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, )); } } @@ -58,6 +59,7 @@ class _DatePickerRoute extends PopupRoute { this.prefix, this.suffix, this.title, + this.dataStyle, RouteSettings settings, }) : super(settings: settings); @@ -71,6 +73,7 @@ class _DatePickerRoute extends PopupRoute { final String prefix; final String suffix; final String title; + final TextStyle dataStyle; @override Duration get transitionDuration => const Duration(milliseconds: 200); @@ -89,14 +92,12 @@ class _DatePickerRoute extends PopupRoute { @override AnimationController createAnimationController() { assert(_animationController == null); - _animationController = - BottomSheet.createAnimationController(navigator.overlay); + _animationController = BottomSheet.createAnimationController(navigator.overlay); return _animationController; } @override - Widget buildPage(BuildContext context, Animation animation, - Animation secondaryAnimation) { + Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { Widget bottomSheet = new MediaQuery.removePadding( context: context, removeTop: true, @@ -108,6 +109,7 @@ class _DatePickerRoute extends PopupRoute { prefix: prefix, suffix: suffix, title: title, + dataStyle: dataStyle, route: this, ), ); @@ -129,6 +131,7 @@ class _DataPickerComponent extends StatefulWidget { this.prefix, this.suffix, this.title, + this.dataStyle, }); final DateChangedCallback onChanged; @@ -142,6 +145,8 @@ class _DataPickerComponent extends StatefulWidget { final String suffix; final String title; + final TextStyle dataStyle; + @override State createState() => _DatePickerState(this.initialData); } @@ -155,8 +160,7 @@ class _DatePickerState extends State<_DataPickerComponent> { if (this._initialIndex < 0) { this._initialIndex = 0; } - dataScrollCtrl = - new FixedExtentScrollController(initialItem: _selectedColorIndex); + dataScrollCtrl = new FixedExtentScrollController(initialItem: _selectedColorIndex); } @override @@ -167,8 +171,7 @@ class _DatePickerState extends State<_DataPickerComponent> { builder: (BuildContext context, Widget child) { return new ClipRect( child: new CustomSingleChildLayout( - delegate: new _BottomPickerLayout(widget.route.animation.value, - showTitleActions: widget.route.showTitleActions), + delegate: new _BottomPickerLayout(widget.route.animation.value, showTitleActions: widget.route.showTitleActions), child: new GestureDetector( child: Material( color: Colors.transparent, @@ -209,7 +212,7 @@ class _DatePickerState extends State<_DataPickerComponent> { return itemView; } - Widget _renderDataPickerComponent(String prefixAppend, String suffixAppend) { + Widget _renderDataPickerComponent(String prefixAppend, String suffixAppend, TextStyle dataStyle) { return new Expanded( flex: 1, child: Container( @@ -232,9 +235,7 @@ class _DatePickerState extends State<_DataPickerComponent> { new Expanded( child: Text( '$prefixAppend${widget.datas[index]}$suffixAppend', - style: TextStyle( - color: Color(0xFF000046), - fontSize: _kDatePickerFontSize), + style: dataStyle, textAlign: TextAlign.center, softWrap: false, overflow: TextOverflow.fade, @@ -248,7 +249,7 @@ class _DatePickerState extends State<_DataPickerComponent> { } Widget _renderItemView() { - return _renderDataPickerComponent(widget.prefix, widget.suffix); + return _renderDataPickerComponent(widget.prefix, widget.suffix, widget.dataStyle); } // Title View @@ -368,11 +369,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { maxHeight += _kDatePickerTitleHeight; } - return new BoxConstraints( - minWidth: constraints.maxWidth, - maxWidth: constraints.maxWidth, - minHeight: 0.0, - maxHeight: maxHeight); + return new BoxConstraints(minWidth: constraints.maxWidth, maxWidth: constraints.maxWidth, minHeight: 0.0, maxHeight: maxHeight); } @override From 20bc382b8657e0a9a18d03a88418ad7b235ba09c Mon Sep 17 00:00:00 2001 From: Thomas Lilley Date: Fri, 30 Oct 2020 15:42:20 +0000 Subject: [PATCH 4/5] added data theme --- .idea/libraries/Dart_Packages.xml | 104 +++++++++++----------- .idea/workspace.xml | 138 +++++++++--------------------- flutter_cupertino_data_picker.iml | 2 +- pubspec.lock | 99 +++++++++++---------- 4 files changed, 152 insertions(+), 191 deletions(-) diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index d32b503..ba13c59 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -5,166 +5,174 @@ - - + + + + + + - - + - - + - - + - - + - - + - - + - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1488020..134d29d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,10 +7,10 @@ + - - - + + @@ -24,44 +24,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + @@ -99,7 +69,7 @@ - +