99 lines
2.6 KiB
Dart
99 lines
2.6 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,
|
|
),
|
|
),
|
|
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|