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 @@
-
+
@@ -110,36 +80,28 @@
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
@@ -163,15 +125,6 @@
-
-
-
-
-
-
-
-
-
@@ -181,6 +134,12 @@
+
+
+
+
+
+
@@ -208,12 +167,21 @@
1536900584939
+
+ 1604072162084
+
+
+
+ 1604072162084
+
+
-
+
+
-
+
@@ -231,7 +199,7 @@
-
+
@@ -244,6 +212,10 @@
+
+
+
+
@@ -255,17 +227,11 @@
-
-
-
-
-
-
-
+
-
-
+
+
@@ -280,16 +246,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -307,16 +263,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/flutter_cupertino_data_picker.iml b/flutter_cupertino_data_picker.iml
index 8d48a06..d9bd5ad 100644
--- a/flutter_cupertino_data_picker.iml
+++ b/flutter_cupertino_data_picker.iml
@@ -12,8 +12,8 @@
-
+
\ No newline at end of file
diff --git a/lib/flutter_cupertino_data_picker.dart b/lib/flutter_cupertino_data_picker.dart
index 57dbd3f..f62a9dc 100644
--- a/lib/flutter_cupertino_data_picker.dart
+++ b/lib/flutter_cupertino_data_picker.dart
@@ -21,9 +21,11 @@ class DataPicker {
int selectedIndex: 0,
DateChangedCallback onChanged,
DateChangedCallback onConfirm,
+ prefix: '',
suffix: '',
title: '',
locale: 'zh',
+ dataStyle: const TextStyle(color: Color(0xFF000046), fontSize: _kDatePickerFontSize),
}) {
Navigator.push(
context,
@@ -34,11 +36,12 @@ class DataPicker {
onChanged: onChanged,
onConfirm: onConfirm,
locale: locale,
+ prefix: prefix,
suffix: suffix,
title: title,
- theme: Theme.of(context, shadowThemeOnly: true),
- barrierLabel:
- MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ theme: Theme.of(context),
+ dataStyle: dataStyle,
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
));
}
}
@@ -53,8 +56,10 @@ class _DatePickerRoute extends PopupRoute {
this.theme,
this.barrierLabel,
this.locale,
+ this.prefix,
this.suffix,
this.title,
+ this.dataStyle,
RouteSettings settings,
}) : super(settings: settings);
@@ -65,8 +70,10 @@ class _DatePickerRoute extends PopupRoute {
final DateChangedCallback onConfirm;
final ThemeData theme;
final String locale;
+ final String prefix;
final String suffix;
final String title;
+ final TextStyle dataStyle;
@override
Duration get transitionDuration => const Duration(milliseconds: 200);
@@ -85,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,
@@ -101,8 +106,10 @@ class _DatePickerRoute extends PopupRoute {
datas: datas,
onChanged: onChanged,
locale: locale,
+ prefix: prefix,
suffix: suffix,
title: title,
+ dataStyle: dataStyle,
route: this,
),
);
@@ -115,14 +122,15 @@ class _DatePickerRoute extends PopupRoute {
class _DataPickerComponent extends StatefulWidget {
_DataPickerComponent({
- Key key,
@required this.route,
this.initialData: 0,
this.datas,
this.onChanged,
this.locale,
+ this.prefix,
this.suffix,
this.title,
+ this.dataStyle,
});
final DateChangedCallback onChanged;
@@ -132,9 +140,12 @@ class _DataPickerComponent extends StatefulWidget {
final _DatePickerRoute route;
final String locale;
+ final String prefix;
final String suffix;
final String title;
+ final TextStyle dataStyle;
+
@override
State createState() => _DatePickerState(this.initialData);
}
@@ -148,8 +159,7 @@ class _DatePickerState extends State<_DataPickerComponent> {
if (this._initialIndex < 0) {
this._initialIndex = 0;
}
- dataScrollCtrl =
- new FixedExtentScrollController(initialItem: _selectedColorIndex);
+ dataScrollCtrl = new FixedExtentScrollController(initialItem: _selectedColorIndex);
}
@override
@@ -160,8 +170,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,
@@ -202,7 +211,7 @@ class _DatePickerState extends State<_DataPickerComponent> {
return itemView;
}
- Widget _renderDataPickerComponent(String suffixAppend) {
+ Widget _renderDataPickerComponent(String prefixAppend, String suffixAppend, TextStyle dataStyle) {
return new Expanded(
flex: 1,
child: Container(
@@ -224,10 +233,8 @@ class _DatePickerState extends State<_DataPickerComponent> {
children: [
new Expanded(
child: Text(
- '${widget.datas[index]}$suffixAppend',
- style: TextStyle(
- color: Color(0xFF000046),
- fontSize: _kDatePickerFontSize),
+ '$prefixAppend${widget.datas[index]}$suffixAppend',
+ style: dataStyle,
textAlign: TextAlign.center,
softWrap: false,
overflow: TextOverflow.fade,
@@ -241,7 +248,7 @@ class _DatePickerState extends State<_DataPickerComponent> {
}
Widget _renderItemView() {
- return _renderDataPickerComponent(widget.suffix);
+ return _renderDataPickerComponent(widget.prefix, widget.suffix, widget.dataStyle);
}
// Title View
@@ -257,7 +264,7 @@ class _DatePickerState extends State<_DataPickerComponent> {
children: [
Container(
height: _kDatePickerTitleHeight,
- child: FlatButton(
+ child: TextButton(
child: Text(
'$cancel',
style: TextStyle(
@@ -281,7 +288,7 @@ class _DatePickerState extends State<_DataPickerComponent> {
),
Container(
height: _kDatePickerTitleHeight,
- child: FlatButton(
+ child: TextButton(
child: Text(
'$done',
style: TextStyle(
@@ -361,11 +368,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
diff --git a/pubspec.lock b/pubspec.lock
index 10f7aaa..65991e8 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1,34 +1,55 @@
# Generated by pub
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
+# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0"
+ version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "2.1.0-nullsafety.1"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0-nullsafety.1"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.2"
+ version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.11"
+ version: "1.15.0-nullsafety.3"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
@@ -43,37 +64,23 @@ packages:
dependency: transitive
description:
name: matcher
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.5"
+ version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0-nullsafety.4"
path:
dependency: transitive
description:
name: path
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.6.2"
- pedantic:
- dependency: transitive
- description:
- name: pedantic
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.5.0"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.2"
+ version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
@@ -83,57 +90,57 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.5"
+ version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.9.3"
+ version: "1.10.0-nullsafety.2"
stream_channel:
dependency: transitive
description:
name: stream_channel
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.4"
+ version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.1.0-nullsafety.3"
sdks:
- dart: ">=2.2.0 <3.0.0"
+ dart: ">=2.10.0-110 <=2.11.0-213.1.beta"