Commit fee481587e992c3bbdbe0ffabdb91cd9aecb7e1c

Authored by weixin_45529955
1 parent 4da6781a

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

@@ -355,14 +355,10 @@ @@ -355,14 +355,10 @@
355 inputFileListPaths = ( 355 inputFileListPaths = (
356 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 356 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
357 ); 357 );
358 - inputPaths = (  
359 - );  
360 name = "[CP] Embed Pods Frameworks"; 358 name = "[CP] Embed Pods Frameworks";
361 outputFileListPaths = ( 359 outputFileListPaths = (
362 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 360 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
363 ); 361 );
364 - outputPaths = (  
365 - );  
366 runOnlyForDeploymentPostprocessing = 0; 362 runOnlyForDeploymentPostprocessing = 0;
367 shellPath = /bin/sh; 363 shellPath = /bin/sh;
368 shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 364 shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
@@ -376,14 +372,10 @@ @@ -376,14 +372,10 @@
376 inputFileListPaths = ( 372 inputFileListPaths = (
377 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", 373 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
378 ); 374 );
379 - inputPaths = (  
380 - );  
381 name = "[CP] Copy Pods Resources"; 375 name = "[CP] Copy Pods Resources";
382 outputFileListPaths = ( 376 outputFileListPaths = (
383 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", 377 "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
384 ); 378 );
385 - outputPaths = (  
386 - );  
387 runOnlyForDeploymentPostprocessing = 0; 379 runOnlyForDeploymentPostprocessing = 0;
388 shellPath = /bin/sh; 380 shellPath = /bin/sh;
389 shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; 381 shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
1 -  
2 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
3 import 'package:flutter_screenutil/flutter_screenutil.dart'; 2 import 'package:flutter_screenutil/flutter_screenutil.dart';
4 import 'package:one_key/constant/state.dart'; 3 import 'package:one_key/constant/state.dart';
@@ -7,7 +6,10 @@ import 'package:one_key/provider/customer_provider.dart'; @@ -7,7 +6,10 @@ import 'package:one_key/provider/customer_provider.dart';
7 import 'package:one_key/res/colors.dart'; 6 import 'package:one_key/res/colors.dart';
8 import 'package:one_key/utils/dialog_util.dart'; 7 import 'package:one_key/utils/dialog_util.dart';
9 import 'package:one_key/utils/event_bus.dart'; 8 import 'package:one_key/utils/event_bus.dart';
  9 +import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
  10 +import 'package:one_key/utils/screen_util.dart';
10 import 'package:one_key/utils/utils.dart'; 11 import 'package:one_key/utils/utils.dart';
  12 +import 'package:one_key/widgets/MyDivider.dart';
11 import 'package:one_key/widgets/h_empty_view.dart'; 13 import 'package:one_key/widgets/h_empty_view.dart';
12 import 'package:one_key/widgets/page_exception.dart'; 14 import 'package:one_key/widgets/page_exception.dart';
13 import 'package:one_key/widgets/round_button.dart'; 15 import 'package:one_key/widgets/round_button.dart';
@@ -70,7 +72,6 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> { @@ -70,7 +72,6 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
70 bus.emit('refresh_guest_info'); 72 bus.emit('refresh_guest_info');
71 bus.emit('refresh_guest_list_my'); 73 bus.emit('refresh_guest_list_my');
72 // Navigator.pop(context); 74 // Navigator.pop(context);
73 -  
74 } 75 }
75 } 76 }
76 77
@@ -86,10 +87,68 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> { @@ -86,10 +87,68 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
86 bus.emit('refresh_guest_info'); 87 bus.emit('refresh_guest_info');
87 bus.emit('refresh_guest_list'); 88 bus.emit('refresh_guest_list');
88 // Navigator.pop(context); 89 // Navigator.pop(context);
89 -  
90 } 90 }
91 } 91 }
92 92
  93 + _item(
  94 + String title,
  95 + String subTitle, {
  96 + GestureTapCallback? onTapDel,
  97 + GestureTapCallback? onTapEdit,
  98 + }) {
  99 + return Container(
  100 + padding: EdgeInsets.all(w(10)),
  101 + // margin: EdgeInsets.symmetric(horizontal: w(20)),
  102 + child: Column(
  103 + crossAxisAlignment: CrossAxisAlignment.start,
  104 + children: [
  105 + Row(
  106 + children: [
  107 + Text(
  108 + title,
  109 + style: TextStyle(
  110 + fontSize: font(16), color: MyColours.color_438E93),
  111 + ),
  112 + Spacer(),
  113 + InkWell(
  114 + onTap: onTapDel,
  115 + child: Padding(
  116 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  117 + child: Image.asset(
  118 + Utils.getImgPath('f_delete_red'),
  119 + width: w(20),
  120 + ),
  121 + )),
  122 + InkWell(
  123 + onTap: onTapEdit,
  124 + child: Padding(
  125 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  126 + child: Image.asset(
  127 + Utils.getImgPath('c_edit'),
  128 + width: w(20),
  129 + ),
  130 + )),
  131 + ],
  132 + ),
  133 + VEmptyView(40),
  134 + Text(
  135 + subTitle,
  136 + style: TextStyle(fontSize: font(16), color: MyColours.color_000000),
  137 + ),
  138 + VEmptyView(20),
  139 + Padding(
  140 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  141 + child: MyDivider(
  142 + double.infinity,
  143 + w(1),
  144 + color: MyColours.color_F7F7F7,
  145 + ),
  146 + )
  147 + ],
  148 + ),
  149 + );
  150 + }
  151 +
