Skip to content

Commit

Permalink
添加上一站 下一站按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
coldshineb committed Apr 6, 2024
1 parent 89b4dac commit 705eb20
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 11 deletions.
54 changes: 51 additions & 3 deletions lib/Pages/LCD/ArrivalFiveStations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ArrivalFiveStationsState extends State<ArrivalFiveStations> with LCD {

//背景图片字节数据
Uint8List? _imageBytes;

//背景纹理
Uint8List? pattern;

Expand All @@ -85,6 +86,7 @@ class ArrivalFiveStationsState extends State<ArrivalFiveStations> with LCD {

//运行方向,用于处理已到站与终点站为中间某一站时的线条显示,0为向左行,1为向右行
int trainDirectionValue = 1;

//是否显示原忆轨道交通品牌图标
bool showLogo = true;

Expand Down Expand Up @@ -206,6 +208,26 @@ class ArrivalFiveStationsState extends State<ArrivalFiveStations> with LCD {
},
value: terminusListValue,
),
Container(
height: 48,
child: MenuItemButton(
onPressed: previousStation,
child: const Text(
"上一站",
style: TextStyle(color: Colors.black),
),
),
),
Container(
height: 48,
child: MenuItemButton(
onPressed: nextStation,
child: const Text(
"下一站",
style: TextStyle(color: Colors.black),
),
),
),
Container(
padding: const EdgeInsets.only(top: 14),
child: const Text(
Expand Down Expand Up @@ -403,9 +425,9 @@ class ArrivalFiveStationsState extends State<ArrivalFiveStations> with LCD {
Container backgroundPattern() {
return pattern != null
? Container(
height: imageHeight,
width: imageWidth,
child: Image.memory(pattern!, repeat: ImageRepeat.repeat))
height: imageHeight,
width: imageWidth,
child: Image.memory(pattern!, repeat: ImageRepeat.repeat))
: Container();
}

Expand Down Expand Up @@ -1741,6 +1763,7 @@ class ArrivalFiveStationsState extends State<ArrivalFiveStations> with LCD {
});
}
}

//导入线路文件
@override
void importLineJson() async {
Expand Down Expand Up @@ -1954,4 +1977,29 @@ class ArrivalFiveStationsState extends State<ArrivalFiveStations> with LCD {
}
}
}

void nextStation() {
if (currentStationListIndex == stationList.length - 1 ||
currentStationListIndex == null) {
return;
} else {
setState(() {
currentStationListIndex = currentStationListIndex! + 1;
currentStationListValue =
stationList[currentStationListIndex!].stationNameCN;
});
}
}

void previousStation() {
if (currentStationListIndex == 0 || currentStationListIndex == null) {
return;
} else {
setState(() {
currentStationListIndex = currentStationListIndex! - 1;
currentStationListValue =
stationList[currentStationListIndex!].stationNameCN;
});
}
}
}
47 changes: 46 additions & 1 deletion lib/Pages/LCD/ArrivalLinearRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,27 @@ class ArrivalLinearRouteState extends State<ArrivalLinearRoute> with LCD {
}
},
value: terminusListValue,
)
),
Container(
height: 48,
child: MenuItemButton(
onPressed: previousStation,
child: const Text(
"上一站",
style: TextStyle(color: Colors.black),
),
),
),
Container(
height: 48,
child: MenuItemButton(
onPressed: nextStation,
child: const Text(
"下一站",
style: TextStyle(color: Colors.black),
),
),
),
])
],
),
Expand Down Expand Up @@ -949,4 +969,29 @@ class ArrivalLinearRouteState extends State<ArrivalLinearRoute> with LCD {
}
}
}

void nextStation() {
if (currentStationListIndex == stationList.length - 1 ||
currentStationListIndex == null) {
return;
} else {
setState(() {
currentStationListIndex = currentStationListIndex! + 1;
currentStationListValue =
stationList[currentStationListIndex!].stationNameCN;
});
}
}

