wurong
2 years ago
12 changed files with 398 additions and 64 deletions
@ -0,0 +1,91 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:intl/intl.dart'; |
||||
import 'package:syncfusion_flutter_datepicker/datepicker.dart'; |
||||
|
||||
import '../../view_widget/my_appbar.dart'; |
||||
|
||||
class DayReportPage extends StatefulWidget { |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _DayReportPage(); |
||||
} |
||||
} |
||||
|
||||
class _DayReportPage extends State<DayReportPage>{ |
||||
String _selectedDate = ''; |
||||
String _dateCount = ''; |
||||
String _range = ''; |
||||
String _rangeCount = ''; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
} |
||||
|
||||
void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) { |
||||
setState(() { |
||||
if (args.value is PickerDateRange) { |
||||
_range = |
||||
DateFormat('dd/MM/yyyy').format(args.value.startDate).toString() + |
||||
' - ' + |
||||
DateFormat('dd/MM/yyyy') |
||||
.format(args.value.endDate ?? args.value.startDate) |
||||
.toString(); |
||||
} else if (args.value is DateTime) { |
||||
_selectedDate = args.value.toString(); |
||||
} else if (args.value is List<DateTime>) { |
||||
_dateCount = args.value.length.toString(); |
||||
} else { |
||||
_rangeCount = args.value.length.toString(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
appBar: MyAppBar( |
||||
title: "时间选择", |
||||
titleColor: Colors.black, |
||||
leadingColor: Colors.black, |
||||
background: Colors.white, |
||||
), |
||||
body: Stack( |
||||
children: <Widget>[ |
||||
Positioned( |
||||
left: 0, |
||||
right: 0, |
||||
top: 0, |
||||
height: 80, |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
||||
mainAxisSize: MainAxisSize.min, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: <Widget>[ |
||||
Text('Selected date: ' + _selectedDate), |
||||
Text('Selected date count: ' + _dateCount), |
||||
Text('Selected range: ' + _range), |
||||
Text('Selected ranges count: ' + _rangeCount) |
||||
], |
||||
), |
||||
), |
||||
Positioned( |
||||
left: 0, |
||||
top: 80, |
||||
right: 0, |
||||
bottom: 0, |
||||
child: SfDateRangePicker( |
||||
onSelectionChanged: _onSelectionChanged, |
||||
selectionMode: DateRangePickerSelectionMode.single, |
||||
selectionColor: Color(0xFF30415B), |
||||
initialSelectedRange: PickerDateRange( |
||||
DateTime.now().subtract(const Duration(days: 4)), |
||||
DateTime.now().add(const Duration(days: 3))), |
||||
), |
||||
) |
||||
], |
||||
)); |
||||
} |
||||
} |
@ -0,0 +1,86 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:intl/intl.dart'; |
||||
import 'package:syncfusion_flutter_datepicker/datepicker.dart'; |
||||
|
||||
import '../../view_widget/my_appbar.dart'; |
||||
|
||||
class MonthlyReportPage extends StatefulWidget { |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _MonthlyReportPage(); |
||||
} |
||||
} |
||||
|
||||
class _MonthlyReportPage extends State<MonthlyReportPage>{ |
||||
String _selectedDate = ''; |
||||
String _dateCount = ''; |
||||
String _range = ''; |
||||
String _rangeCount = ''; |
||||
|
||||
void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) { |
||||
setState(() { |
||||
if (args.value is PickerDateRange) { |
||||
_range = |
||||
DateFormat('dd/MM/yyyy').format(args.value.startDate).toString() + |
||||
' - ' + |
||||
DateFormat('dd/MM/yyyy') |
||||
.format(args.value.endDate ?? args.value.startDate) |
||||
.toString(); |
||||
} else if (args.value is DateTime) { |
||||
_selectedDate = args.value.toString(); |
||||
} else if (args.value is List<DateTime>) { |
||||
_dateCount = args.value.length.toString(); |
||||
} else { |
||||
_rangeCount = args.value.length.toString(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
appBar: MyAppBar( |
||||
title: "时间选择", |
||||
titleColor: Colors.black, |
||||
leadingColor: Colors.black, |
||||
background: Colors.white, |
||||
), |
||||
body: Stack( |
||||
children: <Widget>[ |
||||
Positioned( |
||||
left: 0, |
||||
right: 0, |
||||
top: 0, |
||||
height: 80, |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
||||
mainAxisSize: MainAxisSize.min, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: <Widget>[ |
||||
Text('Selected date: ' + _selectedDate), |
||||
Text('Selected date count: ' + _dateCount), |
||||
Text('Selected range: ' + _range), |
||||
Text('Selected ranges count: ' + _rangeCount) |
||||
], |
||||
), |
||||
), |
||||
Positioned( |
||||
left: 0, |
||||
top: 80, |
||||
right: 0, |
||||
bottom: 0, |
||||
child: SfDateRangePicker( |
||||
onSelectionChanged: _onSelectionChanged, |
||||
selectionMode: DateRangePickerSelectionMode.range, |
||||
selectionShape: DateRangePickerSelectionShape.rectangle, |
||||
initialSelectedRange: PickerDateRange( |
||||
DateTime.now().subtract(const Duration(days: 4)), |
||||
DateTime.now().add(const Duration(days: 3))), |
||||
), |
||||
) |
||||
], |
||||
)); |
||||
} |
||||
} |
@ -0,0 +1,87 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:intl/intl.dart'; |
||||
import 'package:syncfusion_flutter_datepicker/datepicker.dart'; |
||||
|
||||
import '../../view_widget/my_appbar.dart'; |
||||
|
||||
class WeekReportPage extends StatefulWidget { |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _WeekReportPage(); |
||||
} |
||||
} |
||||
|
||||
class _WeekReportPage extends State<WeekReportPage>{ |
||||
String _selectedDate = ''; |
||||
String _dateCount = ''; |
||||
String _range = ''; |
||||
String _rangeCount = ''; |
||||
|
||||
void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) { |
||||
setState(() { |
||||
if (args.value is PickerDateRange) { |
||||
_range = |
||||
DateFormat('dd/MM/yyyy').format(args.value.startDate).toString() + |
||||
' - ' + |
||||
DateFormat('dd/MM/yyyy') |
||||
.format(args.value.endDate ?? args.value.startDate) |
||||
.toString(); |
||||
} else if (args.value is DateTime) { |
||||
_selectedDate = args.value.toString(); |
||||
} else if (args.value is List<DateTime>) { |
||||
_dateCount = args.value.length.toString(); |
||||
} else { |
||||
_rangeCount = args.value.length.toString(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
appBar: MyAppBar( |
||||
title: "时间选择", |
||||
titleColor: Colors.black, |
||||
leadingColor: Colors.black, |
||||
background: Colors.white, |
||||
), |
||||
body: Stack( |
||||
children: <Widget>[ |
||||
Positioned( |
||||
left: 0, |
||||
right: 0, |
||||
top: 0, |
||||
height: 80, |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
||||
mainAxisSize: MainAxisSize.min, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: <Widget>[ |
||||
Text('Selected date: ' + _selectedDate), |
||||
Text('Selected date count: ' + _dateCount), |
||||
Text('Selected range: ' + _range), |
||||
Text('Selected ranges count: ' + _rangeCount) |
||||
], |
||||
), |
||||
), |
||||
Positioned( |
||||
left: 0, |
||||
top: 80, |
||||
right: 0, |
||||
bottom: 0, |
||||
child: SfDateRangePicker( |
||||
onSelectionChanged: _onSelectionChanged, |
||||
selectionMode: DateRangePickerSelectionMode.range, |
||||
startRangeSelectionColor:Color(0xFF30415B), |
||||
endRangeSelectionColor:Color(0xFF30415B), |
||||
initialSelectedRange: PickerDateRange( |
||||
DateTime.now().subtract(const Duration(days: 4)), |
||||
DateTime.now().add(const Duration(days: 3))), |
||||
), |
||||
) |
||||
], |
||||
)); |
||||
} |
||||
} |
Loading…
Reference in new issue