93 @override 152 @override
94 Widget build(BuildContext context) { 153 Widget build(BuildContext context) {
95 customerProvider = Provider.of<CustomerProvider>(context, listen: true); 154 customerProvider = Provider.of<CustomerProvider>(context, listen: true);
@@ -129,167 +188,297 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> { @@ -129,167 +188,297 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
129 itemBuilder: (BuildContext context, int index) { 188 itemBuilder: (BuildContext context, int index) {
130 Cday cday = model.cday![index]; 189 Cday cday = model.cday![index];
131 String show = ''; 190 String show = '';
132 - if (cday.desc != null && cday.desc != '') {  
133 - //新数据  
134 - // 组展示文本  
135 191
136 - if (cday.month != null) {  
137 - //最新的数据 192 + //新数据
  193 + // 组展示文本
138 194
139 - if (cday.year == null) {  
140 - show = cday.desc! +  
141 - ':' +  
142 - cday.month! +  
143 - '-' +  
144 - cday.day! +  
145 - (cday.type == '1' ? '(公历)' : '(农历)'); 195 + if (cday.month != null) {
  196 + //最新的数据
  197 +
  198 + if (cday.year == null) {
  199 + if (cday.type == '1') {
  200 + show = '(公历)' + cday.month! + '月' + cday.day! + '日';
146 } else { 201 } else {
147 - show = cday.desc! +  
148 - ':' + 202 + show = '(农历)' +
  203 + LunarCalendarUtil.formatLunarDate(
  204 + int.parse(cday.month!),
  205 + int.parse(cday.day!));
  206 + }
  207 + } else {
  208 + if (cday.type == '1') {
  209 + show = '(公历)' +
149 cday.year! + 210 cday.year! +
150 - '-' + 211 + '年' +
151 cday.month! + 212 cday.month! +
152 - '-' + 213 + '月' +
153 cday.day! + 214 cday.day! +
154 - (cday.type == '1' ? '(公历)' : '(农历)'); 215 + '日';
  216 + } else {
  217 + show = '(农历)' +
  218 + cday.year! +
  219 + '年' +
  220 + LunarCalendarUtil.formatLunarDate(
  221 + int.parse(cday.month!),
  222 + int.parse(cday.day!));
155 } 223 }
  224 + }
  225 + } else {
  226 + show =
  227 + (cday.type == '1' ? '(公历)' : '(农历)') + cday.dtime!;
  228 + List data = cday.dtime!.split('-');
  229 + if (cday.type == '1') {
  230 + show = '(公历)' +
  231 + data[0] +
  232 + '年' +
  233 + data[1] +
  234 + '月' +
  235 + data[2] +
  236 + '日';
156 } else { 237 } else {
157 - show = cday.desc! +  
158 - ':' +  
159 - cday.dtime! +  
160 - (cday.type == '1' ? '(公历)' : '(农历)'); 238 + show = '(农历)' +
  239 + data[0] +
  240 + '年' +
  241 + LunarCalendarUtil.formatLunarDate(
  242 + int.parse(data[1]), int.parse(data[2]));
161 } 243 }
162 } 244 }
163 - return InkWell(  
164 - onTap: () {  
165 - String? str = cday.content;  
166 - String yearStr = '选填';  
167 - String? monthStr = '';  
168 - String? dayStr = '';  
169 - bool gongli = true;  
170 - String? content = '';  
171 - // str += '${name}:';  
172 - // if (yearStr != '' &&  
173 - // yearStr != null &&  
174 - // yearStr != '选填') {  
175 - // str += '${yearStr}年';  
176 - // }  
177 - // str += '${monthStr}月';  
178 - // str += '${dayStr}日';  
179 - // str += '(${gongli ? '公历' : '农历'})';  
180 245
181 - if (cday.desc != null && cday.desc != '') {  
182 - content = cday.desc;  
183 - if (cday.month != null) {  
184 - //最新的数据 246 + return _item(cday.desc ?? '',
  247 + cday.content == null ? show : cday.content!,
  248 + onTapDel: () {
  249 + //弹框确认是否删除
  250 + DialogUtil.cupertinoAlertDialog(context,
  251 + title: "",
  252 + content: "是否删除该纪念日",
  253 + rTitle: "删除", rCallback: () {
  254 + if (Navigator.canPop(context)) {
  255 + Navigator.pop(context);
  256 + }
  257 + _delGuestInfocDay(model.cday![index].id);
  258 + });
  259 + }, onTapEdit: () {
  260 + String? str = cday.content;
  261 + String yearStr = '选填';
  262 + String? monthStr = '';
  263 + String? dayStr = '';
  264 + bool gongli = true;
  265 + String? content = '';
  266 + // str += '${name}:';
  267 + // if (yearStr != '' &&
  268 + // yearStr != null &&
  269 + // yearStr != '选填') {
  270 + // str += '${yearStr}年';
  271 + // }
  272 + // str += '${monthStr}月';
  273 + // str += '${dayStr}日';
  274 + // str += '(${gongli ? '公历' : '农历'})';
185 275
186 - yearStr = cday.year ?? '选填';  
187 - monthStr = cday.month;  
188 - dayStr = cday.day;  
189 - } else {  
190 - //新数据 276 + if (cday.desc != null && cday.desc != '') {
  277 + content = cday.desc;
  278 + if (cday.month != null) {
  279 + //最新的数据
191 280
192 - List<String> ymd = cday.dtime!.split('-');  
193 - if (ymd.length == 3) {  
194 - //含有年  
195 - yearStr = ymd[0];  
196 - monthStr = ymd[1];  
197 - dayStr = ymd[2];  
198 - } else if (ymd.length == 2) {  
199 - //没有年  
200 - monthStr = ymd[0];  
201 - dayStr = ymd[1];  
202 - } 281 + yearStr = cday.year ?? '选填';
  282 + monthStr = cday.month;
  283 + dayStr = cday.day;
  284 + } else {
  285 + //新数据
203 286
204 - if (monthStr.startsWith('0')) {  
205 - monthStr =  
206 - monthStr.substring(1, monthStr.length);  
207 - }  
208 - if (dayStr.startsWith('0')) {  
209 - dayStr = dayStr.substring(1, dayStr.length);  
210 - } 287 + List<String> ymd = cday.dtime!.split('-');
  288 + if (ymd.length == 3) {
  289 + //含有年
  290 + yearStr = ymd[0];
  291 + monthStr = ymd[1];
  292 + dayStr = ymd[2];
  293 + } else if (ymd.length == 2) {
  294 + //没有年
  295 + monthStr = ymd[0];
  296 + dayStr = ymd[1];
  297 + }
211 298
212 - print(monthStr);  
213 - print(dayStr);  
214 - } 299 + if (monthStr.startsWith('0')) {
  300 + monthStr = monthStr.substring(1, monthStr.length);
  301 + }
  302 + if (dayStr.startsWith('0')) {
  303 + dayStr = dayStr.substring(1, dayStr.length);
  304 + }
  305 +
  306 + print(monthStr);
  307 + print(dayStr);
  308 + }
215 309
216 - gongli = cday.type == '1' ? true : false; 310 + gongli = cday.type == '1' ? true : false;
  311 + } else {
  312 + content = str!.substring(0, str.indexOf(':'));
  313 + String tempStr =
  314 + str.substring(str.indexOf(':'), str.length);
  315 + if (tempStr.contains('年')) {
  316 + yearStr = tempStr.substring(
  317 + tempStr.indexOf(':') + 1, tempStr.indexOf('年'));
  318 + }
  319 + if (tempStr.contains('月')) {
  320 + if (tempStr.contains('年')) {
  321 + monthStr = tempStr.substring(
  322 + tempStr.indexOf('年') + 1,
  323 + tempStr.indexOf('月'));
217 } else { 324 } else {
218 - content = str!.substring(0, str.indexOf(':'));  
219 - String tempStr =  
220 - str.substring(str.indexOf(':'), str.length);  
221 - if (tempStr.contains('年')) {  
222 - yearStr = tempStr.substring(  
223 - tempStr.indexOf(':') + 1,  
224 - tempStr.indexOf('年'));  
225 - }  
226 - if (tempStr.contains('月')) {  
227 - if (tempStr.contains('年')) {  
228 - monthStr = tempStr.substring(  
229 - tempStr.indexOf('年') + 1,  
230 - tempStr.indexOf('月'));  
231 - } else {  
232 - monthStr = tempStr.substring(  
233 - tempStr.indexOf(':') + 1,  
234 - tempStr.indexOf('月'));  
235 - }  
236 - }  
237 - if (tempStr.contains('日')) {  
238 - dayStr = tempStr.substring(  
239 - tempStr.indexOf('月') + 1,  
240 - tempStr.indexOf('日'));  
241 - }  
242 - if (tempStr.contains('农历')) {  
243 - gongli = false;  
244 - } 325 + monthStr = tempStr.substring(
  326 + tempStr.indexOf(':') + 1,
  327 + tempStr.indexOf('月'));
245 } 328 }
  329 + }
  330 + if (tempStr.contains('日')) {
  331 + dayStr = tempStr.substring(
  332 + tempStr.indexOf('月') + 1, tempStr.indexOf('日'));
  333 + }
  334 + if (tempStr.contains('农历')) {
  335 + gongli = false;
  336 + }
  337 + }
  338 +
  339 + DialogUtil.festivalAlertDialog(context, content!, 520,
  340 + rCallback: (content) {
  341 + print(content);
  342 + _setGuestInfocDay(model.cday![index].id,
  343 + content as Map<dynamic, dynamic>);
  344 + // _addCookbookClass(name, showLoading: true);
  345 + },
  346 + yearStr: yearStr,
  347 + monthStr: monthStr,
  348 + dayStr: dayStr,
  349 + gongli: gongli);
  350 + });
  351 +
  352 + // return InkWell(
  353 + // onTap: () {
  354 + // String? str = cday.content;
  355 + // String yearStr = '选填';
  356 + // String? monthStr = '';
  357 + // String? dayStr = '';
  358 + // bool gongli = true;
  359 + // String? content = '';
  360 + // // str += '${name}:';
  361 + // // if (yearStr != '' &&
  362 + // // yearStr != null &&
  363 + // // yearStr != '选填') {
  364 + // // str += '${yearStr}年';
  365 + // // }
  366 + // // str += '${monthStr}月';
  367 + // // str += '${dayStr}日';
  368 + // // str += '(${gongli ? '公历' : '农历'})';
  369 +
  370 + // if (cday.desc != null && cday.desc != '') {
  371 + // content = cday.desc;
  372 + // if (cday.month != null) {
  373 + // //最新的数据
  374 +
  375 + // yearStr = cday.year ?? '选填';
  376 + // monthStr = cday.month;
  377 + // dayStr = cday.day;
  378 + // } else {
  379 + // //新数据
  380 +
  381 + // List<String> ymd = cday.dtime!.split('-');
  382 + // if (ymd.length == 3) {
  383 + // //含有年
  384 + // yearStr = ymd[0];
  385 + // monthStr = ymd[1];
  386 + // dayStr = ymd[2];
  387 + // } else if (ymd.length == 2) {
  388 + // //没有年
  389 + // monthStr = ymd[0];
  390 + // dayStr = ymd[1];
  391 + // }
  392 +
  393 + // if (monthStr.startsWith('0')) {
  394 + // monthStr =
  395 + // monthStr.substring(1, monthStr.length);
  396 + // }
  397 + // if (dayStr.startsWith('0')) {
  398 + // dayStr = dayStr.substring(1, dayStr.length);
  399 + // }
  400 +
  401 + // print(monthStr);
  402 + // print(dayStr);
  403 + // }
  404 +
  405 + // gongli = cday.type == '1' ? true : false;
  406 + // } else {
  407 + // content = str!.substring(0, str.indexOf(':'));
  408 + // String tempStr =
  409 + // str.substring(str.indexOf(':'), str.length);
  410 + // if (tempStr.contains('年')) {
  411 + // yearStr = tempStr.substring(
  412 + // tempStr.indexOf(':') + 1,
  413 + // tempStr.indexOf('年'));
  414 + // }
  415 + // if (tempStr.contains('月')) {
  416 + // if (tempStr.contains('年')) {
  417 + // monthStr = tempStr.substring(
  418 + // tempStr.indexOf('年') + 1,
  419 + // tempStr.indexOf('月'));
  420 + // } else {
  421 + // monthStr = tempStr.substring(
  422 + // tempStr.indexOf(':') + 1,
  423 + // tempStr.indexOf('月'));
  424 + // }
  425 + // }
  426 + // if (tempStr.contains('日')) {
  427 + // dayStr = tempStr.substring(
  428 + // tempStr.indexOf('月') + 1,
  429 + // tempStr.indexOf('日'));
  430 + // }
  431 + // if (tempStr.contains('农历')) {
  432 + // gongli = false;
  433 + // }
  434 + // }
246 435
247 - DialogUtil.festivalAlertDialog(  
248 - context, content!, 520, rCallback: (content) {  
249 - print(content);  
250 - _setGuestInfocDay(model.cday![index].id, content as Map<dynamic, dynamic>);  
251 - // _addCookbookClass(name, showLoading: true);  
252 - }, delCallback: () {  
253 - //弹框确认是否删除  
254 - DialogUtil.cupertinoAlertDialog(context,  
255 - title: "",  
256 - content: "是否确定删除该纪念日",  
257 - rTitle: "确定删除", rCallback: () {  
258 - if (Navigator.canPop(context)) {  
259 - Navigator.pop(context);  
260 - }  
261 - _delGuestInfocDay(model.cday![index].id);  
262 - });  
263 - },  
264 - yearStr: yearStr,  
265 - monthStr: monthStr,  
266 - dayStr: dayStr,  
267 - gongli: gongli);  
268 - },  
269 - child: Padding(  
270 - padding: EdgeInsets.symmetric(  
271 - horizontal: ScreenUtil().setWidth(20),  
272 - vertical: ScreenUtil().setWidth(20)),  
273 - child: Row(  
274 - mainAxisAlignment: MainAxisAlignment.spaceBetween,  
275 - children: [  
276 - Expanded(  
277 - child: Text(  
278 - cday.content == null ? show : cday.content!,  
279 - overflow: TextOverflow.ellipsis,  
280 - style: TextStyle(  
281 - fontSize: ScreenUtil().setSp(26),  
282 - color: MyColours.color_333333),  
283 - )),  
284 - HEmptyView(10),  
285 - Image.asset(  
286 - Utils.getImgPath('c_edit'),  
287 - width: ScreenUtil().setWidth(40),  
288 - // height: ScreenUtil().setWidth(10),  
289 - )  
290 - ],  
291 - ),  
292 - )); 436 + // DialogUtil.festivalAlertDialog(
  437 + // context, content!, 520, rCallback: (content) {
  438 + // print(content);
  439 + // _setGuestInfocDay(model.cday![index].id, content as Map<dynamic, dynamic>);
  440 + // // _addCookbookClass(name, showLoading: true);
  441 + // }, delCallback: () {
  442 + // //弹框确认是否删除
  443 + // DialogUtil.cupertinoAlertDialog(context,
  444 + // title: "",
  445 + // content: "是否确定删除该纪念日",
  446 + // rTitle: "确定删除", rCallback: () {
  447 + // if (Navigator.canPop(context)) {
  448 + // Navigator.pop(context);
  449 + // }
  450 + // _delGuestInfocDay(model.cday![index].id);
  451 + // });
  452 + // },
  453 + // yearStr: yearStr,
  454 + // monthStr: monthStr,
  455 + // dayStr: dayStr,
  456 + // gongli: gongli);
  457 + // },
  458 + // child: Padding(
  459 + // padding: EdgeInsets.symmetric(
  460 + // horizontal: ScreenUtil().setWidth(20),
  461 + // vertical: ScreenUtil().setWidth(20)),
  462 + // child: Row(
  463 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  464 + // children: [
  465 + // Expanded(
  466 + // child: Text(
  467 + // cday.content == null ? show : cday.content!,
  468 + // overflow: TextOverflow.ellipsis,
  469 + // style: TextStyle(
  470 + // fontSize: ScreenUtil().setSp(26),
  471 + // color: MyColours.color_333333),
  472 + // )),
  473 + // HEmptyView(10),
  474 + // Image.asset(
  475 + // Utils.getImgPath('c_edit'),
  476 + // width: ScreenUtil().setWidth(40),
  477 + // // height: ScreenUtil().setWidth(10),
  478 + // )
  479 + // ],
  480 + // ),
  481 + // ));
293 }, 482 },
294 ); 483 );
295 } 484 }
@@ -12,6 +12,7 @@ import 'package:one_key/res/colors.dart'; @@ -12,6 +12,7 @@ import 'package:one_key/res/colors.dart';
12 import 'package:one_key/route/navigator_util.dart'; 12 import 'package:one_key/route/navigator_util.dart';
13 import 'package:one_key/utils/dialog_util.dart'; 13 import 'package:one_key/utils/dialog_util.dart';
14 import 'package:one_key/utils/event_bus.dart'; 14 import 'package:one_key/utils/event_bus.dart';
  15 +import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
