gnssview_old/lib/sky/skyInfo.dart

121 lines
3.8 KiB
Dart
Raw Permalink Normal View History

2024-07-30 18:20:27 +08:00
import 'package:flutter/material.dart';
2024-07-31 19:04:11 +08:00
import 'package:get/get.dart';
2024-07-30 18:20:27 +08:00
import 'package:gnssview/sky/device_type.dart';
2024-07-31 19:04:11 +08:00
import '../Controller/gnssController.dart';
2024-07-30 18:20:27 +08:00
import 'mulbutton.dart';
class SkyInfo extends StatelessWidget {
2024-07-31 19:04:11 +08:00
late GnssController controller;
// final String lat; // 纬度
// final String lon; // 经度
// final String hdop; // 高程
// final int status; // 定位状态
// final int view; // 可见
// final int use; // 使用
// final String time; // 时间
2024-07-30 18:20:27 +08:00
2024-07-31 19:04:11 +08:00
SkyInfo() {
controller = Get.find<GnssController>(tag: 'gnss');
}
2024-07-30 18:20:27 +08:00
@override
Widget build(BuildContext context) {
final isPortrait =
MediaQuery.of(context).orientation == Orientation.portrait;
return Theme(
data: ThemeData(
textTheme: const TextTheme(
titleLarge: TextStyle(
fontSize: 30,
fontWeight: FontWeight.normal,
),
),
),
child: Container(
margin: const EdgeInsets.only(left: 5),
padding: const EdgeInsets.symmetric(vertical: 20),
alignment: Alignment.centerLeft,
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
// 创建行项的函数
2024-07-31 19:04:11 +08:00
rowItem(context, "北纬:", '${controller.locationData?.latitude} '),
rowItem(context, "东经:", '${controller.locationData?.longitude}'),
rowItem(context, "高程:", '${controller.locationData?.altitude}'),
rowItem(context, "水平定位精度:", '${controller.locationData?.hdop}'),
rowItem(context, "垂直定位精度:", '${controller.locationData?.vdop}'),
rowItem(context, "定位状态:", '${controller.locationData?.fixQuality}'),
rowItem(context, "可见卫星数:", '${controller.locationData?.numberSv}'),
rowItem(context, "使用卫星数:", '${controller.locationData?.numberSa}'),
rowItem(context, "时间:", '${controller.locationData?.time}'),
2024-07-30 18:20:27 +08:00
Row(
2024-07-31 19:04:11 +08:00
mainAxisAlignment: MainAxisAlignment.center,
2024-07-30 18:20:27 +08:00
children: [
MulButton(
colors: const [
Colors.blue,
Colors.red,
Colors.green,
Colors.orange
],
onSelectionChanged: (selectedColors) {
// 处理选中的颜色
print('选中的颜色: $selectedColors');
},
),
],
),
]),
));
}
Widget rowItem(BuildContext context, String title, String text) => Row(
children: [
FixedWidthTextWidget(
width: 80,
text: title,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
text,
style: Theme.of(context).textTheme.titleLarge,
),
],
);
}
class FixedWidthTextWidget extends StatelessWidget {
final String text;
final double width;
final TextStyle? style;
FixedWidthTextWidget({
super.key,
required this.text,
this.width = 80,
this.style,
});
TextStyle? textStyle;
@override
Widget build(BuildContext context) {
final deviceType = getDeviceType(context);
double dynamicWidth = deviceType == DeviceType.mobile ? 0 : 50;
if (style != null) {
textStyle =
style!.copyWith(fontSize: deviceType == DeviceType.mobile ? 16 : 20);
} else {
textStyle =
TextStyle(fontSize: deviceType == DeviceType.mobile ? 16 : 20);
}
return Container(
margin: const EdgeInsets.symmetric(horizontal: 3),
width: width + dynamicWidth,
child: Text(
text,
style: textStyle,
),
);
}
}