Commit 3419ac4ef1ff6198934d19fee60140f0b4607d3c

Authored by wdn127929
1 parent 0ab9838a

小程序卡片封面图尺寸原图尺寸

@@ -1240,12 +1240,13 @@ class InvicationPageState extends State<InvicationPage> @@ -1240,12 +1240,13 @@ class InvicationPageState extends State<InvicationPage>
1240 ///初始化时间 半个小时 1240 ///初始化时间 半个小时
1241 _initTime(int dateSolt) { 1241 _initTime(int dateSolt) {
1242 // UserModel userModel = Provider.of<UserModel>(context, listen: false); 1242 // UserModel userModel = Provider.of<UserModel>(context, listen: false);
1243 - String str = detailModel.detailModelAllSunModel!.mdate == null||detailModel.detailModelAllSunModel!.mdate == '' 1243 + String str = detailModel.detailModelAllSunModel!.mdate == null ||
  1244 + detailModel.detailModelAllSunModel!.mdate == ''
1244 ? "00:00-00:00" 1245 ? "00:00-00:00"
1245 : detailModel.detailModelAllSunModel!.mdate!; 1246 : detailModel.detailModelAllSunModel!.mdate!;
1246 - str == "00:00-00:00"  
1247 - ? dailyList = []  
1248 - : dailyList = _getHourAndMinute(str, dateSolt); 1247 + str == "00:00-00:00"
  1248 + ? dailyList = []
  1249 + : dailyList = _getHourAndMinute(str, dateSolt);
1249 // if (dateSolt == 1) { 1250 // if (dateSolt == 1) {
1250 // //早餐 1251 // //早餐
1251 1252
@@ -5076,6 +5077,7 @@ class InvicationPageState extends State<InvicationPage> @@ -5076,6 +5077,7 @@ class InvicationPageState extends State<InvicationPage>
5076 ddateHm ?? '', 5077 ddateHm ?? '',
5077 dateTime, 5078 dateTime,
5078 detailModel.detailModelAllSunModel!.ddateSolt!, 5079 detailModel.detailModelAllSunModel!.ddateSolt!,
  5080 + detailModel.detailModelAllSunModel!.mname ?? '',
5079 detailModel.liteStyle, 5081 detailModel.liteStyle,
5080 detailModel.liteStyleTitle, 5082 detailModel.liteStyleTitle,
5081 depositId: detailModel.depositId); 5083 depositId: detailModel.depositId);
@@ -5098,6 +5100,7 @@ class InvicationPageState extends State<InvicationPage> @@ -5098,6 +5100,7 @@ class InvicationPageState extends State<InvicationPage>
5098 ddateHm ?? '', 5100 ddateHm ?? '',
5099 dateTime, 5101 dateTime,
5100 detailModel.detailModelAllSunModel!.ddateSolt!, 5102 detailModel.detailModelAllSunModel!.ddateSolt!,
  5103 + detailModel.detailModelAllSunModel!.mname ?? '',
5101 detailModel.liteStyle, 5104 detailModel.liteStyle,
5102 detailModel.liteStyleTitle, 5105 detailModel.liteStyleTitle,
5103 depositId: detailModel.depositId); 5106 depositId: detailModel.depositId);
@@ -5119,6 +5122,7 @@ class InvicationPageState extends State<InvicationPage> @@ -5119,6 +5122,7 @@ class InvicationPageState extends State<InvicationPage>
5119 ddateHm ?? '', 5122 ddateHm ?? '',
5120 dateTime, 5123 dateTime,
5121 detailModel.detailModelAllSunModel!.ddateSolt!, 5124 detailModel.detailModelAllSunModel!.ddateSolt!,
  5125 + detailModel.detailModelAllSunModel!.mname ?? '',
5122 detailModel.liteStyle, 5126 detailModel.liteStyle,
5123 detailModel.liteStyleTitle, 5127 detailModel.liteStyleTitle,
5124 depositId: detailModel.depositId); 5128 depositId: detailModel.depositId);
@@ -5138,6 +5142,7 @@ class InvicationPageState extends State<InvicationPage> @@ -5138,6 +5142,7 @@ class InvicationPageState extends State<InvicationPage>
5138 ddateHm ?? '', 5142 ddateHm ?? '',
5139 dateTime, 5143 dateTime,
5140 detailModel.detailModelAllSunModel!.ddateSolt!, 5144 detailModel.detailModelAllSunModel!.ddateSolt!,
  5145 + detailModel.detailModelAllSunModel!.mname ?? '',