15 import 'package:one_key/utils/utils.dart'; 16 import 'package:one_key/utils/utils.dart';
16 import 'package:one_key/widgets/h_empty_view.dart'; 17 import 'package:one_key/widgets/h_empty_view.dart';
17 import 'package:one_key/widgets/page_exception.dart'; 18 import 'package:one_key/widgets/page_exception.dart';
@@ -1007,9 +1008,8 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> { @@ -1007,9 +1008,8 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
1007 fontSize: 26, 1008 fontSize: 26,
1008 isBold: false, 1009 isBold: false,
1009 onPressed: () { 1010 onPressed: () {
1010 -  
1011 - NavigatorUtil.goSetBirthdayPage(context,widget.userHistoryEntity!.gid);  
1012 - 1011 + NavigatorUtil.goSetBirthdayPage(
  1012 + context, widget.userHistoryEntity!.gid);
1013 }, 1013 },
1014 ), 1014 ),
1015 ], 1015 ],
@@ -1061,45 +1061,84 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> { @@ -1061,45 +1061,84 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
1061 Cday cday = customerProvider 1061 Cday cday = customerProvider
1062 .guestInfoSunModel!.guest!.cDay![index]!; 1062 .guestInfoSunModel!.guest!.cDay![index]!;
1063 String? show = cday.content; 1063 String? show = cday.content;
1064 - if (cday.desc != null && cday.desc != '') {  
1065 - if (cday.month != null) {  
1066 - //最新的数据  
1067 1064
1068 - if (cday.year == null) {  
1069 - show = cday.desc! +  
1070 - ':' + 1065 + if (cday.month != null) {
  1066 + //最新的数据
  1067 +
  1068 + if (cday.year == null) {
  1069 + if (cday.type == '1') {
  1070 + show = '(公历)' +
1071 cday.month! + 1071 cday.month! +
1072 - '-' + 1072 + '月' +
1073 cday.day! + 1073 cday.day! +
1074 - (cday.type == '1' ? '(公历)' : '(农历)'); 1074 + '日';
1075 } else { 1075 } else {
1076 - show = cday.desc! +  
1077 - ':' + 1076 + show = '(农历)' +
  1077 + LunarCalendarUtil.formatLunarDate(
  1078 + int.parse(cday.month!),
  1079 + int.parse(cday.day!));
  1080 + }
  1081 + } else {
  1082 + if (cday.type == '1') {
  1083 + show = '(公历)' +
1078 cday.year! + 1084 cday.year! +
1079 - '-' + 1085 + '年' +
1080 cday.month! + 1086 cday.month! +
1081 - '-' + 1087 + '月' +
1082 cday.day! + 1088 cday.day! +
1083 - (cday.type == '1' ? '(公历)' : '(农历)'); 1089 + '日';
  1090 + } else {
  1091 + show = '(农历)' +
  1092 + cday.year! +
  1093 + '年' +
  1094 + LunarCalendarUtil.formatLunarDate(
  1095 + int.parse(cday.month!),
  1096 + int.parse(cday.day!));
1084 } 1097 }
  1098 + }
  1099 + } else {
  1100 + show = (cday.type == '1' ? '(公历)' : '(农历)') +
  1101 + cday.dtime!;
  1102 + List data = cday.dtime!.split('-');
  1103 + if (cday.type == '1') {
  1104 + show = '(公历)' +
  1105 + data[0] +
  1106 + '年' +
  1107 + data[1] +
  1108 + '月' +
  1109 + data[2] +
  1110 + '日';
1085 } else { 1111 } else {
1086 - show = cday.desc! +  
1087 - ':' +  
1088 - cday.dtime! +  
1089 - (cday.type == '1' ? '(公历)' : '(农历)'); 1112 + show = '(农历)' +
  1113 + data[0] +
  1114 + '年' +
  1115 + LunarCalendarUtil.formatLunarDate(
  1116 + int.parse(data[1]),
  1117 + int.parse(data[2]));
1090 } 1118 }
1091 } 1119 }
1092 - return Center(  
1093 - child: Padding(  
1094 - padding: EdgeInsets.symmetric(  
1095 - vertical: ScreenUtil().setWidth(10)),  
1096 - child: Text(  
1097 - show!,  
1098 - style: TextStyle(  
1099 - fontSize: ScreenUtil().setSp(26),  
1100 - color: MyColours.color_333333),  
1101 - ),  
1102 - )); 1120 +
  1121 + return Padding(
  1122 + padding:
  1123 + EdgeInsets.symmetric(vertical: w(10)),
  1124 + child: Row(
  1125 + mainAxisAlignment:
  1126 + MainAxisAlignment.spaceBetween,
  1127 + children: [
  1128 + Text(
  1129 + cday.desc ?? '',
  1130 + style: TextStyle(
  1131 + fontSize: font(16),
  1132 + color: MyColours.color_438E93),
  1133 + ),
  1134 + Text(
  1135 + show,
  1136 + style: TextStyle(
  1137 + fontSize: font(14),
  1138 + color: MyColours.color_000000),
  1139 + ),
  1140 + ],
  1141 + ));
1103 }, 1142 },
1104 ) 1143 )
1105 ])), 1144 ])),
1 -  
2 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
  2 +import 'package:flutter_lunar_datetime_picker/date_init.dart';
3 import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
4 import 'package:one_key/constant/state.dart'; 4 import 'package:one_key/constant/state.dart';
5 import 'package:one_key/models/guest_info_model.dart'; 5 import 'package:one_key/models/guest_info_model.dart';
@@ -7,7 +7,10 @@ import 'package:one_key/provider/customer_provider.dart'; @@ -7,7 +7,10 @@ import 'package:one_key/provider/customer_provider.dart';
7 import 'package:one_key/res/colors.dart'; 7 import 'package:one_key/res/colors.dart';
8 import 'package:one_key/utils/dialog_util.dart'; 8 import 'package:one_key/utils/dialog_util.dart';
9 import 'package:one_key/utils/event_bus.dart'; 9 import 'package:one_key/utils/event_bus.dart';
  10 +import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
  11 +import 'package:one_key/utils/screen_util.dart';
10 import 'package:one_key/utils/utils.dart'; 12 import 'package:one_key/utils/utils.dart';
  13 +import 'package:one_key/widgets/MyDivider.dart';
11 import 'package:one_key/widgets/h_empty_view.dart'; 14 import 'package:one_key/widgets/h_empty_view.dart';
12 import 'package:one_key/widgets/page_exception.dart'; 15 import 'package:one_key/widgets/page_exception.dart';
13 import 'package:one_key/widgets/round_button.dart'; 16 import 'package:one_key/widgets/round_button.dart';
@@ -71,7 +74,6 @@ class _FestivalEditPageState extends State<FestivalEditPage> { @@ -71,7 +74,6 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
71 bus.emit('refresh_guest_info'); 74 bus.emit('refresh_guest_info');
72 bus.emit('refresh_guest_list'); 75 bus.emit('refresh_guest_list');
73 // Navigator.pop(context); 76 // Navigator.pop(context);
74 -  
75 } 77 }
76 } 78 }
77 79
@@ -87,10 +89,68 @@ class _FestivalEditPageState extends State<FestivalEditPage> { @@ -87,10 +89,68 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
87 bus.emit('refresh_guest_info'); 89 bus.emit('refresh_guest_info');
88 bus.emit('refresh_guest_list'); 90 bus.emit('refresh_guest_list');
89 // Navigator.pop(context); 91 // Navigator.pop(context);
90 -  
91 } 92 }
92 } 93 }
93 94
  95 + _item(
  96 + String title,
  97 + String subTitle, {
  98 + GestureTapCallback? onTapDel,
  99 + GestureTapCallback? onTapEdit,
  100 + }) {
  101 + return Container(
  102 + padding: EdgeInsets.all(w(10)),
  103 + // margin: EdgeInsets.symmetric(horizontal: w(20)),
  104 + child: Column(
  105 + crossAxisAlignment: CrossAxisAlignment.start,
  106 + children: [
  107 + Row(
  108 + children: [
  109 + Text(
  110 + title,
  111 + style: TextStyle(
  112 + fontSize: font(16), color: MyColours.color_438E93),
  113 + ),
  114 + Spacer(),
  115 + InkWell(
  116 + onTap: onTapDel,
  117 + child: Padding(
  118 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  119 + child: Image.asset(
  120 + Utils.getImgPath('f_delete_red'),
  121 + width: w(20),
  122 + ),
  123 + )),
  124 + InkWell(
  125 + onTap: onTapEdit,
  126 + child: Padding(
  127 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  128 + child: Image.asset(
  129 + Utils.getImgPath('c_edit'),
  130 + width: w(20),
  131 + ),
  132 + )),
  133 + ],
  134 + ),
  135 + VEmptyView(40),
  136 + Text(
  137 + subTitle,
  138 + style: TextStyle(fontSize: font(16), color: MyColours.color_000000),
  139 + ),
  140 + VEmptyView(20),
  141 + Padding(
  142 + padding: EdgeInsets.symmetric(horizontal: w(10)),
  143 + child: MyDivider(
  144 + double.infinity,
  145 + w(1),
  146 + color: MyColours.color_F7F7F7,
  147 + ),
  148 + )
  149 + ],
  150 + ),
  151 + );
  152 + }
  153 +
