154 lines
5.1 KiB
Dart
154 lines
5.1 KiB
Dart
|
import 'package:cpnav/pages/pass_track/view.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/widgets.dart';
|
||
|
|
||
|
class IconContainer extends StatefulWidget {
|
||
|
@override
|
||
|
_IconContainerState createState() => _IconContainerState();
|
||
|
}
|
||
|
|
||
|
class _IconContainerState extends State<IconContainer> {
|
||
|
final Map<IconData, Color> _iconColors = {
|
||
|
Icons.article: Colors.green,
|
||
|
Icons.speed: Colors.green,
|
||
|
Icons.thermostat: Colors.green,
|
||
|
Icons.zoom_in: Colors.green,
|
||
|
Icons.zoom_out: Colors.green,
|
||
|
Icons.refresh: Colors.green,
|
||
|
Icons.place: Colors.green,
|
||
|
};
|
||
|
|
||
|
void _handleTap(IconData icon, VoidCallback onTap) {
|
||
|
setState(() {
|
||
|
_iconColors[icon] = const Color.fromARGB(255, 166, 182, 149); // 点击后变浅的颜色
|
||
|
});
|
||
|
onTap();
|
||
|
Future.delayed(Duration(milliseconds: 200), () {
|
||
|
setState(() {
|
||
|
_iconColors[icon] = Colors.green; // 恢复原色
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
||
|
return isPortrait
|
||
|
? Positioned(
|
||
|
right: 10,
|
||
|
bottom: 130,
|
||
|
child: Column(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
Container(
|
||
|
width: 36,
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.transparent,
|
||
|
border: Border.all(
|
||
|
color: Color.fromARGB(255, 54, 52, 52),
|
||
|
width: 1.0,
|
||
|
),
|
||
|
borderRadius: BorderRadius.circular(5.0),
|
||
|
),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
_buildIcon(Icons.article, () {
|
||
|
mapcontroller.scale = 1.0;
|
||
|
mapcontroller.rotation.value = 0.0;
|
||
|
mapcontroller.updateCount.value++;
|
||
|
}),
|
||
|
_buildIcon(Icons.speed, () {
|
||
|
// 处理 speed 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.thermostat, () {
|
||
|
// 处理 thermostat 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.zoom_in, () {
|
||
|
// 处理 zoom_in 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.zoom_out, () {
|
||
|
// 处理 zoom_out 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.refresh, () {
|
||
|
// 处理 refresh 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.place, () {
|
||
|
// 处理 place 图标的点击事件
|
||
|
}),
|
||
|
],
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
))
|
||
|
: Positioned(
|
||
|
right: 10,
|
||
|
bottom: 15,
|
||
|
child: Row(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
Container(
|
||
|
height: 36,
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.transparent,
|
||
|
border: Border.all(
|
||
|
color: Color.fromARGB(255, 54, 52, 52),
|
||
|
width: 1.0,
|
||
|
),
|
||
|
borderRadius: BorderRadius.circular(5.0),
|
||
|
),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
_buildIcon(Icons.article, () {
|
||
|
mapcontroller.scale = 1.0;
|
||
|
mapcontroller.rotation.value = 0.0;
|
||
|
mapcontroller.updateCount.value++;
|
||
|
}),
|
||
|
_buildIcon(Icons.speed, () {
|
||
|
// 处理 speed 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.thermostat, () {
|
||
|
// 处理 thermostat 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.zoom_in, () {
|
||
|
// 处理 zoom_in 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.zoom_out, () {
|
||
|
// 处理 zoom_out 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.refresh, () {
|
||
|
// 处理 refresh 图标的点击事件
|
||
|
}),
|
||
|
_buildIcon(Icons.place, () {
|
||
|
// 处理 place 图标的点击事件
|
||
|
}),
|
||
|
],
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
));
|
||
|
}
|
||
|
|
||
|
Widget _buildIcon(IconData icon, VoidCallback onTap) {
|
||
|
return Container(
|
||
|
width: 30,
|
||
|
height: 30,
|
||
|
margin: EdgeInsets.symmetric(vertical: 2.0),
|
||
|
decoration: BoxDecoration(
|
||
|
color: _iconColors[icon],
|
||
|
border: Border.all(
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
borderRadius: BorderRadius.circular(5.0),
|
||
|
),
|
||
|
child: InkWell(
|
||
|
child: Icon(
|
||
|
icon,
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
onTap: () => _handleTap(icon, onTap),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|