5141 detailModel.liteStyle, 5146 detailModel.liteStyle,
5142 detailModel.liteStyleTitle, 5147 detailModel.liteStyleTitle,
5143 depositId: detailModel.depositId); 5148 depositId: detailModel.depositId);
@@ -2467,12 +2467,14 @@ class Utils { @@ -2467,12 +2467,14 @@ class Utils {
2467 } 2467 }
2468 2468
2469 static Future<Uint8List> canvas(context, String _thumbnail, DateTime date, 2469 static Future<Uint8List> canvas(context, String _thumbnail, DateTime date,
2470 - String liteStyle, String dsolt, String ddateHm) async { 2470 + String liteStyle, String dsolt, String ddateHm, String mname) async {
2471 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪 2471 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
2472 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪 2472 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
2473 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片 2473 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
2474 print(images); 2474 print(images);
2475 final Paint paint = Paint(); 2475 final Paint paint = Paint();
  2476 + double scaleX = images.width / 210;
  2477 + double scaleY = images.height / 168;
2476 canvas.drawImage(images, Offset.zero, paint); //绘制原始图片 2478 canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
2477 2479
2478 List<String> subType = liteStyle.split('-'); 2480 List<String> subType = liteStyle.split('-');
@@ -2483,9 +2485,9 @@ class Utils { @@ -2483,9 +2485,9 @@ class Utils {
2483 String week = returnWeek(date, context); 2485 String week = returnWeek(date, context);
2484 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm} ' : ''; 2486 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm} ' : '';
2485 String section = subType1 == '1' || subType1 == '4' 2487 String section = subType1 == '1' || subType1 == '4'
2486 - ? _getDsoltStrShow(dsolt) 2488 + ? _getDsoltStrShow(dsolt, mname)
2487 : subType1 == '2' 2489 : subType1 == '2'
2488 - ? _getDsoltStrShow(dsolt, isCan: false) 2490 + ? _getDsoltStrShow(dsolt, mname, isCan: false)
2489 : ''; 2491 : '';
2490 2492
2491 String time = month + week + hour + section; 2493 String time = month + week + hour + section;
@@ -2501,7 +2503,8 @@ class Utils { @@ -2501,7 +2503,8 @@ class Utils {
2501 // // 定义目标矩形,即画布的大小 2503 // // 定义目标矩形,即画布的大小
2502 // final Rect destination = Rect.fromLTWH(0.0, 0.0, w(210), w(168)); 2504 // final Rect destination = Rect.fromLTWH(0.0, 0.0, w(210), w(168));
2503 // // 绘制图像 2505 // // 绘制图像
2504 - canvas.drawRect(Rect.fromLTWH(0, 0, 500, 60), paint); 2506 + canvas.drawRect(
  2507 + Rect.fromLTWH(0, 0, images.width.toDouble(), 28 * scaleY), paint);
2505 // canvas.drawImageRect(images, source, destination, paint); 2508 // canvas.drawImageRect(images, source, destination, paint);
2506 2509
2507 // 定义源矩形,通常是图像的全部 2510 // 定义源矩形,通常是图像的全部
@@ -2533,11 +2536,15 @@ class Utils { @@ -2533,11 +2536,15 @@ class Utils {
2533 '${Provider.of<UserModel>(context, listen: false).user!.sellername}'); 2536 '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
2534 2537
2535 // 设置文本的宽度约束 2538 // 设置文本的宽度约束
2536 - ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500); 2539 + ParagraphConstraints pc2 =
  2540 + ui.ParagraphConstraints(width: images.width.toDouble());
2537 ui.Paragraph paragraph2 = pb2.build()..layout(pc2); 2541 ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
2538 - canvas.drawParagraph(paragraph2, Offset(0, 14)); 2542 + canvas.drawParagraph(paragraph2, Offset(0, 8 * scaleY));
2539 2543
2540 - canvas.drawRect(Rect.fromLTWH(0, 340, 500, 60), paint); 2544 + canvas.drawRect(
  2545 + Rect.fromLTWH(0, images.height - 28 * scaleY, images.width.toDouble(),
  2546 + 28 * scaleY),
  2547 + paint);
2541 2548
2542 // 绘制文字 2549 // 绘制文字
2543 ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle( 2550 ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2550,9 +2557,11 @@ class Utils { @@ -2550,9 +2557,11 @@ class Utils {
2550 pb.addText(time); 2557 pb.addText(time);
2551 2558
2552 // 设置文本的宽度约束 2559 // 设置文本的宽度约束
2553 - ParagraphConstraints pc = ui.ParagraphConstraints(width: 500); 2560 + ParagraphConstraints pc =
  2561 + ui.ParagraphConstraints(width: images.width.toDouble());
2554 ui.Paragraph paragraph = pb.build()..layout(pc); 2562 ui.Paragraph paragraph = pb.build()..layout(pc);
2555 - canvas.drawParagraph(paragraph, Offset(0, 354)); 2563 + canvas.drawParagraph(
  2564 + paragraph, Offset(0, images.height - 28 * scaleY + 8 * scaleY));
2556 2565
2557 // 绘制文字 2566 // 绘制文字
2558 // ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle( 2567 // ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2569,8 +2578,9 @@ class Utils { @@ -2569,8 +2578,9 @@ class Utils {
2569 // canvas.drawParagraph(paragraph3, Offset(10, 230)); 2578 // canvas.drawParagraph(paragraph3, Offset(10, 230));
2570 2579
2571 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计 2580 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
2572 - var picture =  
2573 - await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高 2581 + var picture = await pictureRecorder
  2582 + .endRecording()
  2583 + .toImage(images.width, images.height); //设置生成图片的宽和高
2574 var pngImageBytes = 2584 var pngImageBytes =
2575 (await picture.toByteData(format: ui.ImageByteFormat.png))!; 2585 (await picture.toByteData(format: ui.ImageByteFormat.png))!;
2576 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道) 2586 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
@@ -2582,12 +2592,15 @@ class Utils { @@ -2582,12 +2592,15 @@ class Utils {
2582 } 2592 }
2583 2593
2584 static Future<Uint8List> canvas2(context, String _thumbnail, DateTime date, 2594 static Future<Uint8List> canvas2(context, String _thumbnail, DateTime date,
2585 - String liteStyle, String dsolt, String ddateHm) async { 2595 + String liteStyle, String dsolt, String ddateHm, String mname) async {
2586 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪 2596 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
2587 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪 2597 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
2588 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片 2598 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
2589 print(images); 2599 print(images);
2590 final Paint paint = Paint(); 2600 final Paint paint = Paint();
  2601 + double scaleX = images.width / 210;
  2602 + double scaleY = images.height / 168;
  2603 +
2591 canvas.drawImage(images, Offset.zero, paint); //绘制原始图片 2604 canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
2592 2605
2593 List<String> subType = liteStyle.split('-'); 2606 List<String> subType = liteStyle.split('-');
@@ -2598,9 +2611,9 @@ class Utils { @@ -2598,9 +2611,9 @@ class Utils {
2598 String week = returnWeek(date, context); 2611 String week = returnWeek(date, context);
2599 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm} ' : ''; 2612 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm} ' : '';
2600 String section = subType1 == '1' || subType1 == '4' 2613 String section = subType1 == '1' || subType1 == '4'
2601 - ? _getDsoltStrShow(dsolt) 2614 + ? _getDsoltStrShow(dsolt, mname)
2602 : subType1 == '2' 2615 : subType1 == '2'
2603 - ? _getDsoltStrShow(dsolt, isCan: false) 2616 + ? _getDsoltStrShow(dsolt, mname, isCan: false)
2604 : ''; 2617 : '';
2605 2618
2606 String time = week + hour + section; 2619 String time = week + hour + section;
@@ -2611,7 +2624,9 @@ class Utils { @@ -2611,7 +2624,9 @@ class Utils {
2611 // paint.style = PaintingStyle.fill; 2624 // paint.style = PaintingStyle.fill;
2612 // } 2625 // }
2613 // // 绘制图像 2626 // // 绘制图像
2614 - canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint); 2627 + canvas.drawRect(
  2628 + Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
  2629 + paint);
2615 2630
2616 // if (Platform.isIOS) { 2631 // if (Platform.isIOS) {
2617 // final paint1 = Paint() 2632 // final paint1 = Paint()
@@ -2628,15 +2643,16 @@ class Utils { @@ -2628,15 +2643,16 @@ class Utils {
2628 maxLines: 2, 2643 maxLines: 2,
2629 height: 1, 2644 height: 1,
2630 fontStyle: FontStyle.normal, 2645 fontStyle: FontStyle.normal,
2631 - fontSize: 428)); 2646 + fontSize: 42));
2632 pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 42)); 2647 pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 42));
2633 pb2.addText( 2648 pb2.addText(
2634 '${Provider.of<UserModel>(context, listen: false).user!.sellername}'); 2649 '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
2635 2650
2636 // 设置文本的宽度约束 2651 // 设置文本的宽度约束
2637 - ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500); 2652 + ParagraphConstraints pc2 =
  2653 + ui.ParagraphConstraints(width: images.width.toDouble());
2638 ui.Paragraph paragraph2 = pb2.build()..layout(pc2); 2654 ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
2639 - canvas.drawParagraph(paragraph2, Offset(0, 86)); 2655 + canvas.drawParagraph(paragraph2, Offset(0, 32 * scaleY));
2640 2656
2641 // 绘制文字 2657 // 绘制文字
2642 ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle( 2658 ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2649,9 +2665,10 @@ class Utils { @@ -2649,9 +2665,10 @@ class Utils {
2649 pb3.addText(month); 2665 pb3.addText(month);
2650 2666
2651 // 设置文本的宽度约束 2667 // 设置文本的宽度约束
2652 - ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 500); 2668 + ParagraphConstraints pc3 =
  2669 + ui.ParagraphConstraints(width: images.width.toDouble());
2653 ui.Paragraph paragraph3 = pb3.build()..layout(pc3); 2670 ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
2654 - canvas.drawParagraph(paragraph3, Offset(0, 190)); 2671 + canvas.drawParagraph(paragraph3, Offset(0, 79 * scaleY));
2655 2672
2656 // 绘制文字 2673 // 绘制文字
2657 ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle( 2674 ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2664,13 +2681,15 @@ class Utils { @@ -2664,13 +2681,15 @@ class Utils {
2664 pb.addText(time); 2681 pb.addText(time);
2665 2682
2666 // 设置文本的宽度约束 2683 // 设置文本的宽度约束
2667 - ParagraphConstraints pc = ui.ParagraphConstraints(width: 500); 2684 + ParagraphConstraints pc =
  2685 + ui.ParagraphConstraints(width: images.width.toDouble());
2668 ui.Paragraph paragraph = pb.build()..layout(pc); 2686 ui.Paragraph paragraph = pb.build()..layout(pc);
2669 - canvas.drawParagraph(paragraph, Offset(0, 285)); 2687 + canvas.drawParagraph(paragraph, Offset(0, 120 * scaleY));
2670 2688
2671 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计 2689 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
2672 - var picture =  
2673 - await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高 2690 + var picture = await pictureRecorder
  2691 + .endRecording()
  2692 + .toImage(images.width, images.height); //设置生成图片的宽和高
2674 var pngImageBytes = 2693 var pngImageBytes =
2675 (await picture.toByteData(format: ui.ImageByteFormat.png))!; 2694 (await picture.toByteData(format: ui.ImageByteFormat.png))!;
2676 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道) 2695 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
@@ -2682,13 +2701,15 @@ class Utils { @@ -2682,13 +2701,15 @@ class Utils {
2682 } 2701 }
2683 2702
2684 static Future<Uint8List> canvas3(context, String _thumbnail, DateTime date, 2703 static Future<Uint8List> canvas3(context, String _thumbnail, DateTime date,
2685 - String liteStyle, String dsolt, String ddateHm) async { 2704 + String liteStyle, String dsolt, String ddateHm, String mname) async {
2686 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪 2705 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
2687 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪 2706 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
2688 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片 2707 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
2689 print(images); 2708 print(images);
2690 final Paint paint = Paint(); 2709 final Paint paint = Paint();
2691 canvas.drawImage(images, Offset.zero, paint); //绘制原始图片 2710 canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
  2711 + double scaleX = images.width / 210;
  2712 + double scaleY = images.height / 168;
2692 2713
2693 List<String> subType = liteStyle.split('-'); 2714 List<String> subType = liteStyle.split('-');
2694 // String subType0 = subType[0]; //几号模版 2715 // String subType0 = subType[0]; //几号模版
@@ -2698,9 +2719,9 @@ class Utils { @@ -2698,9 +2719,9 @@ class Utils {
2698 String week = returnWeek(date, context); 2719 String week = returnWeek(date, context);
2699 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm}' : ''; 2720 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm}' : '';
2700 String section = subType1 == '1' || subType1 == '4' 2721 String section = subType1 == '1' || subType1 == '4'
2701 - ? _getDsoltStrShow(dsolt) 2722 + ? _getDsoltStrShow(dsolt, mname)
2702 : subType1 == '2' 2723 : subType1 == '2'
2703 - ? _getDsoltStrShow(dsolt, isCan: false) 2724 + ? _getDsoltStrShow(dsolt, mname, isCan: false)
2704 : ''; 2725 : '';
2705 2726
2706 if (hour != '' && section != '') { 2727 if (hour != '' && section != '') {
@@ -2715,7 +2736,9 @@ class Utils { @@ -2715,7 +2736,9 @@ class Utils {
2715 // paint.style = PaintingStyle.fill; 2736 // paint.style = PaintingStyle.fill;
2716 // } 2737 // }
2717 // // 绘制图像 2738 // // 绘制图像
2718 - canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint); 2739 + canvas.drawRect(
  2740 + Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
  2741 + paint);
2719 2742
2720 // if (Platform.isIOS) { 2743 // if (Platform.isIOS) {
2721 // final paint1 = Paint() 2744 // final paint1 = Paint()
@@ -2754,7 +2777,8 @@ class Utils { @@ -2754,7 +2777,8 @@ class Utils {
2754 // 设置文本的宽度约束 2777 // 设置文本的宽度约束
2755 ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 270); 2778 ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 270);
2756 ui.Paragraph paragraph3 = pb3.build()..layout(pc3); 2779 ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
2757 - canvas.drawParagraph(paragraph3, Offset(155, 250)); 2780 + canvas.drawParagraph(
  2781 + paragraph3, Offset(images.width - 340, images.height - 180));
2758 2782
2759 // 绘制文字 2783 // 绘制文字
2760 ui.ParagraphBuilder pb4 = ui.ParagraphBuilder(ui.ParagraphStyle( 2784 ui.ParagraphBuilder pb4 = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2769,11 +2793,12 @@ class Utils { @@ -2769,11 +2793,12 @@ class Utils {
2769 // 设置文本的宽度约束 2793 // 设置文本的宽度约束
2770 ParagraphConstraints pc4 = ui.ParagraphConstraints(width: 40); 2794 ParagraphConstraints pc4 = ui.ParagraphConstraints(width: 40);
2771 ui.Paragraph paragraph4 = pb4.build()..layout(pc4); 2795 ui.Paragraph paragraph4 = pb4.build()..layout(pc4);
2772 - canvas.drawParagraph(paragraph4, Offset(430, 250)); 2796 + canvas.drawParagraph(
  2797 + paragraph4, Offset(images.width - 70, images.height - 180));
2773 2798
2774 Rect rect = subType1 == '1' 2799 Rect rect = subType1 == '1'
2775 - ? Rect.fromLTWH(250, 340, 220, 50)  
2776 - : Rect.fromLTWH(362, 340, 104, 50); 2800 + ? Rect.fromLTWH(images.width - 250, images.height - 90, 220, 50)
  2801 + : Rect.fromLTWH(158 * scaleX, images.height - 90, 40 * scaleX, 50);
2777 paint.color = MyColours.color_66FFEFC5; 2802 paint.color = MyColours.color_66FFEFC5;
2778 RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(6)); 2803 RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(6));
2779 canvas.drawRRect(rRect, paint); 2804 canvas.drawRRect(rRect, paint);
@@ -2790,15 +2815,18 @@ class Utils { @@ -2790,15 +2815,18 @@ class Utils {
2790 pb.addText(time); 2815 pb.addText(time);
2791 2816
2792 // 设置文本的宽度约束 2817 // 设置文本的宽度约束
2793 - double width = subType1 == '1' ? 240 : 154;  
2794 - Offset offset = subType1 == '1' ? Offset(241, 349) : Offset(338, 349); 2818 + double width = subType1 == '1' ? 240 : 40 * scaleX;
  2819 + Offset offset = subType1 == '1'
  2820 + ? Offset(images.width - 260, images.height - 80)
  2821 + : Offset(158 * scaleX, images.height - 80);
2795 ParagraphConstraints pc = ui.ParagraphConstraints(width: width); 2822 ParagraphConstraints pc = ui.ParagraphConstraints(width: width);
2796 ui.Paragraph paragraph = pb.build()..layout(pc); 2823 ui.Paragraph paragraph = pb.build()..layout(pc);
2797 canvas.drawParagraph(paragraph, offset); 2824 canvas.drawParagraph(paragraph, offset);
2798 2825
2799 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计 2826 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
2800 - var picture =  
2801 - await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高 2827 + var picture = await pictureRecorder
  2828 + .endRecording()
  2829 + .toImage(images.width, images.height); //设置生成图片的宽和高
2802 var pngImageBytes = 2830 var pngImageBytes =
2803 (await picture.toByteData(format: ui.ImageByteFormat.png))!; 2831 (await picture.toByteData(format: ui.ImageByteFormat.png))!;
2804 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道) 2832 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
@@ -2810,7 +2838,7 @@ class Utils { @@ -2810,7 +2838,7 @@ class Utils {
2810 } 2838 }
2811 2839
2812 static Future<Uint8List> canvas4(context, String _thumbnail, DateTime date, 2840 static Future<Uint8List> canvas4(context, String _thumbnail, DateTime date,
2813 - String liteStyle, String dsolt, String ddateHm) async { 2841 + String liteStyle, String dsolt, String ddateHm, String mname) async {
2814 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪 2842 var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
2815 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪 2843 var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
2816 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片 2844 var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
@@ -2827,9 +2855,9 @@ class Utils { @@ -2827,9 +2855,9 @@ class Utils {
2827 String week = returnWeek(date, context); 2855 String week = returnWeek(date, context);
2828 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm}' : ''; 2856 String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm}' : '';
2829 String section = subType1 == '1' || subType1 == '4' 2857 String section = subType1 == '1' || subType1 == '4'
2830 - ? _getDsoltStrShow(dsolt) 2858 + ? _getDsoltStrShow(dsolt, mname)
2831 : subType1 == '2' 2859 : subType1 == '2'
2832 - ? _getDsoltStrShow(dsolt, isCan: false) 2860 + ? _getDsoltStrShow(dsolt, mname, isCan: false)
2833 : ''; 2861 : '';
2834 2862
2835 if (section != '' && hour != '') { 2863 if (section != '' && hour != '') {
@@ -2844,7 +2872,11 @@ class Utils { @@ -2844,7 +2872,11 @@ class Utils {
2844 // paint.style = PaintingStyle.fill; 2872 // paint.style = PaintingStyle.fill;
2845 // } 2873 // }
2846 // // 绘制图像 2874 // // 绘制图像
2847 - canvas.drawRect(Rect.fromLTWH(0, 267, 500, 133), paint); 2875 + double scaleX = images.width / 210;
  2876 + double scaleY = images.height / 168;
  2877 + canvas.drawRect(
  2878 + Rect.fromLTWH(0, 112 * scaleY, images.width.toDouble(), 56 * scaleY),
  2879 + paint);
2848 2880
2849 // if (Platform.isIOS) { 2881 // if (Platform.isIOS) {
2850 // final paint1 = Paint() 2882 // final paint1 = Paint()
@@ -2866,9 +2898,10 @@ class Utils { @@ -2866,9 +2898,10 @@ class Utils {
2866 '${Provider.of<UserModel>(context, listen: false).user!.sellername}'); 2898 '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
2867 2899
2868 // 设置文本的宽度约束 2900 // 设置文本的宽度约束
2869 - ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500); 2901 + ParagraphConstraints pc2 =
  2902 + ui.ParagraphConstraints(width: images.width.toDouble());
2870 ui.Paragraph paragraph2 = pb2.build()..layout(pc2); 2903 ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
2871 - canvas.drawParagraph(paragraph2, Offset(0, 275)); 2904 + canvas.drawParagraph(paragraph2, Offset(0, 118 * scaleY));
2872 2905
2873 // 绘制文字 2906 // 绘制文字
2874 ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle( 2907 ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2883,7 +2916,8 @@ class Utils { @@ -2883,7 +2916,8 @@ class Utils {
2883 // 设置文本的宽度约束 2916 // 设置文本的宽度约束
2884 ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 240); 2917 ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 240);
2885 ui.Paragraph paragraph3 = pb3.build()..layout(pc3); 2918 ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
2886 - canvas.drawParagraph(paragraph3, Offset(subType1 == '1' ? 8 : 65, 345)); 2919 + canvas.drawParagraph(paragraph3,
  2920 + Offset(subType1 == '1' ? 17 * scaleX : 35 * scaleX, 146 * scaleY));
2887 2921
2888 // // 绘制文字 2922 // // 绘制文字
2889 // ui.ParagraphBuilder pb4 = ui.ParagraphBuilder(ui.ParagraphStyle( 2923 // ui.ParagraphBuilder pb4 = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -2900,8 +2934,8 @@ class Utils { @@ -2900,8 +2934,8 @@ class Utils {
2900 // ui.Paragraph paragraph4 = pb4.build()..layout(pc4); 2934 // ui.Paragraph paragraph4 = pb4.build()..layout(pc4);
2901 // canvas.drawParagraph(paragraph4, Offset(420, 320)); 2935 // canvas.drawParagraph(paragraph4, Offset(420, 320));
2902 2936
2903 - Rect rect = Rect.fromLTWH(  
2904 - subType1 == '1' ? 265 : 315, 335, subType1 == '1' ? 210 : 112, 50); 2937 + Rect rect = Rect.fromLTWH(subType1 == '1' ? 107 * scaleX : 127 * scaleX,
  2938 + 142 * scaleY, subType1 == '1' ? 80 * scaleX : 40 * scaleX, 20 * scaleY);
2905 paint.color = MyColours.color_66FFEFC5; 2939 paint.color = MyColours.color_66FFEFC5;
2906 RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(6)); 2940 RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(6));
2907 canvas.drawRRect(rRect, paint); 2941 canvas.drawRRect(rRect, paint);
@@ -2920,15 +2954,24 @@ class Utils { @@ -2920,15 +2954,24 @@ class Utils {
2920 2954
2921 // 设置文本的宽度约束 2955 // 设置文本的宽度约束
2922 2956
2923 - Offset offset = subType1 == '1' ? Offset(265, 345) : Offset(315, 345);  
2924 - ParagraphConstraints pc =  
2925 - ui.ParagraphConstraints(width: subType1 == '1' ? 210 : 112); 2957 + Offset offset = subType1 == '1'
  2958 + ? Offset(
  2959 + 103 * scaleX,
  2960 + 146 * scaleY,
  2961 + )
  2962 + : Offset(
  2963 + 126 * scaleX,
  2964 + 146 * scaleY,
  2965 + );
  2966 + ParagraphConstraints pc = ui.ParagraphConstraints(
  2967 + width: subType1 == '1' ? 87 * scaleX : 41 * scaleX);
2926 ui.Paragraph paragraph = pb.build()..layout(pc); 2968 ui.Paragraph paragraph = pb.build()..layout(pc);
2927 canvas.drawParagraph(paragraph, offset); 2969 canvas.drawParagraph(paragraph, offset);
2928 2970
2929 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计 2971 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
2930 - var picture =  
2931 - await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高 2972 + var picture = await pictureRecorder
  2973 + .endRecording()
  2974 + .toImage(images.width, images.height); //设置生成图片的宽和高
2932 var pngImageBytes = 2975 var pngImageBytes =
2933 (await picture.toByteData(format: ui.ImageByteFormat.png))!; 2976 (await picture.toByteData(format: ui.ImageByteFormat.png))!;
2934 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道) 2977 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
@@ -2960,7 +3003,11 @@ class Utils { @@ -2960,7 +3003,11 @@ class Utils {
2960 // paint.style = PaintingStyle.fill; 3003 // paint.style = PaintingStyle.fill;
2961 // } 3004 // }
2962 // // 绘制图像 3005 // // 绘制图像
2963 - canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint); 3006 + double scaleX = images.width / 210;
  3007 + double scaleY = images.height / 168;
  3008 + canvas.drawRect(
  3009 + Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
  3010 + paint);
2964 3011
2965 // // 定义源矩形,通常是图像的全部 3012 // // 定义源矩形,通常是图像的全部
2966 // final Rect source = Rect.fromLTWH( 3013 // final Rect source = Rect.fromLTWH(
@@ -2989,9 +3036,10 @@ class Utils { @@ -2989,9 +3036,10 @@ class Utils {
2989 '${Provider.of<UserModel>(context, listen: false).user!.sellername}'); 3036 '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
2990 3037
2991 // 设置文本的宽度约束 3038 // 设置文本的宽度约束
2992 - ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500); 3039 + ParagraphConstraints pc2 =
  3040 + ui.ParagraphConstraints(width: images.width.toDouble());
2993 ui.Paragraph paragraph2 = pb2.build()..layout(pc2); 3041 ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
2994 - canvas.drawParagraph(paragraph2, Offset(10, 40)); 3042 + canvas.drawParagraph(paragraph2, Offset(0, 15 * scaleY));
2995 3043
2996 // 绘制文字 3044 // 绘制文字
2997 ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle( 3045 ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -3004,9 +3052,10 @@ class Utils { @@ -3004,9 +3052,10 @@ class Utils {
3004 pb.addText(month); 3052 pb.addText(month);
3005 3053
3006 // 设置文本的宽度约束 3054 // 设置文本的宽度约束
3007 - ParagraphConstraints pc = ui.ParagraphConstraints(width: 500); 3055 + ParagraphConstraints pc =
  3056 + ui.ParagraphConstraints(width: images.width.toDouble());
3008 ui.Paragraph paragraph = pb.build()..layout(pc); 3057 ui.Paragraph paragraph = pb.build()..layout(pc);
3009 - canvas.drawParagraph(paragraph, Offset(10, 160)); 3058 + canvas.drawParagraph(paragraph, Offset(0, 70 * scaleY));
3010 3059
3011 // 绘制文字 3060 // 绘制文字
3012 ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle( 3061 ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
@@ -3019,9 +3068,10 @@ class Utils { @@ -3019,9 +3068,10 @@ class Utils {
3019 pb3.addText(week); 3068 pb3.addText(week);
3020 3069
3021 // 设置文本的宽度约束 3070 // 设置文本的宽度约束
3022 - ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 500); 3071 + ParagraphConstraints pc3 =
  3072 + ui.ParagraphConstraints(width: images.width.toDouble());
3023 ui.Paragraph paragraph3 = pb3.build()..layout(pc3); 3073 ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
3024 - canvas.drawParagraph(paragraph3, Offset(10, 260)); 3074 + canvas.drawParagraph(paragraph3, Offset(0, 109 * scaleY));
3025 3075
3026 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计 3076 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
3027 // var picture = await pictureRecorder 3077 // var picture = await pictureRecorder
@@ -3036,8 +3086,9 @@ class Utils { @@ -3036,8 +3086,9 @@ class Utils {
3036 // Uint8List result = await realComporessList(pngBytes); //压缩图片 3086 // Uint8List result = await realComporessList(pngBytes); //压缩图片
3037 // return result; 3087 // return result;
3038 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计 3088 //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
3039 - var picture =  
3040 - await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高 3089 + var picture = await pictureRecorder
  3090 + .endRecording()
  3091 + .toImage(images.width, images.height); //设置生成图片的宽和高
3041 var pngImageBytes = 3092 var pngImageBytes =
3042 (await picture.toByteData(format: ui.ImageByteFormat.png))!; 3093 (await picture.toByteData(format: ui.ImageByteFormat.png))!;
3043 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道) 3094 // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
@@ -3205,20 +3256,59 @@ class Utils { @@ -3205,20 +3256,59 @@ class Utils {
3205 return isSuccess; 3256 return isSuccess;
3206 } 3257 }
3207 3258
3208 - static _getDsoltStrShow(String ddateSolt, {bool isCan = true}) { 3259 + static _getDsoltStrShow(String ddateSolt, String mname, {bool isCan = true}) {
3209 String dsoltStr = ''; 3260 String dsoltStr = '';
3210 if (!isCan) { 3261 if (!isCan) {
3211 - dsoltStr = ddateSolt == '1'  
3212 - ? '早上'  
3213 - : ddateSolt == '2'  
3214 - ? '中午'  
3215 - : '晚上'; 3262 + if (mname == '早餐' || mname == '午餐' || mname == '晚餐') {
  3263 + dsoltStr = ddateSolt == '1'
  3264 + ? '早上'
  3265 + : ddateSolt == '2'
  3266 + ? '中午'
  3267 + : '晚上';
  3268 + } else {
  3269 + dsoltStr = mname;
  3270 + }
3216 } else { 3271 } else {
3217 - dsoltStr = ddateSolt == '1'  
3218 - ? '早餐'  
3219 - : ddateSolt == '2'  
3220 - ? '午餐'  
3221 - : '晚餐'; 3272 + if (mname == '早餐' || mname == '午餐' || mname == '晚餐') {
  3273 + dsoltStr = ddateSolt == '1'
  3274 + ? '早餐'
  3275 + : ddateSolt == '2'
  3276 + ? '午餐'
  3277 + : '晚餐';
  3278 + } else {
  3279 + dsoltStr = mname;
  3280 + }
  3281 + }
  3282 + return dsoltStr;
  3283 + }
  3284 +
  3285 + static _getDsoltStrShowOld(
  3286 + String? ddateHm,
  3287 + String? liteStyle,
  3288 + String ddateSolt,
  3289 + String mname,
  3290 + ) {
  3291 + String dsoltStr = '${ddateHm == null || ddateHm == '' ? '' : ddateHm}';
  3292 + if (liteStyle == '1') {
  3293 + if (mname == '早餐' || mname == '午餐' || mname == '晚餐') {
  3294 + dsoltStr = ddateSolt == '1'
  3295 + ? '早上'
  3296 + : ddateSolt == '2'
  3297 + ? '中午'
  3298 + : '晚上';
  3299 + } else {
  3300 + dsoltStr = mname;
  3301 + }
  3302 + } else if (liteStyle == '3') {
  3303 + if (mname == '早餐' || mname == '午餐' || mname == '晚餐') {
  3304 + dsoltStr = ddateSolt == '1'
  3305 + ? '早餐'
  3306 + : ddateSolt == '2'
  3307 + ? '午餐'
  3308 + : '晚餐';
  3309 + } else {
  3310 + dsoltStr = mname;
  3311 + }
3222 } 3312 }
3223 return dsoltStr; 3313 return dsoltStr;
3224 } 3314 }
@@ -3231,6 +3321,7 @@ class Utils { @@ -3231,6 +3321,7 @@ class Utils {
3231 String ddateHm, 3321 String ddateHm,
3232 DateTime dateTime, 3322 DateTime dateTime,
3233 String ddateSolt, 3323 String ddateSolt,
  3324 + String mname,
3234 String? liteStyle, 3325 String? liteStyle,
3235 String? liteStyleTitle, 3326 String? liteStyleTitle,
3236 {bool isWechat = true, 3327 {bool isWechat = true,
@@ -3249,7 +3340,6 @@ class Utils { @@ -3249,7 +3340,6 @@ class Utils {
3249 await WxSdk.fetchImageAsUint8List(_thumbnail); 3340 await WxSdk.fetchImageAsUint8List(_thumbnail);
3250 print(size(_thumbnail.length)); 3341 print(size(_thumbnail.length));
3251 3342
3252 - String dsoltStr = '${ddateHm == null || ddateHm == '' ? '' : ddateHm}';  
3253 // dsoltStr = _getDsoltStrShow(liteStyle!, ddateSolt); 3343 // dsoltStr = _getDsoltStrShow(liteStyle!, ddateSolt);
3254 if (liteStyle != '0') { 3344 if (liteStyle != '0') {
3255 //画图 3345 //画图
@@ -3258,7 +3348,7 @@ class Utils { @@ -3258,7 +3348,7 @@ class Utils {
3258 String month = 3348 String month =
3259 '${Utils.addZeroNumber(dateTime.month)}月${Utils.addZeroNumber(dateTime.day)}日'; 3349 '${Utils.addZeroNumber(dateTime.month)}月${Utils.addZeroNumber(dateTime.day)}日';
3260 String weekAndDsolt = returnWeek(dateTime, context) + 3350 String weekAndDsolt = returnWeek(dateTime, context) +
3261 - _getDsoltStrShow(ddateSolt, isCan: liteStyle == '1' ? false : true); 3351 + _getDsoltStrShowOld(ddateHm, liteStyle, ddateSolt, mname);
3262 _thumbnailUint8List = await canvasold( 3352 _thumbnailUint8List = await canvasold(
3263 context, 3353 context,
3264 sellerImage == null || sellerImage == '' 3354 sellerImage == null || sellerImage == ''
@@ -3278,7 +3368,8 @@ class Utils { @@ -3278,7 +3368,8 @@ class Utils {
3278 dateTime, 3368 dateTime,
3279 liteStyle, 3369 liteStyle,
3280 ddateSolt, 3370 ddateSolt,
3281 - ddateHm); 3371 + ddateHm,
  3372 + mname);
3282 } else if (subType0 == '2') { 3373 } else if (subType0 == '2') {
3283 _thumbnailUint8List = await canvas2( 3374 _thumbnailUint8List = await canvas2(
3284 context, 3375 context,
@@ -3288,7 +3379,8 @@ class Utils { @@ -3288,7 +3379,8 @@ class Utils {
3288 dateTime, 3379 dateTime,
3289 liteStyle, 3380 liteStyle,
3290 ddateSolt, 3381 ddateSolt,
3291 - ddateHm); 3382 + ddateHm,
  3383 + mname);
3292 } else if (subType0 == '3') { 3384 } else if (subType0 == '3') {
3293 _thumbnailUint8List = await canvas3( 3385 _thumbnailUint8List = await canvas3(
3294 context, 3386 context,
@@ -3298,7 +3390,8 @@ class Utils { @@ -3298,7 +3390,8 @@ class Utils {
3298 dateTime, 3390 dateTime,
3299 liteStyle, 3391 liteStyle,
3300 ddateSolt, 3392 ddateSolt,
3301 - ddateHm); 3393 + ddateHm,
  3394 + mname);
3302 } else { 3395 } else {
3303 _thumbnailUint8List = await canvas4( 3396 _thumbnailUint8List = await canvas4(
3304 context, 3397 context,
@@ -3308,7 +3401,8 @@ class Utils { @@ -3308,7 +3401,8 @@ class Utils {
3308 dateTime, 3401 dateTime,
3309 liteStyle, 3402 liteStyle,
3310 ddateSolt, 3403 ddateSolt,
3311 - ddateHm); 3404 + ddateHm,
  3405 + mname);
3312 } 3406 }
3313 } 3407 }
3314 } 3408 }