From 41c95ee94ec0bfca2d613e8206fb01cad3ea41b1 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 18 Dec 2020 10:19:48 +0800 Subject: [PATCH 1/2] update 2datePicker --- example/lib/example_picker.dart | 10 ++ lib/ansu_ui.dart | 2 + lib/pickers/as_date_range_picker.dart | 15 --- lib/pickers/as_date_range_picker_part.dart | 19 ++++ lib/pickers/as_two_date_picker.dart | 102 +++++++++++++++++++++ 5 files changed, 133 insertions(+), 15 deletions(-) delete mode 100644 lib/pickers/as_date_range_picker.dart create mode 100644 lib/pickers/as_date_range_picker_part.dart create mode 100644 lib/pickers/as_two_date_picker.dart diff --git a/example/lib/example_picker.dart b/example/lib/example_picker.dart index e74bf45..2934433 100644 --- a/example/lib/example_picker.dart +++ b/example/lib/example_picker.dart @@ -50,6 +50,16 @@ class _ExamplePickerState extends State { }, ), ), + ListTile( + title: Text('时间区间选择器'), + subtitle: Text('DateRangePicker'), + trailing: ASButton( + title: '时间区间选择器', + onPressed: () async { + show2DatePicker(context); + }, + ), + ), ], ), ); diff --git a/lib/ansu_ui.dart b/lib/ansu_ui.dart index 369a55a..b47865e 100644 --- a/lib/ansu_ui.dart +++ b/lib/ansu_ui.dart @@ -36,6 +36,8 @@ part 'pickers/as_date_picker.dart'; part 'pickers/as_picker_box.dart'; part 'pickers/as_city_picker.dart'; part 'pickers/as_show_city_picker.dart'; +part 'pickers/as_two_date_picker.dart'; +part 'pickers/as_date_range_picker_part.dart'; part 'dialog/as_dialog.dart'; part 'dialog/as_dialog_button.dart'; diff --git a/lib/pickers/as_date_range_picker.dart b/lib/pickers/as_date_range_picker.dart deleted file mode 100644 index 4692728..0000000 --- a/lib/pickers/as_date_range_picker.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/material.dart'; - -class ASDateRangePicker extends StatefulWidget { - ASDateRangePicker({Key key}) : super(key: key); - - @override - _ASDateRangePickerState createState() => _ASDateRangePickerState(); -} - -class _ASDateRangePickerState extends State { - @override - Widget build(BuildContext context) { - return SizedBox(); - } -} diff --git a/lib/pickers/as_date_range_picker_part.dart b/lib/pickers/as_date_range_picker_part.dart new file mode 100644 index 0000000..68ed9db --- /dev/null +++ b/lib/pickers/as_date_range_picker_part.dart @@ -0,0 +1,19 @@ +part of ansu_ui; + +class RangeDate { + DateTime start; + DateTime end; + RangeDate({ + this.start, + this.end, + }); +} + +Future show2DatePicker(BuildContext context) async { + return await showModalBottomSheet( + context: context, + builder: (context) { + return AS2DatePicker(); + }, + ); +} diff --git a/lib/pickers/as_two_date_picker.dart b/lib/pickers/as_two_date_picker.dart new file mode 100644 index 0000000..ad296e7 --- /dev/null +++ b/lib/pickers/as_two_date_picker.dart @@ -0,0 +1,102 @@ +part of ansu_ui; + +class AS2DatePicker extends StatefulWidget { + AS2DatePicker({Key key}) : super(key: key); + + @override + _AS2DatePickerState createState() => _AS2DatePickerState(); +} + +class _AS2DatePickerState extends State + with TickerProviderStateMixin { + int _selectedDay = 0; + + DateTime get now => DateTime.now(); + TabController _tabController; + + DateTimeRange get singleHour => DateTimeRange( + start: now, + end: now.add(Duration(hours: 1)), + ); + Widget _buildDayButton(int index, String title) { + bool sameDay = _selectedDay == index; + return MaterialButton( + elevation: 0, + disabledElevation: 0, + focusElevation: 0, + highlightElevation: 0, + hoverElevation: 0, + color: sameDay ? kForegroundColor : kForegroundColor.withOpacity(0), + onPressed: () => setState(() => _selectedDay = index), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + height: 70.w, + child: title.text.black + .size(16) + .copyWith(fontWeight: sameDay ? FontWeight.bold : FontWeight.normal), + ); + } + + Widget get _renderCheckBox => Container( + height: 14.w, + width: 14.w, + decoration: BoxDecoration( + color: kSecondaryColor, + borderRadius: 7.radius, + ), + child: Icon(Icons.check, size: 12.w), + ); + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 3, vsync: this); + } + + @override + void dispose() { + _tabController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 340.w, + child: Material( + color: kForegroundColor, + child: Column( + children: [ + Row( + children: [ + SizedBox( + width: 112.w, + child: Material( + color: Color(0xFFF2F2F2), + child: ListView( + children: [ + _buildDayButton(0, '今天'), + _buildDayButton(1, '明天'), + _buildDayButton(2, '后天'), + ], + ), + ), + ), + Expanded(child: SizedBox()), + ], + ).expanded, + Container( + margin: EdgeInsets.symmetric( + horizontal: 24.w, + vertical: 18.w, + ), + child: ASLongButton.solid( + title: '确认', + onPressed: () {}, + ), + ), + ], + ), + ), + ); + } +} From d6137d50ab0443c2ced0f9737cd6dcc2ef4a5af5 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 18 Dec 2020 13:58:32 +0800 Subject: [PATCH 2/2] fix cam util --- lib/utils/camera_util.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/camera_util.dart b/lib/utils/camera_util.dart index db05c18..68b095f 100644 --- a/lib/utils/camera_util.dart +++ b/lib/utils/camera_util.dart @@ -1,7 +1,7 @@ part of ansu_ui; ///获取相机文件 -Future camFile({maxHeight = 3000, maxWidth = 3000}) async { +Future camFile({double maxHeight = 3000,double maxWidth = 3000}) async { var pickedFile = await ImagePicker().getImage( source: ImageSource.camera, maxHeight: maxHeight,