Commit fee481587e992c3bbdbe0ffabdb91cd9aecb7e1c

Authored by weixin_45529955
1 parent 4da6781a

纪念日阳历阴历结构UI调整

... ... @@ -355,14 +355,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
... ... @@ -376,14 +372,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
... ... @@ -7,7 +6,10 @@ import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
import 'package:one_key/utils/screen_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
... ... @@ -70,7 +72,6 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_list_my');
// Navigator.pop(context);
}
}
... ... @@ -86,10 +87,68 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_list');
// Navigator.pop(context);
}
}
_item(
String title,
String subTitle, {
GestureTapCallback? onTapDel,
GestureTapCallback? onTapEdit,
}) {
return Container(
padding: EdgeInsets.all(w(10)),
// margin: EdgeInsets.symmetric(horizontal: w(20)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
title,
style: TextStyle(
fontSize: font(16), color: MyColours.color_438E93),
),
Spacer(),
InkWell(
onTap: onTapDel,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('f_delete_red'),
width: w(20),
),
)),
InkWell(
onTap: onTapEdit,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('c_edit'),
width: w(20),
),
)),
],
),
VEmptyView(40),
Text(
subTitle,
style: TextStyle(fontSize: font(16), color: MyColours.color_000000),
),
VEmptyView(20),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: MyDivider(
double.infinity,
w(1),
color: MyColours.color_F7F7F7,
),
)
],
),
);
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
... ... @@ -129,167 +188,297 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
itemBuilder: (BuildContext context, int index) {
Cday cday = model.cday![index];
String show = '';
if (cday.desc != null && cday.desc != '') {
//新数据
// 组展示文本
if (cday.month != null) {
//最新的数据
//新数据
// 组展示文本
if (cday.year == null) {
show = cday.desc! +
':' +
cday.month! +
'-' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
if (cday.month != null) {
//最新的数据
if (cday.year == null) {
if (cday.type == '1') {
show = '(公历)' + cday.month! + '月' + cday.day! + '日';
} else {
show = cday.desc! +
':' +
show = '(农历)' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
} else {
if (cday.type == '1') {
show = '(公历)' +
cday.year! +
'-' +
'年' +
cday.month! +
'-' +
'月' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
'日';
} else {
show = '(农历)' +
cday.year! +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
}
} else {
show =
(cday.type == '1' ? '(公历)' : '(农历)') + cday.dtime!;
List data = cday.dtime!.split('-');
if (cday.type == '1') {
show = '(公历)' +
data[0] +
'年' +
data[1] +
'月' +
data[2] +
'日';
} else {
show = cday.desc! +
':' +
cday.dtime! +
(cday.type == '1' ? '(公历)' : '(农历)');
show = '(农历)' +
data[0] +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(data[1]), int.parse(data[2]));
}
}
return InkWell(
onTap: () {
String? str = cday.content;
String yearStr = '选填';
String? monthStr = '';
String? dayStr = '';
bool gongli = true;
String? content = '';
// str += '${name}:';
// if (yearStr != '' &&
// yearStr != null &&
// yearStr != '选填') {
// str += '${yearStr}年';
// }
// str += '${monthStr}月';
// str += '${dayStr}日';
// str += '(${gongli ? '公历' : '农历'})';
if (cday.desc != null && cday.desc != '') {
content = cday.desc;
if (cday.month != null) {
//最新的数据
return _item(cday.desc ?? '',
cday.content == null ? show : cday.content!,
onTapDel: () {
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否删除该纪念日",
rTitle: "删除", rCallback: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
_delGuestInfocDay(model.cday![index].id);
});
}, onTapEdit: () {
String? str = cday.content;
String yearStr = '选填';
String? monthStr = '';
String? dayStr = '';
bool gongli = true;
String? content = '';
// str += '${name}:';
// if (yearStr != '' &&
// yearStr != null &&
// yearStr != '选填') {
// str += '${yearStr}年';
// }
// str += '${monthStr}月';
// str += '${dayStr}日';
// str += '(${gongli ? '公历' : '农历'})';
yearStr = cday.year ?? '选填';
monthStr = cday.month;
dayStr = cday.day;
} else {
//新数据
if (cday.desc != null && cday.desc != '') {
content = cday.desc;
if (cday.month != null) {
//最新的数据
List<String> ymd = cday.dtime!.split('-');
if (ymd.length == 3) {
//含有年
yearStr = ymd[0];
monthStr = ymd[1];
dayStr = ymd[2];
} else if (ymd.length == 2) {
//没有年
monthStr = ymd[0];
dayStr = ymd[1];
}
yearStr = cday.year ?? '选填';
monthStr = cday.month;
dayStr = cday.day;
} else {
//新数据
if (monthStr.startsWith('0')) {
monthStr =
monthStr.substring(1, monthStr.length);
}
if (dayStr.startsWith('0')) {
dayStr = dayStr.substring(1, dayStr.length);
}
List<String> ymd = cday.dtime!.split('-');
if (ymd.length == 3) {
//含有年
yearStr = ymd[0];
monthStr = ymd[1];
dayStr = ymd[2];
} else if (ymd.length == 2) {
//没有年
monthStr = ymd[0];
dayStr = ymd[1];
}
print(monthStr);
print(dayStr);
}
if (monthStr.startsWith('0')) {
monthStr = monthStr.substring(1, monthStr.length);
}
if (dayStr.startsWith('0')) {
dayStr = dayStr.substring(1, dayStr.length);
}
print(monthStr);
print(dayStr);
}
gongli = cday.type == '1' ? true : false;
gongli = cday.type == '1' ? true : false;
} else {
content = str!.substring(0, str.indexOf(':'));
String tempStr =
str.substring(str.indexOf(':'), str.length);
if (tempStr.contains('年')) {
yearStr = tempStr.substring(
tempStr.indexOf(':') + 1, tempStr.indexOf('年'));
}
if (tempStr.contains('月')) {
if (tempStr.contains('年')) {
monthStr = tempStr.substring(
tempStr.indexOf('年') + 1,
tempStr.indexOf('月'));
} else {
content = str!.substring(0, str.indexOf(':'));
String tempStr =
str.substring(str.indexOf(':'), str.length);
if (tempStr.contains('年')) {
yearStr = tempStr.substring(
tempStr.indexOf(':') + 1,
tempStr.indexOf('年'));
}
if (tempStr.contains('月')) {
if (tempStr.contains('年')) {
monthStr = tempStr.substring(
tempStr.indexOf('年') + 1,
tempStr.indexOf('月'));
} else {
monthStr = tempStr.substring(
tempStr.indexOf(':') + 1,
tempStr.indexOf('月'));
}
}
if (tempStr.contains('日')) {
dayStr = tempStr.substring(
tempStr.indexOf('月') + 1,
tempStr.indexOf('日'));
}
if (tempStr.contains('农历')) {
gongli = false;
}
monthStr = tempStr.substring(
tempStr.indexOf(':') + 1,
tempStr.indexOf('月'));
}
}
if (tempStr.contains('日')) {
dayStr = tempStr.substring(
tempStr.indexOf('月') + 1, tempStr.indexOf('日'));
}
if (tempStr.contains('农历')) {
gongli = false;
}
}
DialogUtil.festivalAlertDialog(context, content!, 520,
rCallback: (content) {
print(content);
_setGuestInfocDay(model.cday![index].id,
content as Map<dynamic, dynamic>);
// _addCookbookClass(name, showLoading: true);
},
yearStr: yearStr,
monthStr: monthStr,
dayStr: dayStr,
gongli: gongli);
});
// return InkWell(
// onTap: () {
// String? str = cday.content;
// String yearStr = '选填';
// String? monthStr = '';
// String? dayStr = '';
// bool gongli = true;
// String? content = '';
// // str += '${name}:';
// // if (yearStr != '' &&
// // yearStr != null &&
// // yearStr != '选填') {
// // str += '${yearStr}年';
// // }
// // str += '${monthStr}月';
// // str += '${dayStr}日';
// // str += '(${gongli ? '公历' : '农历'})';
// if (cday.desc != null && cday.desc != '') {
// content = cday.desc;
// if (cday.month != null) {
// //最新的数据
// yearStr = cday.year ?? '选填';
// monthStr = cday.month;
// dayStr = cday.day;
// } else {
// //新数据
// List<String> ymd = cday.dtime!.split('-');
// if (ymd.length == 3) {
// //含有年
// yearStr = ymd[0];
// monthStr = ymd[1];
// dayStr = ymd[2];
// } else if (ymd.length == 2) {
// //没有年
// monthStr = ymd[0];
// dayStr = ymd[1];
// }
// if (monthStr.startsWith('0')) {
// monthStr =
// monthStr.substring(1, monthStr.length);
// }
// if (dayStr.startsWith('0')) {
// dayStr = dayStr.substring(1, dayStr.length);
// }
// print(monthStr);
// print(dayStr);
// }
// gongli = cday.type == '1' ? true : false;
// } else {
// content = str!.substring(0, str.indexOf(':'));
// String tempStr =
// str.substring(str.indexOf(':'), str.length);
// if (tempStr.contains('年')) {
// yearStr = tempStr.substring(
// tempStr.indexOf(':') + 1,
// tempStr.indexOf('年'));
// }
// if (tempStr.contains('月')) {
// if (tempStr.contains('年')) {
// monthStr = tempStr.substring(
// tempStr.indexOf('年') + 1,
// tempStr.indexOf('月'));
// } else {
// monthStr = tempStr.substring(
// tempStr.indexOf(':') + 1,
// tempStr.indexOf('月'));
// }
// }
// if (tempStr.contains('日')) {
// dayStr = tempStr.substring(
// tempStr.indexOf('月') + 1,
// tempStr.indexOf('日'));
// }
// if (tempStr.contains('农历')) {
// gongli = false;
// }
// }
DialogUtil.festivalAlertDialog(
context, content!, 520, rCallback: (content) {
print(content);
_setGuestInfocDay(model.cday![index].id, content as Map<dynamic, dynamic>);
// _addCookbookClass(name, showLoading: true);
}, delCallback: () {
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否确定删除该纪念日",
rTitle: "确定删除", rCallback: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
_delGuestInfocDay(model.cday![index].id);
});
},
yearStr: yearStr,
monthStr: monthStr,
dayStr: dayStr,
gongli: gongli);
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
cday.content == null ? show : cday.content!,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
)),
HEmptyView(10),
Image.asset(
Utils.getImgPath('c_edit'),
width: ScreenUtil().setWidth(40),
// height: ScreenUtil().setWidth(10),
)
],
),
));
// DialogUtil.festivalAlertDialog(
// context, content!, 520, rCallback: (content) {
// print(content);
// _setGuestInfocDay(model.cday![index].id, content as Map<dynamic, dynamic>);
// // _addCookbookClass(name, showLoading: true);
// }, delCallback: () {
// //弹框确认是否删除
// DialogUtil.cupertinoAlertDialog(context,
// title: "",
// content: "是否确定删除该纪念日",
// rTitle: "确定删除", rCallback: () {
// if (Navigator.canPop(context)) {
// Navigator.pop(context);
// }
// _delGuestInfocDay(model.cday![index].id);
// });
// },
// yearStr: yearStr,
// monthStr: monthStr,
// dayStr: dayStr,
// gongli: gongli);
// },
// child: Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(20),
// vertical: ScreenUtil().setWidth(20)),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Expanded(
// child: Text(
// cday.content == null ? show : cday.content!,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: ScreenUtil().setSp(26),
// color: MyColours.color_333333),
// )),
// HEmptyView(10),
// Image.asset(
// Utils.getImgPath('c_edit'),
// width: ScreenUtil().setWidth(40),
// // height: ScreenUtil().setWidth(10),
// )
// ],
// ),
// ));
},
);
}
... ...
... ... @@ -12,6 +12,7 @@ import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
... ... @@ -1007,9 +1008,8 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goSetBirthdayPage(context,widget.userHistoryEntity!.gid);
NavigatorUtil.goSetBirthdayPage(
context, widget.userHistoryEntity!.gid);
},
),
],
... ... @@ -1061,45 +1061,84 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
Cday cday = customerProvider
.guestInfoSunModel!.guest!.cDay![index]!;
String? show = cday.content;
if (cday.desc != null && cday.desc != '') {
if (cday.month != null) {
//最新的数据
if (cday.year == null) {
show = cday.desc! +
':' +
if (cday.month != null) {
//最新的数据
if (cday.year == null) {
if (cday.type == '1') {
show = '(公历)' +
cday.month! +
'-' +
'月' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
'日';
} else {
show = cday.desc! +
':' +
show = '(农历)' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
} else {
if (cday.type == '1') {
show = '(公历)' +
cday.year! +
'-' +
'年' +
cday.month! +
'-' +
'月' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
'日';
} else {
show = '(农历)' +
cday.year! +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
}
} else {
show = (cday.type == '1' ? '(公历)' : '(农历)') +
cday.dtime!;
List data = cday.dtime!.split('-');
if (cday.type == '1') {
show = '(公历)' +
data[0] +
'年' +
data[1] +
'月' +
data[2] +
'日';
} else {
show = cday.desc! +
':' +
cday.dtime! +
(cday.type == '1' ? '(公历)' : '(农历)');
show = '(农历)' +
data[0] +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(data[1]),
int.parse(data[2]));
}
}
return Center(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(10)),
child: Text(
show!,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
));
return Padding(
padding:
EdgeInsets.symmetric(vertical: w(10)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
cday.desc ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_438E93),
),
Text(
show,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_000000),
),
],
));
},
)
])),
... ...
import 'package:flutter/material.dart';
import 'package:flutter_lunar_datetime_picker/date_init.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/guest_info_model.dart';
... ... @@ -7,7 +7,10 @@ import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
import 'package:one_key/utils/screen_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
... ... @@ -71,7 +74,6 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_list');
// Navigator.pop(context);
}
}
... ... @@ -87,10 +89,68 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_list');
// Navigator.pop(context);
}
}
_item(
String title,
String subTitle, {
GestureTapCallback? onTapDel,
GestureTapCallback? onTapEdit,
}) {
return Container(
padding: EdgeInsets.all(w(10)),
// margin: EdgeInsets.symmetric(horizontal: w(20)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
title,
style: TextStyle(
fontSize: font(16), color: MyColours.color_438E93),
),
Spacer(),
InkWell(
onTap: onTapDel,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('f_delete_red'),
width: w(20),
),
)),
InkWell(
onTap: onTapEdit,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('c_edit'),
width: w(20),
),
)),
],
),
VEmptyView(40),
Text(
subTitle,
style: TextStyle(fontSize: font(16), color: MyColours.color_000000),
),
VEmptyView(20),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: MyDivider(
double.infinity,
w(1),
color: MyColours.color_F7F7F7,
),
)
],
),
);
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
... ... @@ -130,167 +190,194 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
itemBuilder: (BuildContext context, int index) {
Cday cday = model.cday![index];
String show = '';
if (cday.desc != null && cday.desc != '') {
//新数据
// 组展示文本
if (cday.month != null) {
//最新的数据
//新数据
// 组展示文本
if (cday.year == null) {
show = cday.desc! +
':' +
cday.month! +
'-' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
if (cday.month != null) {
//最新的数据
if (cday.year == null) {
if (cday.type == '1') {
show = '(公历)' + cday.month! + '月' + cday.day! + '日';
} else {
show = cday.desc! +
':' +
show = '(农历)' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
} else {
if (cday.type == '1') {
show = '(公历)' +
cday.year! +
'-' +
'年' +
cday.month! +
'-' +
'月' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
'日';
} else {
show = '(农历)' +
cday.year! +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
}
} else {
show =
(cday.type == '1' ? '(公历)' : '(农历)') + cday.dtime!;
List data = cday.dtime!.split('-');
if (cday.type == '1') {
show = '(公历)' +
data[0] +
'年' +
data[1] +
'月' +
data[2] +
'日';
} else {
show = cday.desc! +
':' +
cday.dtime! +
(cday.type == '1' ? '(公历)' : '(农历)');
show = '(农历)' +
data[0] +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(data[1]), int.parse(data[2]));
}
}
return InkWell(
onTap: () {
String? str = cday.content;
String yearStr = '选填';
String? monthStr = '';
String? dayStr = '';
bool gongli = true;
String? content = '';
// str += '${name}:';
// if (yearStr != '' &&
// yearStr != null &&
// yearStr != '选填') {
// str += '${yearStr}年';
// }
// str += '${monthStr}月';
// str += '${dayStr}日';
// str += '(${gongli ? '公历' : '农历'})';
if (cday.desc != null && cday.desc != '') {
content = cday.desc;
if (cday.month != null) {
//最新的数据
return _item(cday.desc ?? '',
cday.content == null ? show : cday.content!,
onTapDel: () {
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否删除该纪念日",
rTitle: "删除", rCallback: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
_delGuestInfocDay(model.cday![index].id);
});
}, onTapEdit: () {
String? str = cday.content;
String yearStr = '选填';
String? monthStr = '';
String? dayStr = '';
bool gongli = true;
String? content = '';
// str += '${name}:';
// if (yearStr != '' &&
// yearStr != null &&
// yearStr != '选填') {
// str += '${yearStr}年';
// }
// str += '${monthStr}月';
// str += '${dayStr}日';
// str += '(${gongli ? '公历' : '农历'})';
yearStr = cday.year ?? '选填';
monthStr = cday.month;
dayStr = cday.day;
} else {
//新数据
if (cday.desc != null && cday.desc != '') {
content = cday.desc;
if (cday.month != null) {
//最新的数据
List<String> ymd = cday.dtime!.split('-');
if (ymd.length == 3) {
//含有年
yearStr = ymd[0];
monthStr = ymd[1];
dayStr = ymd[2];
} else if (ymd.length == 2) {
//没有年
monthStr = ymd[0];
dayStr = ymd[1];
}
yearStr = cday.year ?? '选填';
monthStr = cday.month;
dayStr = cday.day;
} else {
//新数据
if (monthStr.startsWith('0')) {
monthStr =
monthStr.substring(1, monthStr.length);
}
if (dayStr.startsWith('0')) {
dayStr = dayStr.substring(1, dayStr.length);
}
List<String> ymd = cday.dtime!.split('-');
if (ymd.length == 3) {
//含有年
yearStr = ymd[0];
monthStr = ymd[1];
dayStr = ymd[2];
} else if (ymd.length == 2) {
//没有年
monthStr = ymd[0];
dayStr = ymd[1];
}
print(monthStr);
print(dayStr);
}
if (monthStr.startsWith('0')) {
monthStr = monthStr.substring(1, monthStr.length);
}
if (dayStr.startsWith('0')) {
dayStr = dayStr.substring(1, dayStr.length);
}
print(monthStr);
print(dayStr);
}
gongli = cday.type == '1' ? true : false;
gongli = cday.type == '1' ? true : false;
} else {
content = str!.substring(0, str.indexOf(':'));
String tempStr =
str.substring(str.indexOf(':'), str.length);
if (tempStr.contains('年')) {
yearStr = tempStr.substring(
tempStr.indexOf(':') + 1, tempStr.indexOf('年'));
}
if (tempStr.contains('月')) {
if (tempStr.contains('年')) {
monthStr = tempStr.substring(
tempStr.indexOf('年') + 1,
tempStr.indexOf('月'));
} else {
content = str!.substring(0, str.indexOf(':'));
String tempStr =
str.substring(str.indexOf(':'), str.length);
if (tempStr.contains('年')) {
yearStr = tempStr.substring(
tempStr.indexOf(':') + 1,
tempStr.indexOf('年'));
}
if (tempStr.contains('月')) {
if (tempStr.contains('年')) {
monthStr = tempStr.substring(
tempStr.indexOf('年') + 1,
tempStr.indexOf('月'));
} else {
monthStr = tempStr.substring(
tempStr.indexOf(':') + 1,
tempStr.indexOf('月'));
}
}
if (tempStr.contains('日')) {
dayStr = tempStr.substring(
tempStr.indexOf('月') + 1,
tempStr.indexOf('日'));
}
if (tempStr.contains('农历')) {
gongli = false;
}
monthStr = tempStr.substring(
tempStr.indexOf(':') + 1,
tempStr.indexOf('月'));
}
}
if (tempStr.contains('日')) {
dayStr = tempStr.substring(
tempStr.indexOf('月') + 1, tempStr.indexOf('日'));
}
if (tempStr.contains('农历')) {
gongli = false;
}
}
DialogUtil.festivalAlertDialog(context, content!, 520,
rCallback: (content) {
print(content);
_setGuestInfocDay(model.cday![index].id,
content as Map<dynamic, dynamic>);
// _addCookbookClass(name, showLoading: true);
},
yearStr: yearStr,
monthStr: monthStr,
dayStr: dayStr,
gongli: gongli);
});
// return InkWell(
// onTap: () {
DialogUtil.festivalAlertDialog(
context, content!, 520, rCallback: (content) {
print(content);
_setGuestInfocDay(model.cday![index].id, content as Map<dynamic, dynamic>);
// _addCookbookClass(name, showLoading: true);
}, delCallback: () {
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否确定删除该纪念日",
rTitle: "确定删除", rCallback: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
_delGuestInfocDay(model.cday![index].id);
});
},
yearStr: yearStr,
monthStr: monthStr,
dayStr: dayStr,
gongli: gongli);
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
cday.content == null ? show : cday.content!,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
)),
HEmptyView(10),
Image.asset(
Utils.getImgPath('c_edit'),
width: ScreenUtil().setWidth(40),
// height: ScreenUtil().setWidth(10),
)
],
),
));
// },
// child: Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(20),
// vertical: ScreenUtil().setWidth(20)),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Expanded(
// child: Text(
// cday.content == null ? show : cday.content!,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: ScreenUtil().setSp(26),
// color: MyColours.color_333333),
// )),
// HEmptyView(10),
// Image.asset(
// Utils.getImgPath('c_edit'),
// width: ScreenUtil().setWidth(40),
// // height: ScreenUtil().setWidth(10),
// )
// ],
// ),
// ));
},
);
}
... ...
... ... @@ -8,6 +8,8 @@ import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_lunar_datetime_picker/date_init.dart';
import 'package:flutter_lunar_datetime_picker/flutter_lunar_datetime_picker.dart';
import 'package:flutter_picker_plus/flutter_picker_plus.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
... ... @@ -23,6 +25,7 @@ import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/NumLengthInputFormatter.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_day.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_month.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_year.dart';
... ... @@ -55,6 +58,12 @@ import '../models/titlte_type_model.dart';
import '../pages/my/marketing_center/theme_model.dart';
import '../provider/collect_store_provider.dart';
import 'package:flutter_lunar_datetime_picker/flutter_lunar_datetime_picker.dart';
import 'package:flutter_lunar_datetime_picker/datetime_picker_theme.dart'
as picker_theme;
import 'package:lunar/lunar.dart';
typedef CustomCallBack = void Function(Object? object);
typedef CustomCallBackMap = void Function(Map<String, String?> object);
... ... @@ -11815,8 +11824,7 @@ class DialogUtil {
static Future festivalAlertDialog(
BuildContext context, String name, double height,
{CustomCallBack? rCallback,
GestureTapCallback? delCallback,
double fontSize = 28,
double fontSize = 32,
String? yearStr = '选填',
String? monthStr = '',
String? dayStr = '',
... ... @@ -11827,6 +11835,42 @@ class DialogUtil {
builder: (BuildContext context) {
TextEditingController controller = TextEditingController();
controller.text = name;
yearStr = yearStr == '选填' ? DateTime.now().year.toString() : yearStr;
monthStr = monthStr == '' ? DateTime.now().month.toString() : monthStr;
dayStr = dayStr == '' ? DateTime.now().day.toString() : dayStr;
String show = (yearStr ?? '') +
'年' +
(monthStr ?? '') +
'月' +
(dayStr ?? '') +
'日';
DateTime now = DateTime(
int.parse(yearStr!),
int.parse(monthStr!),
int.parse(dayStr!),
);
if (!gongli) {
//格式化农历日期
show = (yearStr ?? '') +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(monthStr!), int.parse(dayStr!));
print(show);
int mLeapMonth = LunarCalendarUtil.leapMonth(int.parse(yearStr!));
List<int?> time = LunarCalendarUtil.lunarToSolar(
int.parse(yearStr!),
int.parse(monthStr!),
int.parse(dayStr!),
mLeapMonth == int.parse(monthStr!));
now = DateTime(time[0]!, time[1]!, time[2]!);
}
return StatefulBuilder(builder: (context, stateSetter) {
return Scaffold(
backgroundColor: Colors.transparent,
... ... @@ -11862,25 +11906,25 @@ class DialogUtil {
fontSize: ScreenUtil().setSp(fontSize),
color: MyColours.color_353535)),
),
monthStr == ''
? SizedBox()
: Positioned(
right: 0,
top: 0,
child: InkWell(
onTap: delCallback,
child: Padding(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(36)),
child: Text('删除',
style: TextStyle(
decoration: TextDecoration
.underline,
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_199095)),
)))
// monthStr == ''
// ? SizedBox()
// : Positioned(
// right: 0,
// top: 0,
// child: InkWell(
// onTap: delCallback,
// child: Padding(
// padding: EdgeInsets.only(
// top: ScreenUtil().setWidth(36)),
// child: Text('删除',
// style: TextStyle(
// decoration: TextDecoration
// .underline,
// fontSize:
// ScreenUtil().setSp(26),
// color: MyColours
// .color_199095)),
// )))
]),
Container(
... ... @@ -11908,15 +11952,15 @@ class DialogUtil {
TextAlignVertical.bottom,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
),
fontSize: font(16),
color: MyColours.color_438E93),
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '例:本人生日',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
fontSize: font(16),
),
enabledBorder:
new UnderlineInputBorder(
... ... @@ -12053,195 +12097,297 @@ class DialogUtil {
: MyColours.color_333333))),
),
HEmptyView(30),
Spacer(),
InkWell(
onTap: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
incrementCounterYear(
context,
gongli,
yearStr == '选填'
? DateTime.now().year.toString()
: yearStr, (year) {
print(year);
stateSetter(() {
yearStr = year as String?;
});
});
},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
)),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.zero,
child: Text(yearStr!,
style: TextStyle(
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_666666)),
),
HEmptyView(6),
Image.asset(
Utils.getImgPath(false
? 'c_arrow_up'
: 'c_arrow_down'),
width: ScreenUtil().setWidth(28),
// height: ScreenUtil().setWidth(10),
),
],
),
)),
Text('年',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333)),
HEmptyView(10),
InkWell(
onTap: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
incrementCounterMonth(
context,
gongli,
yearStr == '选填'
? DateTime.now().year.toString()
: yearStr,
monthStr == ''
? DateTime.now().month.toString()
: monthStr, (month) {
print(month);
stateSetter(() {
monthStr = month as String?;
});
if (dayStr != '') {
List dayList = updateDay(
gongli,
yearStr == '选填'
? DateTime.now()
.year
.toString()
: yearStr,
monthStr == ''
? DateTime.now()
.month
.toString()
: monthStr);
if (!dayList.contains(dayStr)) {
stateSetter(() {
dayStr = '';
});
}
onTap: () {
DatePicker.showDatePicker(
context,
lunarPicker: !gongli,
showTime: false,
theme: picker_theme.DatePickerTheme(
backgroundColor:
MyColours.color_ffffff,
itemStyle: TextStyle(
color: MyColours.color_438E93,
fontSize: font(16)),
containerHeight: w(220),
titleHeight: w(58),
itemHeight: w(44),
cancelStyle: TextStyle(
color: MyColours.color_999999,
fontSize: font(16)),
doneStyle: TextStyle(
color: MyColours.color_438E93,
fontSize: font(16))),
dateInitTime: DateInitTime(
currentTime: now,
maxTime: DateTime(2050, 12, 12),
minTime: DateTime(1900, 1, 1)),
onConfirm: (time, lunar) {
debugPrint(time.toString());
now = time;
if (gongli) {
yearStr = time.year.toString();
monthStr = time.month.toString();
dayStr = time.day.toString();
show = (yearStr ?? '') +
'年' +
(monthStr ?? '') +
'月' +
(dayStr ?? '') +
'日';
} else {
// 阳历转阴历
// 获取当前阴历
Lunar currentLunarTime =
Solar.fromDate(time).getLunar();
yearStr = currentLunarTime
.getYear()
.toString();
monthStr = currentLunarTime
.getMonth()
.toString();
dayStr = currentLunarTime
.getDay()
.toString();
//转换成农历
show = (yearStr ?? '') +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(monthStr!),
int.parse(dayStr!));
print(show);
// int mLeapMonth =
// LunarCalendarUtil.leapMonth(
// int.parse(yearStr!));
// List<int?> time =
// LunarCalendarUtil.lunarToSolar(
// int.parse(yearStr!),
// int.parse(monthStr!),
// int.parse(dayStr!),
// mLeapMonth ==
// int.parse(monthStr!));
}
});
},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
)),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.zero,
child: Text(monthStr!,
style: TextStyle(
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_666666)),
),
HEmptyView(6),
Image.asset(
Utils.getImgPath(false
? 'c_arrow_up'
: 'c_arrow_down'),
width: ScreenUtil().setWidth(28),
// height: ScreenUtil().setWidth(10),
),
],
),
)),
Text('月',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333)),
HEmptyView(10),
InkWell(
onTap: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
incrementCounterDay(
context,
gongli,
yearStr == '选填'
? DateTime.now().year.toString()
: yearStr,
monthStr == ''
? DateTime.now().month.toString()
: monthStr,
dayStr == ''
? DateTime.now().day.toString()
: dayStr, (day) {
print(dayStr);
stateSetter(() {
dayStr = day as String?;
});
});
},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
)),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.zero,
child: Text(dayStr!,
style: TextStyle(
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_666666)),
),
HEmptyView(6),
Image.asset(
Utils.getImgPath(false
? 'c_arrow_up'
: 'c_arrow_down'),
width: ScreenUtil().setWidth(28),
// height: ScreenUtil().setWidth(10),
),
],
stateSetter(() {});
},
onChanged: (time, lunar) {
debugPrint("change:${time.toString()}");
},
);
},
child: Row(
children: [
Text(
show,
style: TextStyle(
color: MyColours.color_000000,
fontSize: font(16)),
),
)),
Text('日',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333)),
HEmptyView(8),
Image.asset(
Utils.getImgPath('calender_theme'),
width: w(16),
)
],
),
),
// InkWell(
// onTap: () {
// FocusScope.of(context).requestFocus(
// FocusNode()); //点击空白处隐藏键盘
// incrementCounterYear(
// context,
// gongli,
// yearStr == '选填'
// ? DateTime.now().year.toString()
// : yearStr, (year) {
// print(year);
// stateSetter(() {
// yearStr = year as String?;
// });
// });
// },
// child: Container(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(4)),
// decoration: BoxDecoration(
// border: Border(
// bottom: BorderSide(
// color: MyColours.color_E0E0E0,
// width: ScreenUtil().setWidth(2)),
// )),
// child: Row(
// crossAxisAlignment:
// CrossAxisAlignment.end,
// children: [
// Padding(
// padding: EdgeInsets.zero,
// child: Text(yearStr!,
// style: TextStyle(
// fontSize:
// ScreenUtil().setSp(26),
// color: MyColours
// .color_666666)),
// ),
// HEmptyView(6),
// Image.asset(
// Utils.getImgPath(false
// ? 'c_arrow_up'
// : 'c_arrow_down'),
// width: ScreenUtil().setWidth(28),
// // height: ScreenUtil().setWidth(10),
// ),
// ],
// ),
// )),
// Text('年',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(28),
// color: MyColours.color_333333)),
// HEmptyView(10),
// InkWell(
// onTap: () {
// FocusScope.of(context).requestFocus(
// FocusNode()); //点击空白处隐藏键盘
// incrementCounterMonth(
// context,
// gongli,
// yearStr == '选填'
// ? DateTime.now().year.toString()
// : yearStr,
// monthStr == ''
// ? DateTime.now().month.toString()
// : monthStr, (month) {
// print(month);
// stateSetter(() {
// monthStr = month as String?;
// });
// if (dayStr != '') {
// List dayList = updateDay(
// gongli,
// yearStr == '选填'
// ? DateTime.now()
// .year
// .toString()
// : yearStr,
// monthStr == ''
// ? DateTime.now()
// .month
// .toString()
// : monthStr);
// if (!dayList.contains(dayStr)) {
// stateSetter(() {
// dayStr = '';
// });
// }
// }
// });
// },
// child: Container(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(4)),
// decoration: BoxDecoration(
// border: Border(
// bottom: BorderSide(
// color: MyColours.color_E0E0E0,
// width: ScreenUtil().setWidth(2)),
// )),
// child: Row(
// crossAxisAlignment:
// CrossAxisAlignment.end,
// children: [
// Padding(
// padding: EdgeInsets.zero,
// child: Text(monthStr!,
// style: TextStyle(
// fontSize:
// ScreenUtil().setSp(26),
// color: MyColours
// .color_666666)),
// ),
// HEmptyView(6),
// Image.asset(
// Utils.getImgPath(false
// ? 'c_arrow_up'
// : 'c_arrow_down'),
// width: ScreenUtil().setWidth(28),
// // height: ScreenUtil().setWidth(10),
// ),
// ],
// ),
// )),
// Text('月',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(28),
// color: MyColours.color_333333)),
// HEmptyView(10),
// InkWell(
// onTap: () {
// FocusScope.of(context).requestFocus(
// FocusNode()); //点击空白处隐藏键盘
// incrementCounterDay(
// context,
// gongli,
// yearStr == '选填'
// ? DateTime.now().year.toString()
// : yearStr,
// monthStr == ''
// ? DateTime.now().month.toString()
// : monthStr,
// dayStr == ''
// ? DateTime.now().day.toString()
// : dayStr, (day) {
// print(dayStr);
// stateSetter(() {
// dayStr = day as String?;
// });
// });
// },
// child: Container(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(4)),
// decoration: BoxDecoration(
// border: Border(
// bottom: BorderSide(
// color: MyColours.color_E0E0E0,
// width: ScreenUtil().setWidth(2)),
// )),
// child: Row(
// crossAxisAlignment:
// CrossAxisAlignment.end,
// children: [
// Padding(
// padding: EdgeInsets.zero,
// child: Text(dayStr!,
// style: TextStyle(
// fontSize:
// ScreenUtil().setSp(26),
// color: MyColours
// .color_666666)),
// ),
// HEmptyView(6),
// Image.asset(
// Utils.getImgPath(false
// ? 'c_arrow_up'
// : 'c_arrow_down'),
// width: ScreenUtil().setWidth(28),
// // height: ScreenUtil().setWidth(10),
// ),
// ],
// ),
// )),
// Text('日',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(28),
// color: MyColours.color_333333)),
],
),
VEmptyView(60),
... ...
/**
* 农历的工具类
*/
class LunarCalendarUtil {
/**
* 支持转换的最小农历年份
... ... @@ -12,10 +14,28 @@ class LunarCalendarUtil {
* 支持转换的最大农历年份
*/
static final int MAX_YEAR = 2099;
/**
* 公历每月前的天数
*/
static final List<int> DAYS_BEFORE_MONTH = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
static final List<int> DAYS_BEFORE_MONTH = [
0,
31,
59,
90,
120,
151,
181,
212,
243,
273,
304,
334,
365
];
/**
* 用来表示1900年到2099年间农历年份的相关信息,共24位bit的16进制表示,其中:
... ... @@ -30,45 +50,224 @@ class LunarCalendarUtil {
/*1900*/
0x84B6BF,
/*1901-1910*/
0x04AE53, 0x0A5748, 0x5526BD, 0x0D2650, 0x0D9544, 0x46AAB9, 0x056A4D, 0x09AD42, 0x24AEB6, 0x04AE4A,
0x04AE53,
0x0A5748,
0x5526BD,
0x0D2650,
0x0D9544,
0x46AAB9,
0x056A4D,
0x09AD42,
0x24AEB6,
0x04AE4A,
/*1911-1920*/
0x6A4DBE, 0x0A4D52, 0x0D2546, 0x5D52BA, 0x0B544E, 0x0D6A43, 0x296D37, 0x095B4B, 0x749BC1, 0x049754,
0x6A4DBE,
0x0A4D52,
0x0D2546,
0x5D52BA,
0x0B544E,
0x0D6A43,
0x296D37,
0x095B4B,
0x749BC1,
0x049754,
/*1921-1930*/
0x0A4B48, 0x5B25BC, 0x06A550, 0x06D445, 0x4ADAB8, 0x02B64D, 0x095742, 0x2497B7, 0x04974A, 0x664B3E,
0x0A4B48,
0x5B25BC,
0x06A550,
0x06D445,
0x4ADAB8,
0x02B64D,
0x095742,
0x2497B7,
0x04974A,
0x664B3E,
/*1931-1940*/
0x0D4A51, 0x0EA546, 0x56D4BA, 0x05AD4E, 0x02B644, 0x393738, 0x092E4B, 0x7C96BF, 0x0C9553, 0x0D4A48,
0x0D4A51,
0x0EA546,
0x56D4BA,
0x05AD4E,
0x02B644,
0x393738,
0x092E4B,
0x7C96BF,
0x0C9553,
0x0D4A48,
/*1941-1950*/
0x6DA53B, 0x0B554F, 0x056A45, 0x4AADB9, 0x025D4D, 0x092D42, 0x2C95B6, 0x0A954A, 0x7B4ABD, 0x06CA51,
0x6DA53B,
0x0B554F,
0x056A45,
0x4AADB9,
0x025D4D,
0x092D42,
0x2C95B6,
0x0A954A,
0x7B4ABD,
0x06CA51,
/*1951-1960*/
0x0B5546, 0x555ABB, 0x04DA4E, 0x0A5B43, 0x352BB8, 0x052B4C, 0x8A953F, 0x0E9552, 0x06AA48, 0x6AD53C,
0x0B5546,
0x555ABB,
0x04DA4E,
0x0A5B43,
0x352BB8,
0x052B4C,
0x8A953F,
0x0E9552,
0x06AA48,
0x6AD53C,
/*1961-1970*/
0x0AB54F, 0x04B645, 0x4A5739, 0x0A574D, 0x052642, 0x3E9335, 0x0D9549, 0x75AABE, 0x056A51, 0x096D46,
0x0AB54F,
0x04B645,
0x4A5739,
0x0A574D,
0x052642,
0x3E9335,
0x0D9549,
0x75AABE,
0x056A51,
0x096D46,
/*1971-1980*/
0x54AEBB, 0x04AD4F, 0x0A4D43, 0x4D26B7, 0x0D254B, 0x8D52BF, 0x0B5452, 0x0B6A47, 0x696D3C, 0x095B50,
0x54AEBB,
0x04AD4F,
0x0A4D43,
0x4D26B7,
0x0D254B,
0x8D52BF,
0x0B5452,
0x0B6A47,
0x696D3C,
0x095B50,
/*1981-1990*/
0x049B45, 0x4A4BB9, 0x0A4B4D, 0xAB25C2, 0x06A554, 0x06D449, 0x6ADA3D, 0x0AB651, 0x095746, 0x5497BB,
0x049B45,
0x4A4BB9,
0x0A4B4D,
0xAB25C2,
0x06A554,
0x06D449,
0x6ADA3D,
0x0AB651,
0x095746,
0x5497BB,
/*1991-2000*/
0x04974F, 0x064B44, 0x36A537, 0x0EA54A, 0x86B2BF, 0x05AC53, 0x0AB647, 0x5936BC, 0x092E50, 0x0C9645,
0x04974F,
0x064B44,
0x36A537,
0x0EA54A,
0x86B2BF,
0x05AC53,
0x0AB647,
0x5936BC,
0x092E50,
0x0C9645,
/*2001-2010*/
0x4D4AB8, 0x0D4A4C, 0x0DA541, 0x25AAB6, 0x056A49, 0x7AADBD, 0x025D52, 0x092D47, 0x5C95BA, 0x0A954E,
0x4D4AB8,
0x0D4A4C,
0x0DA541,
0x25AAB6,
0x056A49,
0x7AADBD,
0x025D52,
0x092D47,
0x5C95BA,
0x0A954E,
/*2011-2020*/
0x0B4A43, 0x4B5537, 0x0AD54A, 0x955ABF, 0x04BA53, 0x0A5B48, 0x652BBC, 0x052B50, 0x0A9345, 0x474AB9,
0x0B4A43,
0x4B5537,
0x0AD54A,
0x955ABF,
0x04BA53,
0x0A5B48,
0x652BBC,
0x052B50,
0x0A9345,
0x474AB9,
/*2021-2030*/
0x06AA4C, 0x0AD541, 0x24DAB6, 0x04B64A, 0x6a573D, 0x0A4E51, 0x0D2646, 0x5E933A, 0x0D534D, 0x05AA43,
0x06AA4C,
0x0AD541,
0x24DAB6,
0x04B64A,
0x6a573D,
0x0A4E51,
0x0D2646,
0x5E933A,
0x0D534D,
0x05AA43,
/*2031-2040*/
0x36B537, 0x096D4B, 0xB4AEBF, 0x04AD53, 0x0A4D48, 0x6D25BC, 0x0D254F, 0x0D5244, 0x5DAA38, 0x0B5A4C,
0x36B537,
0x096D4B,
0xB4AEBF,
0x04AD53,
0x0A4D48,
0x6D25BC,
0x0D254F,
0x0D5244,
0x5DAA38,
0x0B5A4C,
/*2041-2050*/
0x056D41, 0x24ADB6, 0x049B4A, 0x7A4BBE, 0x0A4B51, 0x0AA546, 0x5B52BA, 0x06D24E, 0x0ADA42, 0x355B37,
0x056D41,
0x24ADB6,
0x049B4A,
0x7A4BBE,
0x0A4B51,
0x0AA546,
0x5B52BA,
0x06D24E,
0x0ADA42,
0x355B37,
/*2051-2060*/
0x09374B, 0x8497C1, 0x049753, 0x064B48, 0x66A53C, 0x0EA54F, 0x06AA44, 0x4AB638, 0x0AAE4C, 0x092E42,
0x09374B,
0x8497C1,
0x049753,
0x064B48,
0x66A53C,
0x0EA54F,
0x06AA44,
0x4AB638,
0x0AAE4C,
0x092E42,
/*2061-2070*/
0x3C9735, 0x0C9649, 0x7D4ABD, 0x0D4A51, 0x0DA545, 0x55AABA, 0x056A4E, 0x0A6D43, 0x452EB7, 0x052D4B,
0x3C9735,
0x0C9649,
0x7D4ABD,
0x0D4A51,
0x0DA545,
0x55AABA,
0x056A4E,
0x0A6D43,
0x452EB7,
0x052D4B,
/*2071-2080*/
0x8A95BF, 0x0A9553, 0x0B4A47, 0x6B553B, 0x0AD54F, 0x055A45, 0x4A5D38, 0x0A5B4C, 0x052B42, 0x3A93B6,
0x8A95BF,
0x0A9553,
0x0B4A47,
0x6B553B,
0x0AD54F,
0x055A45,
0x4A5D38,
0x0A5B4C,
0x052B42,
0x3A93B6,
/*2081-2090*/
0x069349, 0x7729BD, 0x06AA51, 0x0AD546, 0x54DABA, 0x04B64E, 0x0A5743, 0x452738, 0x0D264A, 0x8E933E,
0x069349,
0x7729BD,
0x06AA51,
0x0AD546,
0x54DABA,
0x04B64E,
0x0A5743,
0x452738,
0x0D264A,
0x8E933E,
/*2091-2099*/
0x0D5252, 0x0DAA47, 0x66B53B, 0x056D4F, 0x04AE45, 0x4A4EB9, 0x0A4D4C, 0x0D1541, 0x2D92B5
0x0D5252,
0x0DAA47,
0x66B53B,
0x056D4F,
0x04AE45,
0x4A4EB9,
0x0A4D4C,
0x0D1541,
0x2D92B5
];
/**
... ... @@ -79,17 +278,21 @@ class LunarCalendarUtil {
* @param isLeapMonth 该月是否是闰月(该参数可以根据本类中leapMonth()方法,先判断一下要查询的年份是否有闰月,并且闰的几月)
* @return 返回农历日期对应的公历日期,year0, month1, day2.
*/
static List<int?> lunarToSolar(int year, int month, int monthDay, bool isLeapMonth) {
static List<int?> lunarToSolar(
int year, int month, int monthDay, bool isLeapMonth) {
int dayOffset;
int leapMonth;
int i;
if (year < MIN_YEAR || year > MAX_YEAR || month < 1 || month > 12
|| monthDay < 1 || monthDay > 30) {
throw new Exception(
"Illegal lunar date, must be like that:\n\t" +
"year : 1900~2099\n\t" +
"month : 1~12\n\t" +
"day : 1~30");
if (year < MIN_YEAR ||
year > MAX_YEAR ||
month < 1 ||
month > 12 ||
monthDay < 1 ||
monthDay > 30) {
throw new Exception("Illegal lunar date, must be like that:\n\t" +
"year : 1900~2099\n\t" +
"month : 1~12\n\t" +
"day : 1~30");
}
dayOffset = (LUNAR_INFO[year - MIN_YEAR] & 0x001F) - 1;
if (((LUNAR_INFO[year - MIN_YEAR] & 0x0060) >> 5) == 2) {
... ... @@ -122,7 +325,7 @@ class LunarCalendarUtil {
dayOffset -= 365;
}
}
List<int?> solarInfo = [null,null,null];
List<int?> solarInfo = [null, null, null];
for (i = 1; i < 13; i++) {
int iPos = DAYS_BEFORE_MONTH[i];
if (year % 4 == 0 && i > 2) {
... ... @@ -157,6 +360,122 @@ class LunarCalendarUtil {
return solarInfo;
}
static String formatLunarDate(int lunarMonth, int lunarDay) {
// 创建一个数组来存储农历月份的名字
var monthNames = [
'正月',
'二月',
'三月',
'四月',
'五月',
'六月',
'七月',
'八月',
'九月',
'十月',
'冬月',
'腊月'
];
// 创建一个数组来存储农历日期的名字
var dayNames = [
'初一',
'初二',
'初三',
'初四',
'初五',
'初六',
'初七',
'初八',
'初九',
'初十',
'十一',
'十二',
'十三',
'十四',
'十五',
'十六',
'十七',
'十八',
'十九',
'二十',
'廿一',
'廿二',
'廿三',
'廿四',
'廿五',
'廿六',
'廿七',
'廿八',
'廿九',
'三十'
];
return '${monthNames[lunarMonth - 1]}${dayNames[lunarDay - 1]}';
}
static int getMonth(String month) {
// 创建一个数组来存储农历月份的名字
if (month.contains('润')) {
month = month.replaceAll('润', '');
}
var monthNames = [
'正月',
'二月',
'三月',
'四月',
'五月',
'六月',
'七月',
'八月',
'九月',
'十月',
'冬月',
'腊月'
];
return monthNames.indexOf(month) + 1;
}
static int getDay(String day) {
// 创建一个数组来存储农历日期的名字
// 创建一个数组来存储农历日期的名字
var dayNames = [
'初一',
'初二',
'初三',
'初四',
'初五',
'初六',
'初七',
'初八',
'初九',
'初十',
'十一',
'十二',
'十三',
'十四',
'十五',
'十六',
'十七',
'十八',
'十九',
'二十',
'廿一',
'廿二',
'廿三',
'廿四',
'廿五',
'廿六',
'廿七',
'廿八',
'廿九',
'三十'
];
return dayNames.indexOf(day) + 1;
}
/**
* 传回农历year年month月的总天数
*
... ...
... ... @@ -1031,6 +1031,54 @@ class Utils {
return lunarCalendarUtilsShow(day);
}
//农历节日 *表示放假日
static String? lunarCalendarUnHolidays(DateTime day) {
// LunarCalendar lunarCalendar = LunarCalendar(day);
//阴历月-日
// String keyLunar =
// addZeroNumber(lunarCalendar.month) + addZeroNumber(lunarCalendar.day!);
//阳历月-日
// String keySolar =
// Utils.addZeroNumber(day.month) + Utils.addZeroNumber(day.day);
// Map<String, String> holiday1 = {
// "0101": "春节",
// "0102": "大年初二",
// "0103": "大年初三",
// "0104": "大年初四",
// "0105": "大年初五",
// "0106": "大年初六",
// "0107": "大年初七",
// "0115": "元宵节",
// "0505": "端午节",
// "0707": "七夕情人节",
// "0815": "中秋节",
// "0909": "重阳节",
// "1208": "腊八节",
// "1223": "过小年",
// "0100": "除夕"
// };
// Map<String, String> holiday2 = {
// "0101": '元旦',
// "0214": "情人节",
// "0308": "妇女节",
// "0501": "劳动节",
// "0504": "青年节",
// "0601": "国际儿童节",
// "0801": "八一建军节",
// "0910": "教师节",
// "1001": "国庆节",
// "1224": "平安夜",
// "1225": "圣诞节",
// };
// if (holiday1.containsKey(keyLunar)) {
// return holiday1[keyLunar];
// }
// if (holiday2.containsKey(keySolar)) {
// return holiday2[keySolar];
// }
return lunarCalendarUtils(day);
}
//农历节日 *表示放假日
static String? lunarCalendarHolidays(DateTime day) {
LunarCalendar lunarCalendar = LunarCalendar(day);
... ...
... ... @@ -1223,7 +1223,7 @@ packages:
source: hosted
version: "2.0.3"
lunar:
dependency: transitive
dependency: "direct main"
description:
name: lunar
sha256: "4ebb40c1647c5903fc67ff0be09a4ce90da79b482f0c78a8c727086a67375c37"
... ...
... ... @@ -290,6 +290,8 @@ dependencies:
# flutter_swiper: ^1.1.6
flutter_swiper_null_safety: ^1.0.2
pop_scope_page_transitions: ^0.0.1
lunar: ^1.2.21
... ...