| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  | import 'package:qhd_prevention/customWidget/toast_util.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |  | import '../http/ApiService.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  | import '../tools/tools.dart'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /// 自定义组件
 | 
					
						
							|  |  |  |  | class ListItemFactory { | 
					
						
							|  |  |  |  |   /// 类型1:横向spaceBetween布局两个文本加按钮
 | 
					
						
							|  |  |  |  |   static Widget createRowSpaceBetweenItem({ | 
					
						
							|  |  |  |  |     required String leftText, | 
					
						
							|  |  |  |  |     required String rightText, | 
					
						
							|  |  |  |  |     double verticalPadding = 10, | 
					
						
							|  |  |  |  |     double horizontalPadding = 0, | 
					
						
							|  |  |  |  |     Color textColor = Colors.black, | 
					
						
							|  |  |  |  |     bool isRight = false, | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |     bool isRequired = false, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							|  |  |  |  |       padding: EdgeInsets.symmetric( | 
					
						
							|  |  |  |  |         vertical: verticalPadding, | 
					
						
							|  |  |  |  |         horizontal: horizontalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Row( | 
					
						
							|  |  |  |  |         mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |         mainAxisSize: MainAxisSize.max, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |         children: [ | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |           Row( | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |             mainAxisSize: MainAxisSize.min, | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |             children: [ | 
					
						
							|  |  |  |  |               if (isRequired) Text('* ', style: TextStyle(color: Colors.red)), | 
					
						
							|  |  |  |  |               Text( | 
					
						
							|  |  |  |  |                 leftText, | 
					
						
							|  |  |  |  |                 style: TextStyle( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |                   fontSize: 13, | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |                   fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |                   color: textColor, | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |               ), | 
					
						
							|  |  |  |  |             ], | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |           ), | 
					
						
							|  |  |  |  |           if (isRight) | 
					
						
							|  |  |  |  |             Row( | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |               mainAxisSize: MainAxisSize.min, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               children: [ | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |                 Flexible( | 
					
						
							|  |  |  |  |                   fit: FlexFit.loose, | 
					
						
							|  |  |  |  |                   child: Text( | 
					
						
							| 
									
										
										
										
											2025-09-06 17:38:07 +08:00
										 |  |  |  |                       _truncateText(rightText,20) , | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |                     style: TextStyle(fontSize: 13, color: Colors.grey), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |                     maxLines: 1, | 
					
						
							|  |  |  |  |                     overflow: TextOverflow.ellipsis, | 
					
						
							|  |  |  |  |                   ), | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |                 SizedBox(width: 6), | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |                 Icon( | 
					
						
							|  |  |  |  |                   Icons.arrow_forward_ios_rounded, | 
					
						
							|  |  |  |  |                   color: Colors.black45, | 
					
						
							|  |  |  |  |                   size: 15, | 
					
						
							|  |  |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               ], | 
					
						
							|  |  |  |  |             ) | 
					
						
							|  |  |  |  |           else | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |             Flexible( | 
					
						
							|  |  |  |  |               fit: FlexFit.loose, | 
					
						
							|  |  |  |  |               child: Text( | 
					
						
							| 
									
										
										
										
											2025-09-02 14:42:47 +08:00
										 |  |  |  |                 _truncateText(rightText,17) , | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |                 style: TextStyle(fontSize: 13, color: Colors.grey), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |                 maxLines: 1, | 
					
						
							|  |  |  |  |                 overflow: TextOverflow.ellipsis, | 
					
						
							|  |  |  |  |                 textAlign: TextAlign.right, | 
					
						
							|  |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2025-07-25 18:06:37 +08:00
										 |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-25 18:06:37 +08:00
										 |  |  |  |   // 辅助函数:截断文本
 | 
					
						
							|  |  |  |  |   static String _truncateText(String text, int maxLength) { | 
					
						
							|  |  |  |  |     if (text.length <= maxLength) return text; | 
					
						
							|  |  |  |  |     return text.substring(0, maxLength) + '...'; | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   ///类型2:上下布局两个文本(自适应高度)
 | 
					
						
							|  |  |  |  |   static Widget createColumnTextItem({ | 
					
						
							|  |  |  |  |     required String topText, | 
					
						
							|  |  |  |  |     required String bottomText, | 
					
						
							|  |  |  |  |     double verticalPadding = 15, | 
					
						
							|  |  |  |  |     double horizontalPadding = 0, | 
					
						
							|  |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							|  |  |  |  |       padding: EdgeInsets.symmetric( | 
					
						
							|  |  |  |  |         vertical: verticalPadding, | 
					
						
							|  |  |  |  |         horizontal: horizontalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Column( | 
					
						
							|  |  |  |  |         crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |  |         mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |  |         children: [ | 
					
						
							|  |  |  |  |           Text( | 
					
						
							|  |  |  |  |             topText, | 
					
						
							|  |  |  |  |             style: TextStyle( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |               fontSize: 13, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |               color: Colors.black, | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |           const SizedBox(height: 5), | 
					
						
							|  |  |  |  |           Text( | 
					
						
							|  |  |  |  |             bottomText, | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |             style: TextStyle(fontSize: 13, color: Colors.grey), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |             softWrap: true, | 
					
						
							|  |  |  |  |             maxLines: null, // 允许无限行数
 | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   /// 类型3:文本和图片上下布局
 | 
					
						
							|  |  |  |  |   static Widget createTextImageItem({ | 
					
						
							|  |  |  |  |     required String text, | 
					
						
							|  |  |  |  |     required List<String> imageUrls, | 
					
						
							|  |  |  |  |     double imageHeight = 90, | 
					
						
							|  |  |  |  |     double verticalPadding = 10, | 
					
						
							|  |  |  |  |     double horizontalPadding = 0, | 
					
						
							|  |  |  |  |     // 点击图片时回调,index 为被点击图片的下标
 | 
					
						
							|  |  |  |  |     void Function(int index)? onImageTapped, | 
					
						
							|  |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							|  |  |  |  |       padding: EdgeInsets.symmetric( | 
					
						
							|  |  |  |  |         vertical: verticalPadding, | 
					
						
							|  |  |  |  |         horizontal: horizontalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Column( | 
					
						
							|  |  |  |  |         crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |  |         children: [ | 
					
						
							|  |  |  |  |           Text( | 
					
						
							|  |  |  |  |             text, | 
					
						
							|  |  |  |  |             style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |               fontSize: 13, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |               color: Colors.black, | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |           const SizedBox(height: 10), | 
					
						
							|  |  |  |  |           Wrap( | 
					
						
							|  |  |  |  |             spacing: 8, // 水平间距
 | 
					
						
							|  |  |  |  |             runSpacing: 8, // 垂直间距
 | 
					
						
							|  |  |  |  |             children: List.generate(imageUrls.length, (i) { | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |               final url = ApiService.baseImgPath + imageUrls[i]; | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               Widget img; | 
					
						
							|  |  |  |  |               if (url.startsWith('http')) { | 
					
						
							|  |  |  |  |                 img = Image.network( | 
					
						
							|  |  |  |  |                   url, | 
					
						
							|  |  |  |  |                   height: imageHeight, | 
					
						
							|  |  |  |  |                   width: imageHeight * 3 / 2, | 
					
						
							| 
									
										
										
										
											2025-08-29 11:05:17 +08:00
										 |  |  |  |                   fit: BoxFit.fill, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |                 ); | 
					
						
							|  |  |  |  |               } else { | 
					
						
							|  |  |  |  |                 img = Image.asset( | 
					
						
							|  |  |  |  |                   url, | 
					
						
							|  |  |  |  |                   height: imageHeight, | 
					
						
							|  |  |  |  |                   width: imageHeight * 3 / 2, | 
					
						
							| 
									
										
										
										
											2025-08-29 11:05:17 +08:00
										 |  |  |  |                   fit: BoxFit.fill, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |                 ); | 
					
						
							|  |  |  |  |               } | 
					
						
							|  |  |  |  |               return GestureDetector( | 
					
						
							|  |  |  |  |                 onTap: () { | 
					
						
							|  |  |  |  |                   if (onImageTapped != null) onImageTapped(i); | 
					
						
							|  |  |  |  |                 }, | 
					
						
							|  |  |  |  |                 child: ClipRRect( | 
					
						
							|  |  |  |  |                   borderRadius: BorderRadius.circular(4), | 
					
						
							|  |  |  |  |                   child: img, | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |               ); | 
					
						
							|  |  |  |  |             }), | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   /// 类型6:文本和视频上下布局
 | 
					
						
							|  |  |  |  |   static Widget createTextVideoItem({ | 
					
						
							|  |  |  |  |     required String text, | 
					
						
							|  |  |  |  |     required String videoUrl, | 
					
						
							|  |  |  |  |     double videoHeight = 90, | 
					
						
							|  |  |  |  |     double verticalPadding = 10, | 
					
						
							|  |  |  |  |     double horizontalPadding = 0, | 
					
						
							|  |  |  |  |     VoidCallback? onVideoTapped, | 
					
						
							|  |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							|  |  |  |  |       padding: EdgeInsets.symmetric( | 
					
						
							|  |  |  |  |         vertical: verticalPadding, | 
					
						
							|  |  |  |  |         horizontal: horizontalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Column( | 
					
						
							|  |  |  |  |         crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |  |         children: [ | 
					
						
							|  |  |  |  |           Text( | 
					
						
							|  |  |  |  |             text, | 
					
						
							|  |  |  |  |             style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |               fontSize: 13, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |               color: Colors.black, | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |           const SizedBox(height: 10), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |           videoUrl.isNotEmpty | 
					
						
							|  |  |  |  |               ? GestureDetector( | 
					
						
							|  |  |  |  |                 onTap: onVideoTapped, | 
					
						
							|  |  |  |  |                 child: Container( | 
					
						
							|  |  |  |  |                   height: videoHeight, | 
					
						
							|  |  |  |  |                   width: videoHeight * 3 / 2, | 
					
						
							|  |  |  |  |                   decoration: BoxDecoration( | 
					
						
							|  |  |  |  |                     color: Colors.grey[300], | 
					
						
							|  |  |  |  |                     borderRadius: BorderRadius.circular(4), | 
					
						
							|  |  |  |  |                   ), | 
					
						
							|  |  |  |  |                   child: const Center( | 
					
						
							|  |  |  |  |                     child: Icon( | 
					
						
							|  |  |  |  |                       Icons.play_circle_outline, | 
					
						
							|  |  |  |  |                       size: 40, | 
					
						
							|  |  |  |  |                       color: Colors.white, | 
					
						
							|  |  |  |  |                     ), | 
					
						
							|  |  |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |               ) | 
					
						
							|  |  |  |  |               : SizedBox(height: 10), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   ///类型4:一个文本(自适应高度)
 | 
					
						
							|  |  |  |  |   static Widget createAloneTextItem({ | 
					
						
							|  |  |  |  |     required String text, | 
					
						
							|  |  |  |  |     double verticalPadding = 10, | 
					
						
							|  |  |  |  |     double horizontalPadding = 0, | 
					
						
							|  |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							|  |  |  |  |       padding: EdgeInsets.symmetric( | 
					
						
							|  |  |  |  |         vertical: verticalPadding, | 
					
						
							|  |  |  |  |         horizontal: horizontalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Column( | 
					
						
							|  |  |  |  |         crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |  |         mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |  |         children: [ | 
					
						
							|  |  |  |  |           Text( | 
					
						
							|  |  |  |  |             text, | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |             style: TextStyle(fontSize: 13, color: Colors.grey), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |             softWrap: true, | 
					
						
							|  |  |  |  |             maxLines: null, // 允许无限行数
 | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-31 17:33:26 +08:00
										 |  |  |  |   ///  YesNo
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   static Widget createYesNoSection({ | 
					
						
							|  |  |  |  |     required String title, | 
					
						
							| 
									
										
										
										
											2025-08-11 17:40:03 +08:00
										 |  |  |  |     String yesLabel = '是', | 
					
						
							|  |  |  |  |     String noLabel = '否', | 
					
						
							| 
									
										
										
										
											2025-08-12 10:57:07 +08:00
										 |  |  |  |     required bool? groupValue, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |     required ValueChanged<bool> onChanged, | 
					
						
							|  |  |  |  |     double verticalPadding = 15, | 
					
						
							|  |  |  |  |     double horizontalPadding = 10, | 
					
						
							| 
									
										
										
										
											2025-08-12 10:57:07 +08:00
										 |  |  |  |     bool isEdit = true, | 
					
						
							|  |  |  |  |     String text = '', | 
					
						
							| 
									
										
										
										
											2025-08-14 15:05:48 +08:00
										 |  |  |  |     bool isRequired = false, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |       padding: EdgeInsets.only( | 
					
						
							|  |  |  |  |         top: 0, | 
					
						
							|  |  |  |  |         right: horizontalPadding, | 
					
						
							|  |  |  |  |         left: horizontalPadding, | 
					
						
							|  |  |  |  |         bottom: verticalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |       child: Container( | 
					
						
							| 
									
										
										
										
											2025-09-06 17:38:07 +08:00
										 |  |  |  |         padding: EdgeInsets.symmetric(horizontal: 10, vertical:  isEdit ? 0 : verticalPadding), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |         decoration: BoxDecoration( | 
					
						
							|  |  |  |  |           color: Colors.white, | 
					
						
							|  |  |  |  |           borderRadius: BorderRadius.circular(5), | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |         child: Row( | 
					
						
							|  |  |  |  |           children: [ | 
					
						
							|  |  |  |  |             Expanded( | 
					
						
							| 
									
										
										
										
											2025-08-14 15:05:48 +08:00
										 |  |  |  |               child: Row( | 
					
						
							|  |  |  |  |                 children: [ | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |                   if (isRequired && isEdit) | 
					
						
							|  |  |  |  |                     Text('* ', style: TextStyle(color: Colors.red)), | 
					
						
							|  |  |  |  |                   Expanded( | 
					
						
							|  |  |  |  |                     child: Text( | 
					
						
							|  |  |  |  |                       title, | 
					
						
							|  |  |  |  |                       style: TextStyle( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |                         fontSize: 13, | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |                         fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |                         color: Colors.black, | 
					
						
							|  |  |  |  |                       ), | 
					
						
							| 
									
										
										
										
											2025-08-14 15:05:48 +08:00
										 |  |  |  |                     ), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2025-08-14 15:05:48 +08:00
										 |  |  |  |                 ], | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2025-08-12 10:57:07 +08:00
										 |  |  |  |             if (isEdit) | 
					
						
							|  |  |  |  |               Row( | 
					
						
							|  |  |  |  |                 children: [ | 
					
						
							|  |  |  |  |                   Row( | 
					
						
							|  |  |  |  |                     children: [ | 
					
						
							|  |  |  |  |                       Radio<bool>( | 
					
						
							|  |  |  |  |                         activeColor: Colors.blue, | 
					
						
							|  |  |  |  |                         value: true, | 
					
						
							|  |  |  |  |                         groupValue: groupValue, | 
					
						
							|  |  |  |  |                         onChanged: (val) => onChanged(val!), | 
					
						
							|  |  |  |  |                       ), | 
					
						
							|  |  |  |  |                       Text(yesLabel), | 
					
						
							|  |  |  |  |                     ], | 
					
						
							|  |  |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2025-08-21 16:44:24 +08:00
										 |  |  |  |                   const SizedBox(width: 5), | 
					
						
							| 
									
										
										
										
											2025-08-12 10:57:07 +08:00
										 |  |  |  |                   Row( | 
					
						
							|  |  |  |  |                     children: [ | 
					
						
							|  |  |  |  |                       Radio<bool>( | 
					
						
							|  |  |  |  |                         activeColor: Colors.blue, | 
					
						
							|  |  |  |  |                         value: false, | 
					
						
							|  |  |  |  |                         groupValue: groupValue, | 
					
						
							|  |  |  |  |                         onChanged: (val) => onChanged(val!), | 
					
						
							|  |  |  |  |                       ), | 
					
						
							|  |  |  |  |                       Text(noLabel), | 
					
						
							|  |  |  |  |                     ], | 
					
						
							|  |  |  |  |                   ), | 
					
						
							|  |  |  |  |                 ], | 
					
						
							|  |  |  |  |               ), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |             if (!isEdit) Text(text, style: TextStyle()), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |           ], | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   /// 列表标题头(蓝色标识+文字)
 | 
					
						
							| 
									
										
										
										
											2025-08-12 10:57:07 +08:00
										 |  |  |  |   static Widget createBuildSimpleSection( | 
					
						
							|  |  |  |  |     String title, { | 
					
						
							|  |  |  |  |     double horPadding = 10, | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |     Color color = Colors.white, | 
					
						
							| 
									
										
										
										
											2025-08-12 10:57:07 +08:00
										 |  |  |  |   }) { | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |     return Container( | 
					
						
							|  |  |  |  |       decoration: BoxDecoration( | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |         color: color, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |         borderRadius: BorderRadius.circular(8), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Padding( | 
					
						
							| 
									
										
										
										
											2025-08-11 17:40:03 +08:00
										 |  |  |  |         padding: EdgeInsets.symmetric(horizontal: horPadding, vertical: 10), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |         child: Row( | 
					
						
							|  |  |  |  |           children: [ | 
					
						
							|  |  |  |  |             Container(width: 3, height: 15, color: Colors.blue), | 
					
						
							|  |  |  |  |             const SizedBox(width: 8), | 
					
						
							|  |  |  |  |             Text( | 
					
						
							|  |  |  |  |               title, | 
					
						
							|  |  |  |  |               style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ], | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |   /// 列表标题头(蓝色圆点+文字)
 | 
					
						
							|  |  |  |  |   static Widget createBlueDotSection( | 
					
						
							|  |  |  |  |       String title, | 
					
						
							|  |  |  |  |       {double horPadding = 10, | 
					
						
							|  |  |  |  |       int color=0xFFf1f1f1}) { | 
					
						
							|  |  |  |  |     return Container( | 
					
						
							|  |  |  |  |       decoration: BoxDecoration( | 
					
						
							|  |  |  |  |         color: Color(color), | 
					
						
							|  |  |  |  |         borderRadius: BorderRadius.circular(8), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Padding( | 
					
						
							|  |  |  |  |         padding: EdgeInsets.symmetric(horizontal: horPadding, vertical: 10), | 
					
						
							|  |  |  |  |         child: Row( | 
					
						
							|  |  |  |  |           children: [ | 
					
						
							|  |  |  |  |             Container( | 
					
						
							|  |  |  |  |               width: 7, | 
					
						
							|  |  |  |  |               height: 7, | 
					
						
							|  |  |  |  |               decoration: BoxDecoration( | 
					
						
							|  |  |  |  |                 color: Colors.blue, | 
					
						
							|  |  |  |  |                 borderRadius: BorderRadius.circular(180), | 
					
						
							|  |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |             const SizedBox(width: 8), | 
					
						
							|  |  |  |  |             Expanded( | 
					
						
							|  |  |  |  |               // 添加 Expanded
 | 
					
						
							|  |  |  |  |               child: Text( | 
					
						
							|  |  |  |  |                 title, | 
					
						
							|  |  |  |  |                 style: const TextStyle( | 
					
						
							|  |  |  |  |                   fontSize: 16, | 
					
						
							|  |  |  |  |                   fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ], | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-31 17:33:26 +08:00
										 |  |  |  |   /// 单纯标题
 | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |   static Widget headerTitle(String title, {bool isRequired = false}) { | 
					
						
							| 
									
										
										
										
											2025-07-31 17:33:26 +08:00
										 |  |  |  |     return Container( | 
					
						
							|  |  |  |  |       decoration: BoxDecoration( | 
					
						
							|  |  |  |  |         color: Colors.white, | 
					
						
							|  |  |  |  |         borderRadius: BorderRadius.circular(8), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: Row( | 
					
						
							|  |  |  |  |         children: [ | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |           if (isRequired) Text('* ', style: TextStyle(color: Colors.red)), | 
					
						
							| 
									
										
										
										
											2025-07-31 17:33:26 +08:00
										 |  |  |  |           Text( | 
					
						
							|  |  |  |  |             title, | 
					
						
							| 
									
										
										
										
											2025-09-06 17:38:07 +08:00
										 |  |  |  |             maxLines: 5, | 
					
						
							|  |  |  |  |             overflow: TextOverflow.ellipsis, | 
					
						
							| 
									
										
										
										
											2025-09-06 20:17:54 +08:00
										 |  |  |  |             style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold), | 
					
						
							| 
									
										
										
										
											2025-09-06 17:38:07 +08:00
										 |  |  |  |           ) | 
					
						
							| 
									
										
										
										
											2025-07-31 17:33:26 +08:00
										 |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   /// 扩展项(根据需求自定义)
 | 
					
						
							|  |  |  |  |   static Widget createCustomItem({ | 
					
						
							|  |  |  |  |     required Widget child, | 
					
						
							|  |  |  |  |     double verticalPadding = 15, | 
					
						
							|  |  |  |  |     double horizontalPadding = 0, | 
					
						
							|  |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							|  |  |  |  |       padding: EdgeInsets.symmetric( | 
					
						
							|  |  |  |  |         vertical: verticalPadding, | 
					
						
							|  |  |  |  |         horizontal: horizontalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |       child: child, | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |   /// 标题加输入框上下排列
 | 
					
						
							|  |  |  |  |   static Widget createBuildMultilineInput( | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |     String label, | 
					
						
							|  |  |  |  |     String hint, | 
					
						
							|  |  |  |  |     TextEditingController controller, { | 
					
						
							|  |  |  |  |     bool isRequired = false, | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  |  |     int inputNum=120, | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |   }) { | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |     return Container( | 
					
						
							|  |  |  |  |       height: 130, | 
					
						
							|  |  |  |  |       padding: const EdgeInsets.only(top: 8), | 
					
						
							|  |  |  |  |       child: Column( | 
					
						
							|  |  |  |  |         crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |  |         children: [ | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |           Row( | 
					
						
							|  |  |  |  |             children: [ | 
					
						
							|  |  |  |  |               if (isRequired) Text('* ', style: TextStyle(color: Colors.red)), | 
					
						
							|  |  |  |  |               // 标题
 | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |               Expanded( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |               child:HhTextStyleUtils.mainTitle(label, fontSize: 13), | 
					
						
							| 
									
										
										
										
											2025-08-15 17:11:26 +08:00
										 |  |  |  |               ), | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |             ], | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |           const SizedBox(height: 8), | 
					
						
							| 
									
										
										
										
											2025-07-31 17:33:26 +08:00
										 |  |  |  |           // 文本输入框,清除默认内边距以与标题左对齐
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |           Expanded( | 
					
						
							|  |  |  |  |             child: TextField( | 
					
						
							| 
									
										
										
										
											2025-07-28 14:22:07 +08:00
										 |  |  |  |               autofocus: false, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               controller: controller, | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  |  |               maxLength: inputNum, | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               keyboardType: TextInputType.multiline, | 
					
						
							|  |  |  |  |               maxLines: null, | 
					
						
							|  |  |  |  |               expands: true, | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |               style: const TextStyle(fontSize: 13), | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               decoration: InputDecoration( | 
					
						
							|  |  |  |  |                 hintText: hint, | 
					
						
							|  |  |  |  |                 border: InputBorder.none, | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |                 contentPadding: | 
					
						
							|  |  |  |  |                     isRequired | 
					
						
							|  |  |  |  |                         ? EdgeInsets.symmetric(horizontal: 10) | 
					
						
							|  |  |  |  |                         : EdgeInsets.zero, // 去除默认内边距
 | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ), | 
					
						
							|  |  |  |  |         ], | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-24 09:38:06 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  |   ///  分类头部
 | 
					
						
							|  |  |  |  |   static Widget createYesNoSectionTwo({ | 
					
						
							|  |  |  |  |     required String title, | 
					
						
							|  |  |  |  |     required String yesLabel, | 
					
						
							|  |  |  |  |     required String noLabel, | 
					
						
							|  |  |  |  |     required bool groupValue, | 
					
						
							|  |  |  |  |     required bool canClick, | 
					
						
							|  |  |  |  |     required BuildContext context, | 
					
						
							|  |  |  |  |     required ValueChanged<bool> onChanged, | 
					
						
							|  |  |  |  |     double verticalPadding = 15, | 
					
						
							|  |  |  |  |     double horizontalPadding = 10, | 
					
						
							|  |  |  |  |   }) { | 
					
						
							|  |  |  |  |     return Padding( | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |       padding: EdgeInsets.only( | 
					
						
							|  |  |  |  |         top: 0, | 
					
						
							|  |  |  |  |         right: horizontalPadding, | 
					
						
							|  |  |  |  |         left: horizontalPadding, | 
					
						
							|  |  |  |  |         bottom: verticalPadding, | 
					
						
							|  |  |  |  |       ), | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  |       child: Container( | 
					
						
							|  |  |  |  |         padding: EdgeInsets.symmetric(horizontal: 10), | 
					
						
							|  |  |  |  |         decoration: BoxDecoration( | 
					
						
							|  |  |  |  |           color: Colors.white, | 
					
						
							|  |  |  |  |           borderRadius: BorderRadius.circular(5), | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |         child: Row( | 
					
						
							|  |  |  |  |           children: [ | 
					
						
							|  |  |  |  |             Expanded( | 
					
						
							|  |  |  |  |               child: Text( | 
					
						
							|  |  |  |  |                 title, | 
					
						
							|  |  |  |  |                 style: TextStyle( | 
					
						
							| 
									
										
										
										
											2025-09-01 17:25:55 +08:00
										 |  |  |  |                   fontSize: 13, | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  |                   fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |  |                   color: Colors.black, | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |               ), | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |             Row( | 
					
						
							|  |  |  |  |               children: [ | 
					
						
							|  |  |  |  |                 Row( | 
					
						
							|  |  |  |  |                   children: [ | 
					
						
							|  |  |  |  |                     Radio<bool>( | 
					
						
							|  |  |  |  |                       activeColor: Colors.blue, | 
					
						
							|  |  |  |  |                       value: true, | 
					
						
							|  |  |  |  |                       groupValue: groupValue, | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |                       onChanged: (val) { | 
					
						
							|  |  |  |  |                         if (canClick) { | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  |                           onChanged(val!); | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |                         } else { | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  |                           ToastUtil.showNormal(context, "重大隐患不允许选此项"); | 
					
						
							|  |  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2025-08-07 17:33:16 +08:00
										 |  |  |  |                       }, | 
					
						
							| 
									
										
										
										
											2025-07-29 08:53:00 +08:00
										 |  |  |  |                       // (val) => onChanged(val!),
 | 
					
						
							|  |  |  |  |                     ), | 
					
						
							|  |  |  |  |                     Text(yesLabel), | 
					
						
							|  |  |  |  |                   ], | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |                 const SizedBox(width: 16), | 
					
						
							|  |  |  |  |                 Row( | 
					
						
							|  |  |  |  |                   children: [ | 
					
						
							|  |  |  |  |                     Radio<bool>( | 
					
						
							|  |  |  |  |                       activeColor: Colors.blue, | 
					
						
							|  |  |  |  |                       value: false, | 
					
						
							|  |  |  |  |                       groupValue: groupValue, | 
					
						
							|  |  |  |  |                       onChanged: (val) => onChanged(val!), | 
					
						
							|  |  |  |  |                     ), | 
					
						
							|  |  |  |  |                     Text(noLabel), | 
					
						
							|  |  |  |  |                   ], | 
					
						
							|  |  |  |  |                 ), | 
					
						
							|  |  |  |  |               ], | 
					
						
							|  |  |  |  |             ), | 
					
						
							|  |  |  |  |           ], | 
					
						
							|  |  |  |  |         ), | 
					
						
							|  |  |  |  |       ), | 
					
						
							|  |  |  |  |     ); | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-11 11:03:21 +08:00
										 |  |  |  | } |