void previousStation() {
if (currentStationListIndex == 0 || currentStationListIndex == null) {
return;
} else {
setState(() {
currentStationListIndex = currentStationListIndex! - 1;
currentStationListValue =
stationList[currentStationListIndex!].stationNameCN;
});
}
}
}
60 changes: 55 additions & 5 deletions lib/Pages/LCD/ArrivalStationInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {

//背景图片字节数据
Uint8List? _imageBytes;

//背景纹理
Uint8List? pattern;

Expand Down Expand Up @@ -90,10 +91,10 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {

//运行方向,用于处理已到站与终点站为中间某一站时的线条显示,0为向左行,1为向右行
int trainDirectionValue = 1;

//是否显示原忆轨道交通品牌图标
bool showLogo = true;


//默认导出宽度
int exportWidthValue = 2560;

Expand Down Expand Up @@ -214,6 +215,26 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {
},
value: terminusListValue,
),
Container(
height: 48,
child: MenuItemButton(
onPressed: previousStation,
child: const Text(
"上一站",
style: TextStyle(color: Colors.black),
),
),
),
Container(
height: 48,
child: MenuItemButton(
onPressed: nextStation,
child: const Text(
"下一站",
style: TextStyle(color: Colors.black),
),
),
),
])
],
),
Expand Down Expand Up @@ -594,14 +615,16 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {
return container;
}
}

Container backgroundPattern() {
return pattern != null
? Container(
height: imageHeight,
width: imageWidth,
child: Image.memory(pattern!, repeat: ImageRepeat.repeat))
height: imageHeight,
width: imageWidth,
child: Image.memory(pattern!, repeat: ImageRepeat.repeat))
: Container();
}

MenuBar importAndExportMenubar() {
return MenuBar(children: [
// Container(
Expand All @@ -623,7 +646,8 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {
style: TextStyle(color: Colors.black),
),
),
), Container(
),
Container(
height: 48,
child: MenuItemButton(
onPressed: importPattern,
Expand Down Expand Up @@ -717,6 +741,7 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {
});
}
}

//导入线路文件
@override
void importLineJson() async {
Expand Down Expand Up @@ -919,4 +944,29 @@ class ArrivalStationInfoState extends State<ArrivalStationInfo> with LCD {
}
}
}

void nextStation() {
if (currentStationListIndex == stationList.length - 1 ||
currentStationListIndex == null) {
return;
} else {
setState(() {
currentStationListIndex = currentStationListIndex! + 1;
currentStationListValue =
stationList[currentStationListIndex!].stationNameCN;
});
}
}

void previousStation() {
if (currentStationListIndex == 0 || currentStationListIndex == null) {
return;
} else {
setState(() {
currentStationListIndex = currentStationListIndex! - 1;
currentStationListValue =
stationList[currentStationListIndex!].stationNameCN;
});
}
}
}
48 changes: 46 additions & 2 deletions lib/Pages/LCD/RunningLinearRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,27 @@ class RunningLinearRouteState extends State<RunningLinearRoute> with LCD {
}
},
value: terminusListValue,
)
),
Container(
height: 48,
child: MenuItemButton(
onPressed: previousStation,
child: const Text(
"上一站",
style: TextStyle(color: Colors.black),
),
),
),
Container(
height: 48,
child: MenuItemButton(
onPressed: nextStation,
child: const Text(
"下一站",
style: TextStyle(color: Colors.black),
),
),
),
])
],
),
Expand Down Expand Up @@ -804,7 +824,8 @@ class RunningLinearRouteState extends State<RunningLinearRoute> with LCD {
child: Stack(
children: [
Widgets.transferLineIcon(transferLine),
Widgets.transferLineTextTwoCharactersStartsWithM(transferLine)
Widgets.transferLineTextTwoCharactersStartsWithM(
transferLine)
],
)));
}
Expand Down Expand Up @@ -1145,4 +1166,27 @@ class RunningLinearRouteState extends State<RunningLinearRoute> with LCD {
}
}
}

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;
});
}
}
}

0 comments on commit 705eb20

Please sign in to comment.