import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:gnssview/sky/device_type.dart'; import '../Controller/gnssController.dart'; import 'mulbutton.dart'; class SkyInfo extends StatelessWidget { late GnssController controller; // final String lat; // 纬度 // final String lon; // 经度 // final String hdop; // 高程 // final int status; // 定位状态 // final int view; // 可见 // final int use; // 使用 // final String time; // 时间 SkyInfo() { controller = Get.find(tag: 'gnss'); } @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: [ // 创建行项的函数 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}'), Row( mainAxisAlignment: MainAxisAlignment.center, 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, ), ); } }