127 lines
3.7 KiB
Dart
127 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../service/pile/device_type.dart';
|
|
import 'controller.dart';
|
|
|
|
class RealDeviceView extends GetView<RealDataController> {
|
|
const RealDeviceView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
DeviceType deviceType = getDeviceType(context);
|
|
final size = MediaQuery.of(context).size;
|
|
double imageW = size.width / 4 - 20;
|
|
double imageH = size.height - 40;
|
|
double rad = 0.10625;
|
|
// double distance = 0;
|
|
double hammerDis = 50; //
|
|
|
|
double hookDis = 30;
|
|
|
|
bool isMobile = deviceType != DeviceType.mobile ? false : true;
|
|
double lineTop = deviceType != DeviceType.mobile
|
|
? (rad * size.height).floorToDouble() - 45
|
|
: (rad / 2 * size.height).floorToDouble() - 45;
|
|
return Obx(() {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: Colors.black, width: 1),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
// 车
|
|
Positioned(
|
|
bottom: 45,
|
|
left: 0,
|
|
width: imageW,
|
|
height: imageH,
|
|
child: const Image(
|
|
image: AssetImage(
|
|
'images/mechinacs.png',
|
|
),
|
|
),
|
|
),
|
|
|
|
// 线
|
|
Positioned(
|
|
top: lineTop,
|
|
left: isMobile ? 35 : 32,
|
|
width: 3,
|
|
height: controller.lineDis.value,
|
|
child: CustomPaint(
|
|
painter: LinePainter(),
|
|
),
|
|
),
|
|
// 锤
|
|
Positioned(
|
|
left: isMobile ? 10 : 8,
|
|
top: lineTop + 110 + controller.distance.value,
|
|
width: 50,
|
|
height: hammerDis,
|
|
child: const Image(image: AssetImage('images/hammer.png')),
|
|
),
|
|
// 钩
|
|
Positioned(
|
|
top: lineTop + controller.lineDis.value,
|
|
left: isMobile ? 20 : 18,
|
|
width: 30,
|
|
height: hookDis,
|
|
child: const Image(
|
|
image: AssetImage('images/hook.png'),
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 20,
|
|
left: 35,
|
|
child: ElevatedButton(
|
|
style: ButtonStyle(
|
|
fixedSize: MaterialStateProperty.all(Size(200, 70)),
|
|
|
|
backgroundColor: MaterialStateProperty.all( const Color.fromARGB(255, 226, 220, 220))),
|
|
|
|
child: Text(
|
|
controller.isClick.value ? ' 暂停 ' : ' 开始 ',
|
|
style: TextStyle(fontSize: 28,
|
|
color:
|
|
controller.isClick.value ? Colors.red : Colors.green),
|
|
),
|
|
onPressed: () => {
|
|
controller.isClick.value = !controller.isClick.value,
|
|
},
|
|
),
|
|
)
|
|
// Positioned(
|
|
// bottom: 40,
|
|
// right: 30,
|
|
// child: ElevatedButton(
|
|
// child:
|
|
// const Text(" 暂停 ", style: TextStyle(color: Colors.red)),
|
|
// onPressed: () => null,
|
|
// ),
|
|
// )
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
class LinePainter extends CustomPainter {
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final paint = Paint()
|
|
..color = Colors.black
|
|
..strokeWidth = 3;
|
|
|
|
// 绘制一条从顶部到底部的直线
|
|
canvas.drawLine(Offset(0, 0), Offset(0, size.height), paint);
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
|
return false;
|
|
}
|
|
}
|