94 @override 154 @override
95 Widget build(BuildContext context) { 155 Widget build(BuildContext context) {
96 customerProvider = Provider.of<CustomerProvider>(context, listen: true); 156 customerProvider = Provider.of<CustomerProvider>(context, listen: true);
@@ -130,167 +190,194 @@ class _FestivalEditPageState extends State<FestivalEditPage> { @@ -130,167 +190,194 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
130 itemBuilder: (BuildContext context, int index) { 190 itemBuilder: (BuildContext context, int index) {
131 Cday cday = model.cday![index]; 191 Cday cday = model.cday![index];
132 String show = ''; 192 String show = '';
133 - if (cday.desc != null && cday.desc != '') {  
134 - //新数据  
135 - // 组展示文本  
136 193
137 - if (cday.month != null) {  
138 - //最新的数据 194 + //新数据
  195 + // 组展示文本
139 196
140 - if (cday.year == null) {  
141 - show = cday.desc! +  
142 - ':' +  
143 - cday.month! +  
144 - '-' +  
145 - cday.day! +  
146 - (cday.type == '1' ? '(公历)' : '(农历)'); 197 + if (cday.month != null) {
  198 + //最新的数据
  199 +
  200 + if (cday.year == null) {
  201 + if (cday.type == '1') {
  202 + show = '(公历)' + cday.month! + '月' + cday.day! + '日';
147 } else { 203 } else {
148 - show = cday.desc! +  
149 - ':' + 204 + show = '(农历)' +
  205 + LunarCalendarUtil.formatLunarDate(
  206 + int.parse(cday.month!),
  207 + int.parse(cday.day!));
  208 + }
  209 + } else {
  210 + if (cday.type == '1') {
  211 + show = '(公历)' +
150 cday.year! + 212 cday.year! +
151 - '-' + 213 + '年' +
152 cday.month! + 214 cday.month! +
153 - '-' + 215 + '月' +
154 cday.day! + 216 cday.day! +
155 - (cday.type == '1' ? '(公历)' : '(农历)'); 217 + '日';
  218 + } else {
  219 + show = '(农历)' +
  220 + cday.year! +
  221 + '年' +
  222 + LunarCalendarUtil.formatLunarDate(
  223 + int.parse(cday.month!),
  224 + int.parse(cday.day!));
156 } 225 }
  226 + }
  227 + } else {
  228 + show =
  229 + (cday.type == '1' ? '(公历)' : '(农历)') + cday.dtime!;
  230 + List data = cday.dtime!.split('-');
  231 + if (cday.type == '1') {
  232 + show = '(公历)' +
  233 + data[0] +
  234 + '年' +
  235 + data[1] +
  236 + '月' +
  237 + data[2] +
  238 + '日';
157 } else { 239 } else {
158 - show = cday.desc! +  
159 - ':' +  
160 - cday.dtime! +  
161 - (cday.type == '1' ? '(公历)' : '(农历)'); 240 + show = '(农历)' +
  241 + data[0] +
  242 + '年' +
  243 + LunarCalendarUtil.formatLunarDate(
  244 + int.parse(data[1]), int.parse(data[2]));
162 } 245 }
163 } 246 }
164 - return InkWell(  
165 - onTap: () {  
166 - String? str = cday.content;  
167 - String yearStr = '选填';  
168 - String? monthStr = '';  
169 - String? dayStr = '';  
170 - bool gongli = true;  
171 - String? content = '';  
172 - // str += '${name}:';  
173 - // if (yearStr != '' &&  
174 - // yearStr != null &&  
175 - // yearStr != '选填') {  
176 - // str += '${yearStr}年';  
177 - // }  
178 - // str += '${monthStr}月';  
179 - // str += '${dayStr}日';  
180 - // str += '(${gongli ? '公历' : '农历'})';  
181 247
182 - if (cday.desc != null && cday.desc != '') {  
183 - content = cday.desc;  
184 - if (cday.month != null) {  
185 - //最新的数据 248 + return _item(cday.desc ?? '',
  249 + cday.content == null ? show : cday.content!,
  250 + onTapDel: () {
  251 + //弹框确认是否删除
  252 + DialogUtil.cupertinoAlertDialog(context,
  253 + title: "",
  254 + content: "是否删除该纪念日",
  255 + rTitle: "删除", rCallback: () {
  256 + if (Navigator.canPop(context)) {
  257 + Navigator.pop(context);
  258 + }
  259 + _delGuestInfocDay(model.cday![index].id);
  260 + });
  261 + }, onTapEdit: () {
  262 + String? str = cday.content;
  263 + String yearStr = '选填';
  264 + String? monthStr = '';
  265 + String? dayStr = '';
  266 + bool gongli = true;
  267 + String? content = '';
  268 + // str += '${name}:';
  269 + // if (yearStr != '' &&
  270 + // yearStr != null &&
  271 + // yearStr != '选填') {
  272 + // str += '${yearStr}年';
  273 + // }
  274 + // str += '${monthStr}月';
  275 + // str += '${dayStr}日';
  276 + // str += '(${gongli ? '公历' : '农历'})';
186 277
187 - yearStr = cday.year ?? '选填';  
188 - monthStr = cday.month;  
189 - dayStr = cday.day;  
190 - } else {  
191 - //新数据 278 + if (cday.desc != null && cday.desc != '') {
  279 + content = cday.desc;
  280 + if (cday.month != null) {
  281 + //最新的数据
192 282
193 - List<String> ymd = cday.dtime!.split('-');  
194 - if (ymd.length == 3) {  
195 - //含有年  
196 - yearStr = ymd[0];  
197 - monthStr = ymd[1];  
198 - dayStr = ymd[2];  
199 - } else if (ymd.length == 2) {  
200 - //没有年  
201 - monthStr = ymd[0];  
202 - dayStr = ymd[1];  
203 - } 283 + yearStr = cday.year ?? '选填';
  284 + monthStr = cday.month;
  285 + dayStr = cday.day;
  286 + } else {
  287 + //新数据
204 288
205 - if (monthStr.startsWith('0')) {  
206 - monthStr =  
207 - monthStr.substring(1, monthStr.length);  
208 - }  
209 - if (dayStr.startsWith('0')) {  
210 - dayStr = dayStr.substring(1, dayStr.length);  
211 - } 289 + List<String> ymd = cday.dtime!.split('-');
  290 + if (ymd.length == 3) {
  291 + //含有年
  292 + yearStr = ymd[0];
  293 + monthStr = ymd[1];
  294 + dayStr = ymd[2];
  295 + } else if (ymd.length == 2) {
  296 + //没有年
  297 + monthStr = ymd[0];
  298 + dayStr = ymd[1];
  299 + }
212 300
213 - print(monthStr);  
214 - print(dayStr);  
215 - } 301 + if (monthStr.startsWith('0')) {
  302 + monthStr = monthStr.substring(1, monthStr.length);
  303 + }
  304 + if (dayStr.startsWith('0')) {
  305 + dayStr = dayStr.substring(1, dayStr.length);
  306 + }
  307 +
  308 + print(monthStr);
  309 + print(dayStr);
  310 + }
216 311
217 - gongli = cday.type == '1' ? true : false; 312 + gongli = cday.type == '1' ? true : false;
  313 + } else {
  314 + content = str!.substring(0, str.indexOf(':'));
  315 + String tempStr =
  316 + str.substring(str.indexOf(':'), str.length);
  317 + if (tempStr.contains('年')) {
  318 + yearStr = tempStr.substring(
  319 + tempStr.indexOf(':') + 1, tempStr.indexOf('年'));
  320 + }
  321 + if (tempStr.contains('月')) {
  322 + if (tempStr.contains('年')) {
  323 + monthStr = tempStr.substring(
  324 + tempStr.indexOf('年') + 1,
  325 + tempStr.indexOf('月'));
218 } else { 326 } else {
219 - content = str!.substring(0, str.indexOf(':'));  
220 - String tempStr =  
221 - str.substring(str.indexOf(':'), str.length);  
222 - if (tempStr.contains('年')) {  
223 - yearStr = tempStr.substring(  
224 - tempStr.indexOf(':') + 1,  
225 - tempStr.indexOf('年'));  
226 - }  
227 - if (tempStr.contains('月')) {  
228 - if (tempStr.contains('年')) {  
229 - monthStr = tempStr.substring(  
230 - tempStr.indexOf('年') + 1,  
231 - tempStr.indexOf('月'));  
232 - } else {  
233 - monthStr = tempStr.substring(  
234 - tempStr.indexOf(':') + 1,  
235 - tempStr.indexOf('月'));  
236 - }  
237 - }  
238 - if (tempStr.contains('日')) {  
239 - dayStr = tempStr.substring(  
240 - tempStr.indexOf('月') + 1,  
241 - tempStr.indexOf('日'));  
242 - }  
243 - if (tempStr.contains('农历')) {  
244 - gongli = false;  
245 - } 327 + monthStr = tempStr.substring(
  328 + tempStr.indexOf(':') + 1,
  329 + tempStr.indexOf('月'));
246 } 330 }
  331 + }
  332 + if (tempStr.contains('日')) {
  333 + dayStr = tempStr.substring(
  334 + tempStr.indexOf('月') + 1, tempStr.indexOf('日'));
  335 + }
  336 + if (tempStr.contains('农历')) {
  337 + gongli = false;
  338 + }
  339 + }
  340 +
  341 + DialogUtil.festivalAlertDialog(context, content!, 520,
  342 + rCallback: (content) {
  343 + print(content);
  344 + _setGuestInfocDay(model.cday![index].id,
  345 + content as Map<dynamic, dynamic>);
  346 + // _addCookbookClass(name, showLoading: true);
  347 + },
  348 + yearStr: yearStr,
  349 + monthStr: monthStr,
  350 + dayStr: dayStr,
  351 + gongli: gongli);
  352 + });
  353 + // return InkWell(
  354 + // onTap: () {
247 355
248 - DialogUtil.festivalAlertDialog(  
249 - context, content!, 520, rCallback: (content) {  
250 - print(content);  
251 - _setGuestInfocDay(model.cday![index].id, content as Map<dynamic, dynamic>);  
252 - // _addCookbookClass(name, showLoading: true);  
253 - }, delCallback: () {  
254 - //弹框确认是否删除  
255 - DialogUtil.cupertinoAlertDialog(context,  
256 - title: "",  
257 - content: "是否确定删除该纪念日",  
258 - rTitle: "确定删除", rCallback: () {  
259 - if (Navigator.canPop(context)) {  
260 - Navigator.pop(context);  
261 - }  
262 - _delGuestInfocDay(model.cday![index].id);  
263 - });  
264 - },  
265 - yearStr: yearStr,  
266 - monthStr: monthStr,  
267 - dayStr: dayStr,  
268 - gongli: gongli);  
269 - },  
270 - child: Padding(  
271 - padding: EdgeInsets.symmetric(  
272 - horizontal: ScreenUtil().setWidth(20),  
273 - vertical: ScreenUtil().setWidth(20)),  
274 - child: Row(  
275 - mainAxisAlignment: MainAxisAlignment.spaceBetween,  
276 - children: [  
277 - Expanded(  
278 - child: Text(  
279 - cday.content == null ? show : cday.content!,  
280 - overflow: TextOverflow.ellipsis,  
281 - style: TextStyle(  
282 - fontSize: ScreenUtil().setSp(26),  
283 - color: MyColours.color_333333),  
284 - )),  
285 - HEmptyView(10),  
286 - Image.asset(  
287 - Utils.getImgPath('c_edit'),  
288 - width: ScreenUtil().setWidth(40),  
289 - // height: ScreenUtil().setWidth(10),  
290 - )  
291 - ],  
292 - ),  
293 - )); 356 + // },
  357 + // child: Padding(
  358 + // padding: EdgeInsets.symmetric(
  359 + // horizontal: ScreenUtil().setWidth(20),
  360 + // vertical: ScreenUtil().setWidth(20)),
  361 + // child: Row(
  362 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  363 + // children: [
  364 + // Expanded(
  365 + // child: Text(
  366 + // cday.content == null ? show : cday.content!,
  367 + // overflow: TextOverflow.ellipsis,
  368 + // style: TextStyle(
  369 + // fontSize: ScreenUtil().setSp(26),
  370 + // color: MyColours.color_333333),
  371 + // )),
  372 + // HEmptyView(10),
  373 + // Image.asset(
  374 + // Utils.getImgPath('c_edit'),
  375 + // width: ScreenUtil().setWidth(40),
  376 + // // height: ScreenUtil().setWidth(10),
  377 + // )
  378 + // ],
  379 + // ),
  380 + // ));
294 }, 381 },
295 ); 382 );
296 } 383 }
@@ -8,6 +8,8 @@ import 'package:common_utils/common_utils.dart'; @@ -8,6 +8,8 @@ import 'package:common_utils/common_utils.dart';
8 import 'package:flutter/cupertino.dart'; 8 import 'package:flutter/cupertino.dart';
9 import 'package:flutter/material.dart'; 9 import 'package:flutter/material.dart';
10 import 'package:flutter/services.dart'; 10 import 'package:flutter/services.dart';
  11 +import 'package:flutter_lunar_datetime_picker/date_init.dart';
  12 +import 'package:flutter_lunar_datetime_picker/flutter_lunar_datetime_picker.dart';
11 import 'package:flutter_picker_plus/flutter_picker_plus.dart'; 13 import 'package:flutter_picker_plus/flutter_picker_plus.dart';
12 import 'package:flutter_screenutil/flutter_screenutil.dart'; 14 import 'package:flutter_screenutil/flutter_screenutil.dart';
13 15
@@ -23,6 +25,7 @@ import 'package:one_key/res/colors.dart'; @@ -23,6 +25,7 @@ import 'package:one_key/res/colors.dart';
23 import 'package:one_key/utils/NumLengthInputFormatter.dart'; 25 import 'package:one_key/utils/NumLengthInputFormatter.dart';
24 import 'package:one_key/utils/misc.dart'; 26 import 'package:one_key/utils/misc.dart';
25 import 'package:one_key/route/navigator_util.dart'; 27 import 'package:one_key/route/navigator_util.dart';
  28 +import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
26 import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_day.dart'; 29 import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_day.dart';
27 import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_month.dart'; 30 import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_month.dart';
28 import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_year.dart'; 31 import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_year.dart';
@@ -55,6 +58,12 @@ import '../models/titlte_type_model.dart'; @@ -55,6 +58,12 @@ import '../models/titlte_type_model.dart';
55 import '../pages/my/marketing_center/theme_model.dart'; 58 import '../pages/my/marketing_center/theme_model.dart';
56 import '../provider/collect_store_provider.dart'; 59 import '../provider/collect_store_provider.dart';
57 60
  61 +import 'package:flutter_lunar_datetime_picker/flutter_lunar_datetime_picker.dart';
  62 +import 'package:flutter_lunar_datetime_picker/datetime_picker_theme.dart'
  63 + as picker_theme;
  64 +
  65 +import 'package:lunar/lunar.dart';
  66 +
