diff --git a/example/pubspec.lock b/example/pubspec.lock index b0fd7cf..cf3b2c7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -16,7 +16,7 @@ packages: path: ".." relative: true source: path - version: "0.0.4" + version: "1.0.0" args: dependency: "direct main" description: @@ -227,7 +227,7 @@ packages: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.4.0" + version: "1.3.0" path: dependency: transitive description: diff --git a/lib/list_tile/as_option_tile_item.dart b/lib/list_tile/as_option_tile_item.dart index b39b05e..a42a511 100644 --- a/lib/list_tile/as_option_tile_item.dart +++ b/lib/list_tile/as_option_tile_item.dart @@ -1,12 +1,12 @@ +import 'package:ansu_ui/extension/num_extension.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:ansu_ui/extension/num_extension.dart'; class ASOptionTileItem extends StatelessWidget { final Widget? leading; final Widget? title; - final onPressed; + final VoidCallback? onPressed; const ASOptionTileItem({ Key? key, this.leading, diff --git a/lib/pickers/as_date_picker.dart b/lib/pickers/as_date_picker.dart index 64efd8a..2632323 100644 --- a/lib/pickers/as_date_picker.dart +++ b/lib/pickers/as_date_picker.dart @@ -5,7 +5,19 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; //时间选择器内部实现 class _ASDatePickerWidget extends StatefulWidget { - _ASDatePickerWidget({Key? key}) : super(key: key); + final CupertinoDatePickerMode mode; + + _ASDatePickerWidget({Key? key}) + : mode = CupertinoDatePickerMode.date, + super(key: key); + + _ASDatePickerWidget.time({Key? key}) + : mode = CupertinoDatePickerMode.time, + super(key: key); + + _ASDatePickerWidget.dateAndTime({Key? key}) + : mode = CupertinoDatePickerMode.dateAndTime, + super(key: key); @override _ASDatePickerWidgetState createState() => _ASDatePickerWidgetState(); @@ -13,6 +25,7 @@ class _ASDatePickerWidget extends StatefulWidget { class _ASDatePickerWidgetState extends State<_ASDatePickerWidget> { DateTime? _dateTime; + @override void initState() { super.initState(); @@ -29,11 +42,10 @@ class _ASDatePickerWidgetState extends State<_ASDatePickerWidget> { child: Padding( padding: EdgeInsets.symmetric(horizontal: 18.w), child: CupertinoDatePicker( - onDateTimeChanged: (dateTime) { - _dateTime = dateTime; - }, - mode: CupertinoDatePickerMode.date, - ), + onDateTimeChanged: (dateTime) { + _dateTime = dateTime; + }, + mode: widget.mode), ), ); } @@ -57,7 +69,7 @@ class _ASDatePickerWidgetState extends State<_ASDatePickerWidget> { ///```dart ///Navigator.pop(context,dateTime) ///``` -Future asDatePicker(BuildContext context) async { +Future showAsDatePicker(BuildContext context) async { return await showModalBottomSheet( context: context, builder: (context) { @@ -65,3 +77,21 @@ Future asDatePicker(BuildContext context) async { }, ); } + +Future showAsTimePicker(BuildContext context) async { + return await showModalBottomSheet( + context: context, + builder: (context) { + return _ASDatePickerWidget.time(); + }, + ); +} + +Future showAsDateAndTimePicker(BuildContext context) async { + return await showModalBottomSheet( + context: context, + builder: (context) { + return _ASDatePickerWidget.dateAndTime(); + }, + ); +} diff --git a/pubspec.lock b/pubspec.lock index f99489e..fae8b8e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,77 +14,77 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0" + version: "2.6.1" auto_size_text_pk: dependency: transitive description: name: auto_size_text_pk - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "3.0.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" bot_toast: dependency: "direct main" description: name: bot_toast - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "4.0.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.15.0" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "0.3.1+4" + version: "0.3.1+5" expandable: dependency: "direct main" description: name: expandable - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "5.0.1" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" flutter: @@ -96,21 +96,21 @@ packages: dependency: "direct main" description: name: flutter_easyrefresh - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.2.1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.2" + version: "2.0.3" flutter_screenutil: dependency: "direct main" description: name: flutter_screenutil - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "5.0.0+2" flutter_test: @@ -127,98 +127,98 @@ packages: dependency: "direct main" description: name: get - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "4.3.8" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.13.3" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "4.0.0" image_picker: dependency: "direct main" description: name: image_picker - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.7.5+4" image_picker_for_web: dependency: transitive description: name: image_picker_for_web - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.3" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.3.0" + version: "2.4.1" intl: dependency: transitive description: name: intl - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.17.0" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.6.3" lpinyin: dependency: "direct main" description: name: lpinyin - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.0.3" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.8.0" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.11.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.0.1" sky_engine: @@ -230,70 +230,70 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" velocity_x: dependency: "direct main" description: name: velocity_x - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "3.3.0" vxstate: dependency: transitive description: name: vxstate - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" sdks: