feat:交易记录、日期组建
This commit is contained in:
1 parent
08ad1c2d81
commit
88e73ad950
32 files changed
+672
-279
No files matched your search
@@ -1,15 +1,155 @@
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
|
||||
|
||||
Widget appDatePicer(
|
||||
BuildContext context,
|
||||
) {
|
||||
return FCalendar(
|
||||
controller: FCalendarController.range(
|
||||
initialSelection: (DateTime(2024, 7, 17), DateTime(2024, 7, 20)),
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
Widget appDatePicker(
|
||||
BuildContext context, {
|
||||
required Function(List<DateTime>?) onChnage,
|
||||
required List<DateTime>? datetimeRange,
|
||||
}) {
|
||||
final theme = FTheme.of(context);
|
||||
String detail = "请选择";
|
||||
if (!ObjectUtil.isEmpty(datetimeRange)) {
|
||||
final sartStr = DateUtil.formatDate(
|
||||
datetimeRange![0],
|
||||
format: DateFormats.y_mo_d,
|
||||
);
|
||||
final endStr = DateUtil.formatDate(
|
||||
datetimeRange[1],
|
||||
format: DateFormats.y_mo_d,
|
||||
);
|
||||
detail = "$sartStr-$endStr";
|
||||
}
|
||||
return FTile(
|
||||
prefixIcon: FIcon(
|
||||
FAssets.icons.calendar,
|
||||
size: theme.typography.xl.fontSize,
|
||||
),
|
||||
suffixIcon: FIcon(
|
||||
FAssets.icons.chevronsUpDown,
|
||||
size: theme.typography.sm.fontSize,
|
||||
),
|
||||
title: const SizedBox.shrink(),
|
||||
details: Text(
|
||||
detail,
|
||||
style: theme.typography.base,
|
||||
),
|
||||
onPress: () async {
|
||||
final result = await appShowDatePicker(
|
||||
context,
|
||||
datetimeRange: datetimeRange,
|
||||
);
|
||||
onChnage(result);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<DateTime>?> appShowDatePicker(
|
||||
BuildContext context, {
|
||||
List<DateTime>? datetimeRange,
|
||||
}) async {
|
||||
final theme = FTheme.of(context);
|
||||
final width = context.width;
|
||||
final height = context.height;
|
||||
// 默认时间为当天
|
||||
DateTime startTIme = DateTime.now();
|
||||
DateTime endTime = DateTime.now().add(const Duration(days: 1));
|
||||
if (!ObjectUtil.isEmptyList(datetimeRange)) {
|
||||
startTIme = datetimeRange![0];
|
||||
endTime = datetimeRange[1];
|
||||
}
|
||||
List<DateTime> slectDateTime = [];
|
||||
return await showAdaptiveDialog<List<DateTime>?>(
|
||||
context: context,
|
||||
builder: (context) => FDialog(
|
||||
style: theme.dialogStyle.copyWith(
|
||||
insetPadding: EdgeInsets.zero,
|
||||
maxWidth: width * 0.6,
|
||||
minWidth: width * 0.6,
|
||||
horizontalStyle: theme.dialogStyle.horizontalStyle.copyWith(
|
||||
padding: EdgeInsets.all(20.w),
|
||||
),
|
||||
),
|
||||
direction: Axis.horizontal,
|
||||
title: const SizedBox.shrink(),
|
||||
body: SfDateRangePicker(
|
||||
onSelectionChanged: (date) {
|
||||
if (date.value is PickerDateRange) {
|
||||
final v = date.value as PickerDateRange;
|
||||
if (v.startDate == null || v.endDate == null) {
|
||||
return;
|
||||
}
|
||||
slectDateTime = [v.startDate!, v.endDate!];
|
||||
}
|
||||
},
|
||||
initialSelectedDates: [startTIme, endTime],
|
||||
selectionMode: DateRangePickerSelectionMode.range,
|
||||
headerHeight: 60.h,
|
||||
todayHighlightColor: theme.colorScheme.primary,
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
headerStyle: DateRangePickerHeaderStyle(
|
||||
textStyle: theme.typography.xl,
|
||||
textAlign: TextAlign.center,
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
),
|
||||
selectionColor: theme.colorScheme.primary,
|
||||
startRangeSelectionColor: theme.colorScheme.primary,
|
||||
endRangeSelectionColor: theme.colorScheme.primary,
|
||||
rangeSelectionColor: theme.colorScheme.mutedForeground,
|
||||
selectionTextStyle: theme.typography.sm.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
rangeTextStyle: theme.typography.sm,
|
||||
monthCellStyle: DateRangePickerMonthCellStyle(
|
||||
textStyle: theme.typography.sm,
|
||||
todayTextStyle: theme.typography.sm,
|
||||
weekendTextStyle: theme.typography.sm,
|
||||
),
|
||||
monthViewSettings: DateRangePickerMonthViewSettings(
|
||||
viewHeaderHeight: 50.h,
|
||||
showWeekNumber: true,
|
||||
weekNumberStyle: DateRangePickerWeekNumberStyle(
|
||||
textStyle: theme.typography.sm,
|
||||
backgroundColor: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
viewHeaderStyle: DateRangePickerViewHeaderStyle(
|
||||
textStyle: theme.typography.base,
|
||||
),
|
||||
),
|
||||
).width(width).height(height * 0.6),
|
||||
actions: [
|
||||
FButton(
|
||||
label: Text(
|
||||
"确定",
|
||||
style: theme.typography.xl.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
onPress: () {
|
||||
if (ObjectUtil.isEmptyList(slectDateTime)) {
|
||||
Toast.error(msg: "请选择日期范围");
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop(slectDateTime);
|
||||
},
|
||||
).width(200.w),
|
||||
SizedBox(width: 30.w),
|
||||
FButton(
|
||||
style: FButtonStyle.destructive,
|
||||
label: Text(
|
||||
"取消",
|
||||
style: theme.typography.xl.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
onPress: () => Navigator.of(context).pop(null),
|
||||
).width(200.w),
|
||||
],
|
||||
),
|
||||
start: DateTime(2024),
|
||||
today: DateTime(2024, 7, 15),
|
||||
end: DateTime(2030),
|
||||
);
|
||||
}
|
||||
@@ -28,13 +28,14 @@ Future<bool> appMessageDialog(BuildContext context, String msg) async {
|
||||
label: Text('取消', style: theme.typography.base),
|
||||
onPress: () => Navigator.of(context).pop(false)),
|
||||
FButton(
|
||||
label: Text(
|
||||
'确定',
|
||||
style: theme.typography.base.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Text(
|
||||
'确定',
|
||||
style: theme.typography.base.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
onPress: () => Navigator.of(context).pop(true)),
|
||||
),
|
||||
onPress: () => Navigator.of(context).pop(true),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ Widget appPage(
|
||||
return <Widget>[
|
||||
<Widget>[
|
||||
Text(
|
||||
"共 $total 条",
|
||||
"每页$pageSize条,共$total条",
|
||||
style: theme.typography.lg.copyWith(
|
||||
fontWeight: theme.typography.xl8.fontWeight,
|
||||
color: theme.colorScheme.primary,
|
||||
|
||||
Reference in new issue
Block a user