张萌 4 years ago
commit d4b0af5dce

@ -50,6 +50,16 @@ class _ExamplePickerState extends State<ExamplePicker> {
},
),
),
ListTile(
title: Text('时间区间选择器'),
subtitle: Text('DateRangePicker'),
trailing: ASButton(
title: '时间区间选择器',
onPressed: () async {
show2DatePicker(context);
},
),
),
],
),
);

@ -38,6 +38,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';

@ -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<ASDateRangePicker> {
@override
Widget build(BuildContext context) {
return SizedBox();
}
}

@ -0,0 +1,19 @@
part of ansu_ui;
class RangeDate {
DateTime start;
DateTime end;
RangeDate({
this.start,
this.end,
});
}
Future<RangeDate> show2DatePicker(BuildContext context) async {
return await showModalBottomSheet(
context: context,
builder: (context) {
return AS2DatePicker();
},
);
}

@ -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<AS2DatePicker>
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: () {},
),
),
],
),
),
);
}
}

@ -1,7 +1,7 @@
part of ansu_ui;
///
Future<File> camFile({maxHeight = 3000, maxWidth = 3000}) async {
Future<File> camFile({double maxHeight = 3000,double maxWidth = 3000}) async {
var pickedFile = await ImagePicker().getImage(
source: ImageSource.camera,
maxHeight: maxHeight,

Loading…
Cancel
Save