58 typedef CustomCallBack = void Function(Object? object); 67 typedef CustomCallBack = void Function(Object? object);
59 typedef CustomCallBackMap = void Function(Map<String, String?> object); 68 typedef CustomCallBackMap = void Function(Map<String, String?> object);
60 69
@@ -11815,8 +11824,7 @@ class DialogUtil { @@ -11815,8 +11824,7 @@ class DialogUtil {
11815 static Future festivalAlertDialog( 11824 static Future festivalAlertDialog(
11816 BuildContext context, String name, double height, 11825 BuildContext context, String name, double height,
11817 {CustomCallBack? rCallback, 11826 {CustomCallBack? rCallback,
11818 - GestureTapCallback? delCallback,  
11819 - double fontSize = 28, 11827 + double fontSize = 32,
11820 String? yearStr = '选填', 11828 String? yearStr = '选填',
11821 String? monthStr = '', 11829 String? monthStr = '',
11822 String? dayStr = '', 11830 String? dayStr = '',
@@ -11827,6 +11835,42 @@ class DialogUtil { @@ -11827,6 +11835,42 @@ class DialogUtil {
11827 builder: (BuildContext context) { 11835 builder: (BuildContext context) {
11828 TextEditingController controller = TextEditingController(); 11836 TextEditingController controller = TextEditingController();
11829 controller.text = name; 11837 controller.text = name;
  11838 +
  11839 + yearStr = yearStr == '选填' ? DateTime.now().year.toString() : yearStr;
  11840 +
  11841 + monthStr = monthStr == '' ? DateTime.now().month.toString() : monthStr;
  11842 +
  11843 + dayStr = dayStr == '' ? DateTime.now().day.toString() : dayStr;
  11844 + String show = (yearStr ?? '') +
  11845 + '年' +
  11846 + (monthStr ?? '') +
  11847 + '月' +
  11848 + (dayStr ?? '') +
  11849 + '日';
  11850 +
  11851 + DateTime now = DateTime(
  11852 + int.parse(yearStr!),
  11853 + int.parse(monthStr!),
  11854 + int.parse(dayStr!),
  11855 + );
  11856 +
  11857 + if (!gongli) {
  11858 + //格式化农历日期
  11859 +
  11860 + show = (yearStr ?? '') +
  11861 + '年' +
  11862 + LunarCalendarUtil.formatLunarDate(
  11863 + int.parse(monthStr!), int.parse(dayStr!));
  11864 + print(show);
  11865 +
  11866 + int mLeapMonth = LunarCalendarUtil.leapMonth(int.parse(yearStr!));
  11867 + List<int?> time = LunarCalendarUtil.lunarToSolar(
  11868 + int.parse(yearStr!),
  11869 + int.parse(monthStr!),
  11870 + int.parse(dayStr!),
  11871 + mLeapMonth == int.parse(monthStr!));
  11872 + now = DateTime(time[0]!, time[1]!, time[2]!);
  11873 + }
11830 return StatefulBuilder(builder: (context, stateSetter) { 11874 return StatefulBuilder(builder: (context, stateSetter) {
11831 return Scaffold( 11875 return Scaffold(
11832 backgroundColor: Colors.transparent, 11876 backgroundColor: Colors.transparent,
@@ -11862,25 +11906,25 @@ class DialogUtil { @@ -11862,25 +11906,25 @@ class DialogUtil {
11862 fontSize: ScreenUtil().setSp(fontSize), 11906 fontSize: ScreenUtil().setSp(fontSize),
11863 color: MyColours.color_353535)), 11907 color: MyColours.color_353535)),
11864 ), 11908 ),
11865 - monthStr == ''  
11866 - ? SizedBox()  
11867 - : Positioned(  
11868 - right: 0,  
11869 - top: 0,  
11870 - child: InkWell(  
11871 - onTap: delCallback,  
11872 - child: Padding(  
11873 - padding: EdgeInsets.only(  
11874 - top: ScreenUtil().setWidth(36)),  
11875 - child: Text('删除',  
11876 - style: TextStyle(  
11877 - decoration: TextDecoration  
11878 - .underline,  
11879 - fontSize:  
11880 - ScreenUtil().setSp(26),  
11881 - color: MyColours  
11882 - .color_199095)),  
11883 - ))) 11909 + // monthStr == ''
  11910 + // ? SizedBox()
  11911 + // : Positioned(
  11912 + // right: 0,
  11913 + // top: 0,
  11914 + // child: InkWell(
  11915 + // onTap: delCallback,
  11916 + // child: Padding(
  11917 + // padding: EdgeInsets.only(
  11918 + // top: ScreenUtil().setWidth(36)),
  11919 + // child: Text('删除',
  11920 + // style: TextStyle(
  11921 + // decoration: TextDecoration
  11922 + // .underline,
  11923 + // fontSize:
  11924 + // ScreenUtil().setSp(26),
  11925 + // color: MyColours
  11926 + // .color_199095)),
  11927 + // )))
11884 ]), 11928 ]),
11885 11929
11886 Container( 11930 Container(
@@ -11908,15 +11952,15 @@ class DialogUtil { @@ -11908,15 +11952,15 @@ class DialogUtil {
11908 TextAlignVertical.bottom, 11952 TextAlignVertical.bottom,
11909 textAlign: TextAlign.center, 11953 textAlign: TextAlign.center,
11910 style: TextStyle( 11954 style: TextStyle(
11911 - fontSize: ScreenUtil().setSp(26),  
11912 - ), 11955 + fontSize: font(16),
  11956 + color: MyColours.color_438E93),
11913 decoration: InputDecoration( 11957 decoration: InputDecoration(
11914 border: OutlineInputBorder( 11958 border: OutlineInputBorder(
11915 borderSide: BorderSide.none), 11959 borderSide: BorderSide.none),
11916 hintText: '例:本人生日', 11960 hintText: '例:本人生日',
11917 hintStyle: TextStyle( 11961 hintStyle: TextStyle(
11918 color: MyColours.color_999999, 11962 color: MyColours.color_999999,
11919 - fontSize: ScreenUtil().setSp(26), 11963 + fontSize: font(16),
11920 ), 11964 ),
11921 enabledBorder: 11965 enabledBorder:
11922 new UnderlineInputBorder( 11966 new UnderlineInputBorder(
@@ -12053,195 +12097,297 @@ class DialogUtil { @@ -12053,195 +12097,297 @@ class DialogUtil {
12053 : MyColours.color_333333))), 12097 : MyColours.color_333333))),
12054 ), 12098 ),
12055 HEmptyView(30), 12099 HEmptyView(30),
  12100 + Spacer(),
  12101 +
12056 InkWell( 12102 InkWell(
12057 - onTap: () {  
12058 - FocusScope.of(context).requestFocus(  
12059 - FocusNode()); //点击空白处隐藏键盘  
12060 - incrementCounterYear(  
12061 - context,  
12062 - gongli,  
12063 - yearStr == '选填'  
12064 - ? DateTime.now().year.toString()  
12065 - : yearStr, (year) {  
12066 - print(year);  
12067 - stateSetter(() {  
12068 - yearStr = year as String?;  
12069 - });  
12070 - });  
12071 - },  
12072 - child: Container(  
12073 - padding: EdgeInsets.only(  
12074 - bottom: ScreenUtil().setWidth(4)),  
12075 - decoration: BoxDecoration(  
12076 - border: Border(  
12077 - bottom: BorderSide(  
12078 - color: MyColours.color_E0E0E0,  
12079 - width: ScreenUtil().setWidth(2)),  
12080 - )),  
12081 - child: Row(  
12082 - crossAxisAlignment:  
12083 - CrossAxisAlignment.end,  
12084 - children: [  
12085 - Padding(  
12086 - padding: EdgeInsets.zero,  
12087 - child: Text(yearStr!,  
12088 - style: TextStyle(  
12089 - fontSize:  
12090 - ScreenUtil().setSp(26),  
12091 - color: MyColours  
12092 - .color_666666)),  
12093 - ),  
12094 - HEmptyView(6),  
12095 - Image.asset(  
12096 - Utils.getImgPath(false  
12097 - ? 'c_arrow_up'  
12098 - : 'c_arrow_down'),  
12099 - width: ScreenUtil().setWidth(28),  
12100 - // height: ScreenUtil().setWidth(10),  
12101 - ),  
12102 - ],  
12103 - ),  
12104 - )),  
12105 - Text('年',  
12106 - style: TextStyle(  
12107 - fontSize: ScreenUtil().setSp(28),  
12108 - color: MyColours.color_333333)),  
12109 - HEmptyView(10),  
12110 - InkWell(  
12111 - onTap: () {  
12112 - FocusScope.of(context).requestFocus(  
12113 - FocusNode()); //点击空白处隐藏键盘  
12114 - incrementCounterMonth(  
12115 - context,  
12116 - gongli,  
12117 - yearStr == '选填'  
12118 - ? DateTime.now().year.toString()  
12119 - : yearStr,  
12120 - monthStr == ''  
12121 - ? DateTime.now().month.toString()  
12122 - : monthStr, (month) {  
12123 - print(month);  
12124 - stateSetter(() {  
12125 - monthStr = month as String?;  
12126 - });  
12127 - if (dayStr != '') {  
12128 - List dayList = updateDay(  
12129 - gongli,  
12130 - yearStr == '选填'  
12131 - ? DateTime.now()  
12132 - .year  
12133 - .toString()  
12134 - : yearStr,  
12135 - monthStr == ''  
12136 - ? DateTime.now()  
12137 - .month  
12138 - .toString()  
12139 - : monthStr);  
12140 - if (!dayList.contains(dayStr)) {  
12141 - stateSetter(() {  
12142 - dayStr = '';  
12143 - });  
12144 - } 12103 + onTap: () {
  12104 + DatePicker.showDatePicker(
  12105 + context,
  12106 + lunarPicker: !gongli,
  12107 + showTime: false,
  12108 + theme: picker_theme.DatePickerTheme(
  12109 + backgroundColor:
  12110 + MyColours.color_ffffff,
  12111 + itemStyle: TextStyle(
  12112 + color: MyColours.color_438E93,
  12113 + fontSize: font(16)),
  12114 + containerHeight: w(220),
  12115 + titleHeight: w(58),
  12116 + itemHeight: w(44),
  12117 + cancelStyle: TextStyle(
  12118 + color: MyColours.color_999999,
  12119 + fontSize: font(16)),
  12120 + doneStyle: TextStyle(
  12121 + color: MyColours.color_438E93,
  12122 + fontSize: font(16))),
  12123 + dateInitTime: DateInitTime(
  12124 + currentTime: now,
  12125 + maxTime: DateTime(2050, 12, 12),
  12126 + minTime: DateTime(1900, 1, 1)),
  12127 + onConfirm: (time, lunar) {
  12128 + debugPrint(time.toString());
  12129 +
  12130 + now = time;
  12131 +
  12132 + if (gongli) {
  12133 + yearStr = time.year.toString();
  12134 +
  12135 + monthStr = time.month.toString();
  12136 + dayStr = time.day.toString();
  12137 + show = (yearStr ?? '') +
  12138 + '年' +
  12139 + (monthStr ?? '') +
  12140 + '月' +
  12141 + (dayStr ?? '') +
  12142 + '日';
  12143 + } else {
  12144 + // 阳历转阴历
  12145 +
  12146 + // 获取当前阴历
  12147 + Lunar currentLunarTime =
  12148 + Solar.fromDate(time).getLunar();
  12149 + yearStr = currentLunarTime
  12150 + .getYear()
  12151 + .toString();
  12152 + monthStr = currentLunarTime
  12153 + .getMonth()
  12154 + .toString();
  12155 + dayStr = currentLunarTime
  12156 + .getDay()
  12157 + .toString();
  12158 + //转换成农历
  12159 +
  12160 + show = (yearStr ?? '') +
  12161 + '年' +
  12162 + LunarCalendarUtil.formatLunarDate(
  12163 + int.parse(monthStr!),
  12164 + int.parse(dayStr!));
  12165 +
  12166 + print(show);
  12167 + // int mLeapMonth =
  12168 + // LunarCalendarUtil.leapMonth(
  12169 + // int.parse(yearStr!));
  12170 + // List<int?> time =
  12171 + // LunarCalendarUtil.lunarToSolar(
  12172 + // int.parse(yearStr!),
  12173 + // int.parse(monthStr!),
  12174 + // int.parse(dayStr!),
  12175 + // mLeapMonth ==
  12176 + // int.parse(monthStr!));
12145 } 12177 }
12146 - });  
12147 - },  
12148 - child: Container(  
12149 - padding: EdgeInsets.only(  
12150 - bottom: ScreenUtil().setWidth(4)),  
12151 - decoration: BoxDecoration(  
12152 - border: Border(  
12153 - bottom: BorderSide(  
12154 - color: MyColours.color_E0E0E0,  
12155 - width: ScreenUtil().setWidth(2)),  
12156 - )),  
12157 - child: Row(  
12158 - crossAxisAlignment:  
12159 - CrossAxisAlignment.end,  
12160 - children: [  
12161 - Padding(  
12162 - padding: EdgeInsets.zero,  
12163 - child: Text(monthStr!,  
12164 - style: TextStyle(  
12165 - fontSize:  
12166 - ScreenUtil().setSp(26),  
12167 - color: MyColours  
12168 - .color_666666)),  
12169 - ),  
12170 - HEmptyView(6),  
12171 - Image.asset(  
12172 - Utils.getImgPath(false  
12173 - ? 'c_arrow_up'  
12174 - : 'c_arrow_down'),  
12175 - width: ScreenUtil().setWidth(28),  
12176 - // height: ScreenUtil().setWidth(10),  
12177 - ),  
12178 - ],  
12179 - ),  
12180 - )),  
12181 - Text('月',  
12182 - style: TextStyle(  
12183 - fontSize: ScreenUtil().setSp(28),  
12184 - color: MyColours.color_333333)),  
12185 - HEmptyView(10),  
12186 - InkWell(  
12187 - onTap: () {  
12188 - FocusScope.of(context).requestFocus(  
12189 - FocusNode()); //点击空白处隐藏键盘  
12190 - incrementCounterDay(  
12191 - context,  
12192 - gongli,  
12193 - yearStr == '选填'  
12194 - ? DateTime.now().year.toString()  
12195 - : yearStr,  
12196 - monthStr == ''  
12197 - ? DateTime.now().month.toString()  
12198 - : monthStr,  
12199 - dayStr == ''  
12200 - ? DateTime.now().day.toString()  
12201 - : dayStr, (day) {  
12202 - print(dayStr);  
12203 - stateSetter(() {  
12204 - dayStr = day as String?;  
12205 - });  
12206 - });  
12207 - },  
12208 - child: Container(  
12209 - padding: EdgeInsets.only(  
12210 - bottom: ScreenUtil().setWidth(4)),  
12211 - decoration: BoxDecoration(  
12212 - border: Border(  
12213 - bottom: BorderSide(  
12214 - color: MyColours.color_E0E0E0,  
12215 - width: ScreenUtil().setWidth(2)),  
12216 - )),  
12217 - child: Row(  
12218 - crossAxisAlignment:  
12219 - CrossAxisAlignment.end,  
12220 - children: [  
12221 - Padding(  
12222 - padding: EdgeInsets.zero,  
12223 - child: Text(dayStr!,  
12224 - style: TextStyle(  
12225 - fontSize:  
12226 - ScreenUtil().setSp(26),  
12227 - color: MyColours  
12228 - .color_666666)),  
12229 - ),  
12230 - HEmptyView(6),  
12231 - Image.asset(  
12232 - Utils.getImgPath(false  
12233 - ? 'c_arrow_up'  
12234 - : 'c_arrow_down'),  
12235 - width: ScreenUtil().setWidth(28),  
12236 - // height: ScreenUtil().setWidth(10),  
12237 - ),  
12238 - ], 12178 +
  12179 + stateSetter(() {});
  12180 + },
  12181 + onChanged: (time, lunar) {
  12182 + debugPrint("change:${time.toString()}");
  12183 + },
  12184 + );
  12185 + },
  12186 + child: Row(
  12187 + children: [
  12188 + Text(
  12189 + show,
  12190 + style: TextStyle(
  12191 + color: MyColours.color_000000,
  12192 + fontSize: font(16)),
12239 ), 12193 ),
12240 - )),  
12241 - Text('日',  
12242 - style: TextStyle(  
12243 - fontSize: ScreenUtil().setSp(28),  
12244 - color: MyColours.color_333333)), 12194 + HEmptyView(8),
  12195 + Image.asset(
  12196 + Utils.getImgPath('calender_theme'),
  12197 + width: w(16),
  12198 + )
  12199 + ],
  12200 + ),
  12201 + ),
  12202 + // InkWell(
  12203 + // onTap: () {
  12204 + // FocusScope.of(context).requestFocus(
  12205 + // FocusNode()); //点击空白处隐藏键盘
  12206 + // incrementCounterYear(
  12207 + // context,
  12208 + // gongli,
  12209 + // yearStr == '选填'
  12210 + // ? DateTime.now().year.toString()
  12211 + // : yearStr, (year) {
  12212 + // print(year);
  12213 + // stateSetter(() {
  12214 + // yearStr = year as String?;
  12215 + // });
  12216 + // });
  12217 + // },
  12218 + // child: Container(
  12219 + // padding: EdgeInsets.only(
  12220 + // bottom: ScreenUtil().setWidth(4)),
  12221 + // decoration: BoxDecoration(
  12222 + // border: Border(
  12223 + // bottom: BorderSide(
  12224 + // color: MyColours.color_E0E0E0,
  12225 + // width: ScreenUtil().setWidth(2)),
  12226 + // )),
  12227 + // child: Row(
  12228 + // crossAxisAlignment:
  12229 + // CrossAxisAlignment.end,
  12230 + // children: [
  12231 + // Padding(
  12232 + // padding: EdgeInsets.zero,
  12233 + // child: Text(yearStr!,
  12234 + // style: TextStyle(
  12235 + // fontSize:
  12236 + // ScreenUtil().setSp(26),
  12237 + // color: MyColours
  12238 + // .color_666666)),
  12239 + // ),
  12240 + // HEmptyView(6),
  12241 + // Image.asset(
  12242 + // Utils.getImgPath(false
  12243 + // ? 'c_arrow_up'
  12244 + // : 'c_arrow_down'),
  12245 + // width: ScreenUtil().setWidth(28),
  12246 + // // height: ScreenUtil().setWidth(10),
  12247 + // ),
  12248 + // ],
  12249 + // ),
  12250 + // )),
  12251 + // Text('年',
  12252 + // style: TextStyle(
  12253 + // fontSize: ScreenUtil().setSp(28),
  12254 + // color: MyColours.color_333333)),
  12255 + // HEmptyView(10),
  12256 + // InkWell(
  12257 + // onTap: () {
  12258 + // FocusScope.of(context).requestFocus(
  12259 + // FocusNode()); //点击空白处隐藏键盘
  12260 + // incrementCounterMonth(
  12261 + // context,
  12262 + // gongli,
  12263 + // yearStr == '选填'
  12264 + // ? DateTime.now().year.toString()
  12265 + // : yearStr,
  12266 + // monthStr == ''
  12267 + // ? DateTime.now().month.toString()
  12268 + // : monthStr, (month) {
  12269 + // print(month);
  12270 + // stateSetter(() {
  12271 + // monthStr = month as String?;
  12272 + // });
  12273 + // if (dayStr != '') {
  12274 + // List dayList = updateDay(
  12275 + // gongli,
  12276 + // yearStr == '选填'
  12277 + // ? DateTime.now()
  12278 + // .year
  12279 + // .toString()
  12280 + // : yearStr,
  12281 + // monthStr == ''
  12282 + // ? DateTime.now()
  12283 + // .month
  12284 + // .toString()
  12285 + // : monthStr);
  12286 + // if (!dayList.contains(dayStr)) {
  12287 + // stateSetter(() {
  12288 + // dayStr = '';
  12289 + // });
  12290 + // }
  12291 + // }
  12292 + // });
  12293 + // },
  12294 + // child: Container(
  12295 + // padding: EdgeInsets.only(
  12296 + // bottom: ScreenUtil().setWidth(4)),
  12297 + // decoration: BoxDecoration(
  12298 + // border: Border(
  12299 + // bottom: BorderSide(
  12300 + // color: MyColours.color_E0E0E0,
  12301 + // width: ScreenUtil().setWidth(2)),
  12302 + // )),
  12303 + // child: Row(
  12304 + // crossAxisAlignment:
  12305 + // CrossAxisAlignment.end,
  12306 + // children: [
  12307 + // Padding(
  12308 + // padding: EdgeInsets.zero,
  12309 + // child: Text(monthStr!,
  12310 + // style: TextStyle(
  12311 + // fontSize:
  12312 + // ScreenUtil().setSp(26),
  12313 + // color: MyColours
  12314 + // .color_666666)),
  12315 + // ),
  12316 + // HEmptyView(6),
  12317 + // Image.asset(
  12318 + // Utils.getImgPath(false
  12319 + // ? 'c_arrow_up'
  12320 + // : 'c_arrow_down'),
  12321 + // width: ScreenUtil().setWidth(28),
  12322 + // // height: ScreenUtil().setWidth(10),
  12323 + // ),
  12324 + // ],
  12325 + // ),
  12326 + // )),
  12327 + // Text('月',
  12328 + // style: TextStyle(
  12329 + // fontSize: ScreenUtil().setSp(28),
  12330 + // color: MyColours.color_333333)),
  12331 + // HEmptyView(10),
  12332 + // InkWell(
  12333 + // onTap: () {
  12334 + // FocusScope.of(context).requestFocus(
  12335 + // FocusNode()); //点击空白处隐藏键盘
  12336 + // incrementCounterDay(
  12337 + // context,
  12338 + // gongli,
  12339 + // yearStr == '选填'
  12340 + // ? DateTime.now().year.toString()
  12341 + // : yearStr,
  12342 + // monthStr == ''
  12343 + // ? DateTime.now().month.toString()
  12344 + // : monthStr,
  12345 + // dayStr == ''
  12346 + // ? DateTime.now().day.toString()
  12347 + // : dayStr, (day) {
  12348 + // print(dayStr);
  12349 + // stateSetter(() {
  12350 + // dayStr = day as String?;
  12351 + // });
  12352 + // });
  12353 + // },
  12354 + // child: Container(
  12355 + // padding: EdgeInsets.only(
  12356 + // bottom: ScreenUtil().setWidth(4)),
  12357 + // decoration: BoxDecoration(
  12358 + // border: Border(
  12359 + // bottom: BorderSide(
  12360 + // color: MyColours.color_E0E0E0,
  12361 + // width: ScreenUtil().setWidth(2)),
  12362 + // )),
  12363 + // child: Row(
  12364 + // crossAxisAlignment:
  12365 + // CrossAxisAlignment.end,
  12366 + // children: [
  12367 + // Padding(
  12368 + // padding: EdgeInsets.zero,
  12369 + // child: Text(dayStr!,
  12370 + // style: TextStyle(
  12371 + // fontSize:
  12372 + // ScreenUtil().setSp(26),
  12373 + // color: MyColours
  12374 + // .color_666666)),
  12375 + // ),
  12376 + // HEmptyView(6),
  12377 + // Image.asset(
  12378 + // Utils.getImgPath(false
  12379 + // ? 'c_arrow_up'
  12380 + // : 'c_arrow_down'),
  12381 + // width: ScreenUtil().setWidth(28),
  12382 + // // height: ScreenUtil().setWidth(10),
  12383 + // ),
  12384 + // ],
  12385 + // ),
  12386 + // )),
  12387 + // Text('日',
  12388 + // style: TextStyle(
  12389 + // fontSize: ScreenUtil().setSp(28),
  12390 + // color: MyColours.color_333333)),
12245 ], 12391 ],
12246 ), 12392 ),
12247 VEmptyView(60), 12393 VEmptyView(60),
1 -  
2 /** 1 /**
3 * 农历的工具类 2 * 农历的工具类
4 */ 3 */
  4 +
  5 +
  6 +
5 class LunarCalendarUtil { 7 class LunarCalendarUtil {
6 /** 8 /**
7 * 支持转换的最小农历年份 9 * 支持转换的最小农历年份
@@ -12,10 +14,28 @@ class LunarCalendarUtil { @@ -12,10 +14,28 @@ class LunarCalendarUtil {
12 * 支持转换的最大农历年份 14 * 支持转换的最大农历年份
13 */ 15 */
14 static final int MAX_YEAR = 2099; 16 static final int MAX_YEAR = 2099;
  17 +
  18 +
  19 +
  20 +
15 /** 21 /**
16 * 公历每月前的天数 22 * 公历每月前的天数
17 */ 23 */
18 - static final List<int> DAYS_BEFORE_MONTH = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; 24 + static final List<int> DAYS_BEFORE_MONTH = [
  25 + 0,
  26 + 31,
  27 + 59,
  28 + 90,
  29 + 120,
  30 + 151,
  31 + 181,
  32 + 212,
  33 + 243,
  34 + 273,
  35 + 304,
  36 + 334,
  37 + 365
  38 + ];
19 39
20 /** 40 /**
21 * 用来表示1900年到2099年间农历年份的相关信息,共24位bit的16进制表示,其中: 41 * 用来表示1900年到2099年间农历年份的相关信息,共24位bit的16进制表示,其中:
@@ -30,45 +50,224 @@ class LunarCalendarUtil { @@ -30,45 +50,224 @@ class LunarCalendarUtil {
30 /*1900*/ 50 /*1900*/
31 0x84B6BF, 51 0x84B6BF,
32 /*1901-1910*/ 52 /*1901-1910*/
33 - 0x04AE53, 0x0A5748, 0x5526BD, 0x0D2650, 0x0D9544, 0x46AAB9, 0x056A4D, 0x09AD42, 0x24AEB6, 0x04AE4A, 53 + 0x04AE53,
  54 + 0x0A5748,
  55 + 0x5526BD,
  56 + 0x0D2650,
  57 + 0x0D9544,
  58 + 0x46AAB9,
  59 + 0x056A4D,
  60 + 0x09AD42,
  61 + 0x24AEB6,
  62 + 0x04AE4A,
34 /*1911-1920*/ 63 /*1911-1920*/
35 - 0x6A4DBE, 0x0A4D52, 0x0D2546, 0x5D52BA, 0x0B544E, 0x0D6A43, 0x296D37, 0x095B4B, 0x749BC1, 0x049754, 64 + 0x6A4DBE,
  65 + 0x0A4D52,
  66 + 0x0D2546,
  67 + 0x5D52BA,
  68 + 0x0B544E,
  69 + 0x0D6A43,
  70 + 0x296D37,
  71 + 0x095B4B,
  72 + 0x749BC1,
  73 + 0x049754,
36 /*1921-1930*/ 74 /*1921-1930*/
37 - 0x0A4B48, 0x5B25BC, 0x06A550, 0x06D445, 0x4ADAB8, 0x02B64D, 0x095742, 0x2497B7, 0x04974A, 0x664B3E, 75 + 0x0A4B48,
  76 + 0x5B25BC,
  77 + 0x06A550,
  78 + 0x06D445,
  79 + 0x4ADAB8,
  80 + 0x02B64D,
  81 + 0x095742,
  82 + 0x2497B7,
  83 + 0x04974A,
  84 + 0x664B3E,
38 /*1931-1940*/ 85 /*1931-1940*/
39 - 0x0D4A51, 0x0EA546, 0x56D4BA, 0x05AD4E, 0x02B644, 0x393738, 0x092E4B, 0x7C96BF, 0x0C9553, 0x0D4A48, 86 + 0x0D4A51,
  87 + 0x0EA546,
  88 + 0x56D4BA,
  89 + 0x05AD4E,
  90 + 0x02B644,
  91 + 0x393738,
  92 + 0x092E4B,
  93 + 0x7C96BF,
  94 + 0x0C9553,
  95 + 0x0D4A48,
40 /*1941-1950*/ 96 /*1941-1950*/
41 - 0x6DA53B, 0x0B554F, 0x056A45, 0x4AADB9, 0x025D4D, 0x092D42, 0x2C95B6, 0x0A954A, 0x7B4ABD, 0x06CA51, 97 + 0x6DA53B,
  98 + 0x0B554F,
  99 + 0x056A45,
  100 + 0x4AADB9,
  101 + 0x025D4D,
  102 + 0x092D42,
  103 + 0x2C95B6,
  104 + 0x0A954A,
  105 + 0x7B4ABD,
  106 + 0x06CA51,
42 /*1951-1960*/ 107 /*1951-1960*/
43 - 0x0B5546, 0x555ABB, 0x04DA4E, 0x0A5B43, 0x352BB8, 0x052B4C, 0x8A953F, 0x0E9552, 0x06AA48, 0x6AD53C, 108 + 0x0B5546,
  109 + 0x555ABB,
  110 + 0x04DA4E,
  111 + 0x0A5B43,
  112 + 0x352BB8,
  113 + 0x052B4C,
  114 + 0x8A953F,
  115 + 0x0E9552,
  116 + 0x06AA48,
  117 + 0x6AD53C,
44 /*1961-1970*/ 118 /*1961-1970*/
45 - 0x0AB54F, 0x04B645, 0x4A5739, 0x0A574D, 0x052642, 0x3E9335, 0x0D9549, 0x75AABE, 0x056A51, 0x096D46, 119 + 0x0AB54F,
  120 + 0x04B645,
  121 + 0x4A5739,
  122 + 0x0A574D,
  123 + 0x052642,
  124 + 0x3E9335,
  125 + 0x0D9549,
  126 + 0x75AABE,
  127 + 0x056A51,
  128 + 0x096D46,
46 /*1971-1980*/ 129 /*1971-1980*/
47 - 0x54AEBB, 0x04AD4F, 0x0A4D43, 0x4D26B7, 0x0D254B, 0x8D52BF, 0x0B5452, 0x0B6A47, 0x696D3C, 0x095B50, 130 + 0x54AEBB,
  131 + 0x04AD4F,
  132 + 0x0A4D43,
  133 + 0x4D26B7,
  134 + 0x0D254B,
  135 + 0x8D52BF,
  136 + 0x0B5452,
  137 + 0x0B6A47,
  138 + 0x696D3C,
  139 + 0x095B50,
48 /*1981-1990*/ 140 /*1981-1990*/
49 - 0x049B45, 0x4A4BB9, 0x0A4B4D, 0xAB25C2, 0x06A554, 0x06D449, 0x6ADA3D, 0x0AB651, 0x095746, 0x5497BB, 141 + 0x049B45,
  142 + 0x4A4BB9,
  143 + 0x0A4B4D,
  144 + 0xAB25C2,
  145 + 0x06A554,
  146 + 0x06D449,
  147 + 0x6ADA3D,
  148 + 0x0AB651,
  149 + 0x095746,
  150 + 0x5497BB,
50 /*1991-2000*/ 151 /*1991-2000*/
51 - 0x04974F, 0x064B44, 0x36A537, 0x0EA54A, 0x86B2BF, 0x05AC53, 0x0AB647, 0x5936BC, 0x092E50, 0x0C9645, 152 + 0x04974F,
  153 + 0x064B44,
  154 + 0x36A537,
  155 + 0x0EA54A,
  156 + 0x86B2BF,
  157 + 0x05AC53,
  158 + 0x0AB647,
  159 + 0x5936BC,
  160 + 0x092E50,
  161 + 0x0C9645,
52 /*2001-2010*/ 162 /*2001-2010*/
53 - 0x4D4AB8, 0x0D4A4C, 0x0DA541, 0x25AAB6, 0x056A49, 0x7AADBD, 0x025D52, 0x092D47, 0x5C95BA, 0x0A954E, 163 + 0x4D4AB8,
  164 + 0x0D4A4C,
  165 + 0x0DA541,
  166 + 0x25AAB6,
  167 + 0x056A49,
  168 + 0x7AADBD,
  169 + 0x025D52,
  170 + 0x092D47,
  171 + 0x5C95BA,
  172 + 0x0A954E,
54 /*2011-2020*/ 173 /*2011-2020*/
55 - 0x0B4A43, 0x4B5537, 0x0AD54A, 0x955ABF, 0x04BA53, 0x0A5B48, 0x652BBC, 0x052B50, 0x0A9345, 0x474AB9, 174 + 0x0B4A43,
  175 + 0x4B5537,
  176 + 0x0AD54A,
  177 + 0x955ABF,
  178 + 0x04BA53,
  179 + 0x0A5B48,
  180 + 0x652BBC,
  181 + 0x052B50,
  182 + 0x0A9345,
  183 + 0x474AB9,
56 /*2021-2030*/ 184 /*2021-2030*/
57 - 0x06AA4C, 0x0AD541, 0x24DAB6, 0x04B64A, 0x6a573D, 0x0A4E51, 0x0D2646, 0x5E933A, 0x0D534D, 0x05AA43, 185 + 0x06AA4C,
  186 + 0x0AD541,
  187 + 0x24DAB6,
  188 + 0x04B64A,
  189 + 0x6a573D,
  190 + 0x0A4E51,
  191 + 0x0D2646,
  192 + 0x5E933A,
  193 + 0x0D534D,
  194 + 0x05AA43,
58 /*2031-2040*/ 195 /*2031-2040*/
59 - 0x36B537, 0x096D4B, 0xB4AEBF, 0x04AD53, 0x0A4D48, 0x6D25BC, 0x0D254F, 0x0D5244, 0x5DAA38, 0x0B5A4C, 196 + 0x36B537,
  197 + 0x096D4B,
  198 + 0xB4AEBF,
  199 + 0x04AD53,
  200 + 0x0A4D48,
  201 + 0x6D25BC,
  202 + 0x0D254F,
  203 + 0x0D5244,
  204 + 0x5DAA38,
  205 + 0x0B5A4C,
60 /*2041-2050*/ 206 /*2041-2050*/
61 - 0x056D41, 0x24ADB6, 0x049B4A, 0x7A4BBE, 0x0A4B51, 0x0AA546, 0x5B52BA, 0x06D24E, 0x0ADA42, 0x355B37, 207 + 0x056D41,
  208 + 0x24ADB6,
  209 + 0x049B4A,
  210 + 0x7A4BBE,
  211 + 0x0A4B51,
  212 + 0x0AA546,
  213 + 0x5B52BA,
  214 + 0x06D24E,
  215 + 0x0ADA42,
  216 + 0x355B37,
62 /*2051-2060*/ 217 /*2051-2060*/
63 - 0x09374B, 0x8497C1, 0x049753, 0x064B48, 0x66A53C, 0x0EA54F, 0x06AA44, 0x4AB638, 0x0AAE4C, 0x092E42, 218 + 0x09374B,
  219 + 0x8497C1,
  220 + 0x049753,
  221 + 0x064B48,
  222 + 0x66A53C,
  223 + 0x0EA54F,
  224 + 0x06AA44,
  225 + 0x4AB638,
  226 + 0x0AAE4C,
  227 + 0x092E42,
64 /*2061-2070*/ 228 /*2061-2070*/
65 - 0x3C9735, 0x0C9649, 0x7D4ABD, 0x0D4A51, 0x0DA545, 0x55AABA, 0x056A4E, 0x0A6D43, 0x452EB7, 0x052D4B, 229 + 0x3C9735,
  230 + 0x0C9649,
  231 + 0x7D4ABD,
  232 + 0x0D4A51,
  233 + 0x0DA545,
  234 + 0x55AABA,
  235 + 0x056A4E,
  236 + 0x0A6D43,
  237 + 0x452EB7,
  238 + 0x052D4B,
66 /*2071-2080*/ 239 /*2071-2080*/
67 - 0x8A95BF, 0x0A9553, 0x0B4A47, 0x6B553B, 0x0AD54F, 0x055A45, 0x4A5D38, 0x0A5B4C, 0x052B42, 0x3A93B6, 240 + 0x8A95BF,
  241 + 0x0A9553,
  242 + 0x0B4A47,
  243 + 0x6B553B,
  244 + 0x0AD54F,
  245 + 0x055A45,
  246 + 0x4A5D38,
  247 + 0x0A5B4C,
  248 + 0x052B42,
  249 + 0x3A93B6,
68 /*2081-2090*/ 250 /*2081-2090*/
69 - 0x069349, 0x7729BD, 0x06AA51, 0x0AD546, 0x54DABA, 0x04B64E, 0x0A5743, 0x452738, 0x0D264A, 0x8E933E, 251 + 0x069349,
  252 + 0x7729BD,
  253 + 0x06AA51,
  254 + 0x0AD546,
  255 + 0x54DABA,
  256 + 0x04B64E,
  257 + 0x0A5743,
  258 + 0x452738,
  259 + 0x0D264A,
  260 + 0x8E933E,
70 /*2091-2099*/ 261 /*2091-2099*/
71 - 0x0D5252, 0x0DAA47, 0x66B53B, 0x056D4F, 0x04AE45, 0x4A4EB9, 0x0A4D4C, 0x0D1541, 0x2D92B5 262 + 0x0D5252,
  263 + 0x0DAA47,
  264 + 0x66B53B,
  265 + 0x056D4F,
  266 + 0x04AE45,
  267 + 0x4A4EB9,
  268 + 0x0A4D4C,
  269 + 0x0D1541,
  270 + 0x2D92B5
72 ]; 271 ];
73 272
74 /** 273 /**
@@ -79,17 +278,21 @@ class LunarCalendarUtil { @@ -79,17 +278,21 @@ class LunarCalendarUtil {
79 * @param isLeapMonth 该月是否是闰月(该参数可以根据本类中leapMonth()方法,先判断一下要查询的年份是否有闰月,并且闰的几月) 278 * @param isLeapMonth 该月是否是闰月(该参数可以根据本类中leapMonth()方法,先判断一下要查询的年份是否有闰月,并且闰的几月)
80 * @return 返回农历日期对应的公历日期,year0, month1, day2. 279 * @return 返回农历日期对应的公历日期,year0, month1, day2.
81 */ 280 */
82 - static List<int?> lunarToSolar(int year, int month, int monthDay, bool isLeapMonth) { 281 + static List<int?> lunarToSolar(
  282 + int year, int month, int monthDay, bool isLeapMonth) {
83 int dayOffset; 283 int dayOffset;
84 int leapMonth; 284 int leapMonth;
85 int i; 285 int i;
86 - if (year < MIN_YEAR || year > MAX_YEAR || month < 1 || month > 12  
87 - || monthDay < 1 || monthDay > 30) {  
88 - throw new Exception(  
89 - "Illegal lunar date, must be like that:\n\t" +  
90 - "year : 1900~2099\n\t" +  
91 - "month : 1~12\n\t" +  
92 - "day : 1~30"); 286 + if (year < MIN_YEAR ||
  287 + year > MAX_YEAR ||
  288 + month < 1 ||
  289 + month > 12 ||
  290 + monthDay < 1 ||
  291 + monthDay > 30) {
  292 + throw new Exception("Illegal lunar date, must be like that:\n\t" +
  293 + "year : 1900~2099\n\t" +
  294 + "month : 1~12\n\t" +
  295 + "day : 1~30");
93 } 296 }
94 dayOffset = (LUNAR_INFO[year - MIN_YEAR] & 0x001F) - 1; 297 dayOffset = (LUNAR_INFO[year - MIN_YEAR] & 0x001F) - 1;
95 if (((LUNAR_INFO[year - MIN_YEAR] & 0x0060) >> 5) == 2) { 298 if (((LUNAR_INFO[year - MIN_YEAR] & 0x0060) >> 5) == 2) {
@@ -122,7 +325,7 @@ class LunarCalendarUtil { @@ -122,7 +325,7 @@ class LunarCalendarUtil {
122 dayOffset -= 365; 325 dayOffset -= 365;
123 } 326 }
124 } 327 }
125 - List<int?> solarInfo = [null,null,null]; 328 + List<int?> solarInfo = [null, null, null];
126 for (i = 1; i < 13; i++) { 329 for (i = 1; i < 13; i++) {
127 int iPos = DAYS_BEFORE_MONTH[i]; 330 int iPos = DAYS_BEFORE_MONTH[i];
128 if (year % 4 == 0 && i > 2) { 331 if (year % 4 == 0 && i > 2) {
@@ -157,6 +360,122 @@ class LunarCalendarUtil { @@ -157,6 +360,122 @@ class LunarCalendarUtil {
157 return solarInfo; 360 return solarInfo;
158 } 361 }
159 362
  363 + static String formatLunarDate(int lunarMonth, int lunarDay) {
  364 + // 创建一个数组来存储农历月份的名字
  365 + var monthNames = [
  366 + '正月',
  367 + '二月',
  368 + '三月',
  369 + '四月',
  370 + '五月',
  371 + '六月',
  372 + '七月',
  373 + '八月',
  374 + '九月',
  375 + '十月',
  376 + '冬月',
  377 + '腊月'
  378 + ];
  379 +
  380 + // 创建一个数组来存储农历日期的名字
  381 + var dayNames = [
  382 + '初一',
  383 + '初二',
  384 + '初三',
  385 + '初四',
  386 + '初五',
  387 + '初六',
  388 + '初七',
  389 + '初八',
  390 + '初九',
  391 + '初十',
  392 + '十一',
  393 + '十二',
  394 + '十三',
  395 + '十四',
  396 + '十五',
  397 + '十六',
  398 + '十七',
  399 + '十八',
  400 + '十九',
  401 + '二十',
  402 + '廿一',
  403 + '廿二',
  404 + '廿三',
  405 + '廿四',
  406 + '廿五',
  407 + '廿六',
  408 + '廿七',
  409 + '廿八',
  410 + '廿九',
  411 + '三十'
  412 + ];
  413 +
  414 + return '${monthNames[lunarMonth - 1]}${dayNames[lunarDay - 1]}';
  415 + }
  416 +
  417 + static int getMonth(String month) {
  418 + // 创建一个数组来存储农历月份的名字
  419 + if (month.contains('润')) {
  420 + month = month.replaceAll('润', '');
  421 + }
  422 +
  423 + var monthNames = [
  424 + '正月',
  425 + '二月',
  426 + '三月',
  427 + '四月',
  428 + '五月',
  429 + '六月',
  430 + '七月',
  431 + '八月',
  432 + '九月',
  433 + '十月',
  434 + '冬月',
  435 + '腊月'
  436 + ];
  437 +
  438 + return monthNames.indexOf(month) + 1;
  439 + }
  440 +
  441 + static int getDay(String day) {
  442 + // 创建一个数组来存储农历日期的名字
  443 + // 创建一个数组来存储农历日期的名字
  444 + var dayNames = [
  445 + '初一',
  446 + '初二',
  447 + '初三',
  448 + '初四',
  449 + '初五',
  450 + '初六',
  451 + '初七',
  452 + '初八',
  453 + '初九',
  454 + '初十',
  455 + '十一',
  456 + '十二',
  457 + '十三',
  458 + '十四',
  459 + '十五',
  460 + '十六',
  461 + '十七',
  462 + '十八',
  463 + '十九',
  464 + '二十',
  465 + '廿一',
  466 + '廿二',
  467 + '廿三',
  468 + '廿四',
  469 + '廿五',
  470 + '廿六',
  471 + '廿七',
  472 + '廿八',
  473 + '廿九',
  474 + '三十'
  475 + ];
  476 + return dayNames.indexOf(day) + 1;
  477 + }
  478 +
160 /** 479 /**
161 * 传回农历year年month月的总天数 480 * 传回农历year年month月的总天数
162 * 481 *
@@ -1031,6 +1031,54 @@ class Utils { @@ -1031,6 +1031,54 @@ class Utils {
1031 return lunarCalendarUtilsShow(day); 1031 return lunarCalendarUtilsShow(day);
1032 } 1032 }
1033 1033
  1034 + //农历节日 *表示放假日
  1035 + static String? lunarCalendarUnHolidays(DateTime day) {
  1036 + // LunarCalendar lunarCalendar = LunarCalendar(day);
  1037 + //阴历月-日
  1038 + // String keyLunar =
  1039 + // addZeroNumber(lunarCalendar.month) + addZeroNumber(lunarCalendar.day!);
  1040 + //阳历月-日
  1041 + // String keySolar =
  1042 + // Utils.addZeroNumber(day.month) + Utils.addZeroNumber(day.day);
  1043 + // Map<String, String> holiday1 = {
  1044 + // "0101": "春节",
  1045 + // "0102": "大年初二",
  1046 + // "0103": "大年初三",
  1047 + // "0104": "大年初四",
  1048 + // "0105": "大年初五",
  1049 + // "0106": "大年初六",
  1050 + // "0107": "大年初七",
  1051 + // "0115": "元宵节",
  1052 + // "0505": "端午节",
  1053 + // "0707": "七夕情人节",
  1054 + // "0815": "中秋节",
  1055 + // "0909": "重阳节",
  1056 + // "1208": "腊八节",
  1057 + // "1223": "过小年",
  1058 + // "0100": "除夕"
  1059 + // };
  1060 + // Map<String, String> holiday2 = {
  1061 + // "0101": '元旦',
  1062 + // "0214": "情人节",
  1063 + // "0308": "妇女节",
  1064 + // "0501": "劳动节",
  1065 + // "0504": "青年节",
  1066 + // "0601": "国际儿童节",
  1067 + // "0801": "八一建军节",
  1068 + // "0910": "教师节",
  1069 + // "1001": "国庆节",
  1070 + // "1224": "平安夜",
  1071 + // "1225": "圣诞节",
  1072 + // };
  1073 + // if (holiday1.containsKey(keyLunar)) {
  1074 + // return holiday1[keyLunar];
  1075 + // }
  1076 + // if (holiday2.containsKey(keySolar)) {
  1077 + // return holiday2[keySolar];
  1078 + // }
  1079 + return lunarCalendarUtils(day);
  1080 + }
  1081 +
1034 //农历节日 *表示放假日 1082 //农历节日 *表示放假日
1035 static String? lunarCalendarHolidays(DateTime day) { 1083 static String? lunarCalendarHolidays(DateTime day) {
1036 LunarCalendar lunarCalendar = LunarCalendar(day); 1084 LunarCalendar lunarCalendar = LunarCalendar(day);
@@ -1223,7 +1223,7 @@ packages: @@ -1223,7 +1223,7 @@ packages:
1223 source: hosted 1223 source: hosted
1224 version: "2.0.3" 1224 version: "2.0.3"
1225 lunar: 1225 lunar:
1226 - dependency: transitive 1226 + dependency: "direct main"
1227 description: 1227 description:
1228 name: lunar 1228 name: lunar
1229 sha256: "4ebb40c1647c5903fc67ff0be09a4ce90da79b482f0c78a8c727086a67375c37" 1229 sha256: "4ebb40c1647c5903fc67ff0be09a4ce90da79b482f0c78a8c727086a67375c37"
@@ -290,6 +290,8 @@ dependencies: @@ -290,6 +290,8 @@ dependencies:
290 # flutter_swiper: ^1.1.6 290 # flutter_swiper: ^1.1.6
291 flutter_swiper_null_safety: ^1.0.2 291 flutter_swiper_null_safety: ^1.0.2
292 pop_scope_page_transitions: ^0.0.1 292 pop_scope_page_transitions: ^0.0.1
  293 + lunar: ^1.2.21
  294 +
293 295
294 296
295 297