From 61955acaee3a3ab285eb1c98a3e23bd75180689a Mon Sep 17 00:00:00 2001 From: coldshineb Date: Sun, 17 Nov 2024 06:24:54 -0500 Subject: [PATCH] =?UTF-8?q?led=E7=BA=BF=E8=B7=AF=E5=9B=BE=E4=B8=BB?= =?UTF-8?q?=E4=BD=93=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RailwayTransit/LEDRouteMap.dart | 233 +----------------- 1 file changed, 11 insertions(+), 222 deletions(-) diff --git a/lib/Pages/ImageMaker/RailwayTransit/LEDRouteMap.dart b/lib/Pages/ImageMaker/RailwayTransit/LEDRouteMap.dart index da6da98..ac505f5 100644 --- a/lib/Pages/ImageMaker/RailwayTransit/LEDRouteMap.dart +++ b/lib/Pages/ImageMaker/RailwayTransit/LEDRouteMap.dart @@ -54,7 +54,6 @@ class LEDRouteMapState extends State final GlobalKey _passingImageKey = GlobalKey(); final GlobalKey _directionImageKey = GlobalKey(); final GlobalKey _passedImageKey = GlobalKey(); - final GlobalKey _passedFullImageKey = GlobalKey(); //背景图片字节数据 Uint8List? _imageBytes; @@ -71,13 +70,6 @@ class LEDRouteMapState extends State //线路颜色和颜色变体,默认透明,导入文件时赋值 Color lineColor = Colors.transparent; - //站名下拉菜单默认值,设空,导入文件时赋值 - String? nextStationListValue; - String? terminusListValue; - - //站名下拉菜单默认索引,用于找到下拉菜单选择的站名所对应的英文站名,设空,下拉选择站名时赋值 - int? nextStationListIndex; - //是否显示原忆轨道交通品牌图标 bool showLogo = true; @@ -118,65 +110,7 @@ class LEDRouteMapState extends State Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - importAndExportMenubar(), - MenuBar(style: menuStyle(context), children: [ - Container( - padding: const EdgeInsets.only(top: 14, left: 7), - child: const Text("下一站"), - ), - DropdownButton( - disabledHint: const Text( - "下一站", - style: TextStyle(color: Colors.grey, fontSize: 14), - ), //设置空时的提示文字 - items: showStationList(stationList), - onChanged: (value) { - try { - nextStationListIndex = stationList.indexWhere( - (element) => - element.stationNameCN == - value); //根据选择的站名,找到站名集合中对应的索引 - nextStationListValue = value; - setState(() {}); - } catch (e) { - print(e); - } - }, - value: nextStationListValue, - ), - Container( - height: 48, - child: MenuItemButton( - onPressed: previousStation, - child: const Text("上一站"), - ), - ), - Container( - height: 48, - child: MenuItemButton( - onPressed: nextStation, - child: const Text("下一站"), - ), - ), - Container( - height: 48, - child: MenuItemButton( - onPressed: () { - setState(() { - if (stationList.isNotEmpty) { - stationList = stationList.reversed.toList(); - transferLineList = - transferLineList.reversed.toList(); - nextStationListIndex = stationList.length - - 1 - - nextStationListIndex!; //反转站点索引 - } - }); - }, - child: const Text("反转站点"), - ), - ), - ]) + importAndExportMenubar() ], ), Expanded( @@ -204,9 +138,6 @@ class LEDRouteMapState extends State stationList.clear(); transferLineList.clear(); lineColor = Colors.transparent; - nextStationListIndex = null; - nextStationListValue = null; - terminusListValue = null; lineNumber = ""; lineNumberEN = ""; setState(() {}); @@ -329,25 +260,6 @@ class LEDRouteMapState extends State //已过站图 RepaintBoundary( key: _passedImageKey, - child: Container( - color: Colors.transparent, - child: Stack( - children: [ - const SizedBox( - width: imageWidth, - height: imageHeight, - ), - Container( - padding: const EdgeInsets.fromLTRB(50, 202.5, 0, 0), - child: showPassedStationIcon(), - ), - ], - ), - ), - ), - //已过站图(全程) - RepaintBoundary( - key: _passedFullImageKey, child: Container( color: Colors.transparent, child: Stack( @@ -396,13 +308,6 @@ class LEDRouteMapState extends State child: const Text("导出全部图"), ), ), - Container( - height: 48, - child: MenuItemButton( - onPressed: exportDynamicImage, - child: const Text("导出当前站全部图"), - ), - ), const VerticalDivider(), Container( height: 48, @@ -432,13 +337,6 @@ class LEDRouteMapState extends State child: const Text("导出已过站图"), ), ), - Container( - height: 48, - child: MenuItemButton( - onPressed: exportPassedFullImage, - child: const Text("导出已过站(全程)图"), - ), - ), Container( padding: const EdgeInsets.only(top: 14), child: const Text("导出分辨率"), @@ -528,15 +426,10 @@ class LEDRouteMapState extends State //显示正在过站图标 Stack showPassingRouteIcon() { List tempList = []; - if (nextStationListIndex != null) { + for (int i = 0; i < stationList.length; i++) { tempList.add(Container( padding: EdgeInsets.fromLTRB( - 10 + - (lineLength / (stationList.length - 1)) * - nextStationListIndex!, - 0, - 0, - 0), + 10 + (lineLength / (stationList.length - 1)) * i, 0, 0, 0), child: CustomPaint( painter: LEDRouteMapStationIconPainter(Colors.orange, lineColor, 8, 2), @@ -547,37 +440,6 @@ class LEDRouteMapState extends State ); } - //显示已过站图标 - Stack showPassedStationIcon() { - List iconList = []; - if (nextStationListIndex != null) { - for (int i = 0; i < 4 * (nextStationListIndex! - 1); i++) { - iconList.add(Container( - padding: EdgeInsets.fromLTRB( - 10 + (lineLength / (4 * (stationList.length - 1))) * i, - 0, - 0, - 0), - child: CustomPaint( - painter: - LEDRouteMapStationIconPainter(Colors.red, lineColor, 5, 1), - ))); - } - for (int i = 0; i < nextStationListIndex!; i++) { - iconList.add(Container( - padding: EdgeInsets.fromLTRB( - 10 + (lineLength / (stationList.length - 1)) * i, 0, 0, 0), - child: CustomPaint( - painter: - LEDRouteMapStationIconPainter(Colors.red, lineColor, 8, 2), - ))); - } - } - return Stack( - children: iconList, - ); - } - //显示换乘线路图标 Stack showTransferIcon() { List iconList = []; @@ -756,7 +618,6 @@ class LEDRouteMapState extends State //清空或重置可能空或导致显示异常的变量,只有文件格式验证无误后才清空 stationList.clear(); transferLineList.clear(); - nextStationListIndex = 0; //会导致显示的是前一个索引对应的站点 // 设置线路颜色 lineNumber = jsonData['lineNumber']; @@ -788,9 +649,6 @@ class LEDRouteMapState extends State stationList.add(station); } - //文件成功导入后将下拉菜单默认值设为第一站 - nextStationListValue = stationList[0].stationNameCN; - terminusListValue = stationList[stationList.length - 1].stationNameCN; // 刷新页面状态 setState(() {}); } else if (stationsFromJson.length < 2) { @@ -815,34 +673,12 @@ class LEDRouteMapState extends State await exportImage(context, stationList, _directionImageKey, "$path${Util.pathSlash}方向指示.png", true, exportWidthValue: exportWidthValue); - await exportImage(context, stationList, _passedFullImageKey, - "$path${Util.pathSlash}已过站 全程.png", true, + await exportImage(context, stationList, _passingImageKey, + "$path${Util.pathSlash}下一站.png", true, + exportWidthValue: exportWidthValue); + await exportImage(context, stationList, _passedImageKey, + "$path${Util.pathSlash}已过站.png", true, exportWidthValue: exportWidthValue); - for (int i = 0; i < stationList.length; i++) { - nextStationListIndex = i; - setState(() {}); - await exportImage( - context, - stationList, - _passingImageKey, - "$path${Util.pathSlash}下一站 ${nextStationListIndex! + 1} ${stationList[nextStationListIndex!].stationNameCN}.png", - true, - exportWidthValue: exportWidthValue); - await exportImage( - context, - stationList, - _passingImageKey, - "$path${Util.pathSlash}下一站 ${nextStationListIndex! + 1} ${stationList[nextStationListIndex!].stationNameCN}.png", - true, - exportWidthValue: exportWidthValue); - await exportImage( - context, - stationList, - _passedImageKey, - "$path${Util.pathSlash}已过站 ${nextStationListIndex! + 1} ${stationList[nextStationListIndex!].stationNameCN}.png", - true, - exportWidthValue: exportWidthValue); - } } ScaffoldMessenger.of(context).showSnackBar(SnackBar( margin: const EdgeInsets.all(10.0), @@ -854,18 +690,6 @@ class LEDRouteMapState extends State } } - //导出当前站全部图 - Future exportDynamicImage() async { - if (stationList.isNotEmpty) { - await exportMainImage(); - await exportDirectionImage(); - await exportPassingImage(); - await exportPassedImage(); - } else { - noStationsSnackbar(context); - } - } - //导出主线路图 Future exportMainImage() async { if (stationList.isNotEmpty) { @@ -893,7 +717,7 @@ class LEDRouteMapState extends State Future exportPassingImage() async { if (stationList.isNotEmpty) { String fileName = - "下一站 ${nextStationListIndex! + 1} $nextStationListValue.png"; + "下一站.png"; await exportImage(context, stationList, _passingImageKey, fileName, false, exportWidthValue: exportWidthValue); } else { @@ -904,47 +728,12 @@ class LEDRouteMapState extends State //导出已过站图 Future exportPassedImage() async { if (stationList.isNotEmpty) { - String fileName = - "已过站 ${nextStationListIndex! + 1} $nextStationListValue.png"; - await exportImage(context, stationList, _passedImageKey, fileName, false, - exportWidthValue: exportWidthValue); - } else { - noStationsSnackbar(context); - } - } - - //导出已过站(全程)图 - Future exportPassedFullImage() async { - if (stationList.isNotEmpty) { - String fileName = "已过站 全程.png"; + String fileName = "已过站.png"; await exportImage( - context, stationList, _passedFullImageKey, fileName, false, + context, stationList, _passedImageKey, fileName, false, exportWidthValue: exportWidthValue); } else { noStationsSnackbar(context); } } - - void nextStation() { - if (nextStationListIndex == stationList.length - 1 || - nextStationListIndex == null) { - return; - } else { - setState(() { - nextStationListIndex = nextStationListIndex! + 1; - nextStationListValue = stationList[nextStationListIndex!].stationNameCN; - }); - } - } - - void previousStation() { - if (nextStationListIndex == 0 || nextStationListIndex == null) { - return; - } else { - setState(() { - nextStationListIndex = nextStationListIndex! - 1; - nextStationListValue = stationList[nextStationListIndex!].stationNameCN; - }); - } - } }