2 Commits 024748e01e ... a9796fbc11

Author SHA1 Message Date
  guanxinyi a9796fbc11 Merge branch 'master' of http://git.ius.plus:88/Project-Wing/Flyinsono 4 months ago
  guanxinyi 103b9e4aca 1、测量项的配置单独的单位 4 months ago

+ 110 - 0
lib/lab/components/control_panel_item/selector.dart

@@ -0,0 +1,110 @@
+import 'package:flutter/material.dart';
+import 'package:flyinsono/lab/color/lab_colors.dart';
+import 'package:fis_theme/theme.dart';
+import 'package:flyinsono/lab/style/lab_box_decoration.dart';
+
+// 下拉菜单-切换控制器
+class Selector<T> extends StatefulWidget {
+  const Selector({
+    super.key,
+    required this.values,
+    required this.textMap,
+    required this.currentValue,
+    this.onChanged,
+  });
+
+  final List<T> values;
+  final T currentValue;
+  final ValueChanged? onChanged;
+  final Map<T, String> textMap;
+
+  @override
+  State<Selector> createState() => _SelectorState<T>();
+}
+
+class _SelectorState<T> extends State<Selector> {
+  late T _currentValue;
+  List<T> values = [];
+
+  @override
+  void initState() {
+    super.initState();
+    _currentValue = (widget as Selector<T>).currentValue;
+    values = (widget as Selector<T>).values;
+  }
+
+  @override
+  void didUpdateWidget(Selector<T> oldWidget) {
+    super.didUpdateWidget(oldWidget);
+    if (widget.currentValue != _currentValue) {
+      _currentValue = widget.currentValue;
+    }
+    if (widget.values != values) {
+      values = (widget as Selector<T>).values;
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      // padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
+      decoration: BoxDecoration(
+        color: LabColors.base400,
+        borderRadius: BorderRadius.circular(3),
+        border: Border.all(
+          color: LabColors.base400,
+          width: 1,
+        ),
+      ),
+      child: Container(
+        height: 40,
+        child: Container(
+          padding: const EdgeInsets.only(left: 4),
+          decoration: LabBoxDecoration.operatePanel.copyWith(
+            color: LabColors.base400,
+          ),
+          child: DropdownButtonHideUnderline(
+            child: DropdownButton<T>(
+                value: _currentValue,
+                itemHeight: 50,
+                dropdownColor: LabColors.base400,
+                icon: Icon(
+                  Icons.keyboard_arrow_down_rounded,
+                  color: LabColors.base800,
+                ),
+                style: TextStyle(
+                  fontSize: 14,
+                  color: LabColors.text800,
+                  fontFamily: FTheme.ins.localeSetting.fontFamily,
+                ),
+                isExpanded: true,
+                elevation: 2,
+                items: values.map((T dataSource) {
+                  return DropdownMenuItem<T>(
+                    value: dataSource,
+                    child: Text(
+                      typeToString(dataSource),
+                      overflow: TextOverflow.ellipsis,
+                      maxLines: 1,
+                    ),
+                  );
+                }).toList(),
+                onChanged: (value) {
+                  if (value != null) {
+                    setState(() {
+                      _currentValue = value;
+                    });
+                    widget.onChanged?.call(value);
+                  }
+                }),
+          ),
+        ),
+      ),
+    );
+  }
+
+  String typeToString(T type) {
+    // 查询 map 获取对应的文本
+    return widget.textMap[type] ?? "";
+  }
+}

+ 34 - 8
lib/lab/pages/lab_image/widgets/image_operate_panel/widgets/measure_config/change_config_settings.dart

@@ -8,8 +8,11 @@ import 'package:flutter/material.dart';
 import 'package:flyinsono/architecture/define.dart';
 import 'package:flyinsono/architecture/utils/prompt_box.dart';
 import 'package:flyinsono/lab/color/lab_colors.dart';
+import 'package:flyinsono/lab/components/control_panel_item/selector.dart';
 import 'package:flyinsono/lab/pages/lab_image/controller.dart';
 import 'package:flyinsono/lab/pages/lab_record_info/widgets/alert_dialog.dart';
+import 'package:vid/us/vid_us_unit.dart';
+import 'package:fis_measure/values/unit_desc.dart';
 
 import 'package:get/get.dart';
 
@@ -544,7 +547,15 @@ class _DialogPageState extends State<_DialogPage> {
   }
 
   FWidget _buildUnitItem(
-      String name, OutputItemMetaDTO outputItemMeta, bool isCanClick) {
+    String name,
+    OutputItemMetaDTO outputItemMeta,
+    bool isCanClick,
+  ) {
+    Map<int, String> unitsMap = {};
+    outputItemMeta.units?.forEach((element) {
+      unitsMap.putIfAbsent(element,
+          () => UnitDescriptionMap.getDesc(VidUsUnitMap.getUnit(element)));
+    });
     return FGestureDetector(
       name: name,
       businessParent: widget.parent,
@@ -566,20 +577,35 @@ class _DialogPageState extends State<_DialogPage> {
             color: FTheme.ins.colorScheme.line,
           ),
         ),
-        child: FCenter(
-          child: FColumn(
-            mainAxisAlignment: MainAxisAlignment.center,
-            children: [
-              FText(
+        child: FRow(
+          mainAxisAlignment: MainAxisAlignment.spaceAround,
+          children: [
+            FExpanded(
+              child: FText(
                 name,
+                textAlign: TextAlign.center,
                 style: TextStyle(
                   color: outputItemMeta.isWorking ?? false
                       ? LabColors.text100
                       : LabColors.text700,
                 ),
               ),
-            ],
-          ),
+            ),
+            if (outputItemMeta.unit != 0)
+              QuickFWidget(
+                Container(
+                  width: 70,
+                  child: Selector<int>(
+                    values: outputItemMeta.units ?? [],
+                    textMap: unitsMap,
+                    currentValue: outputItemMeta.unit,
+                    onChanged: (value) {
+                      outputItemMeta.unit = value;
+                    },
+                  ),
+                ),
+              )
+          ],
         ),
       ),
     );

+ 3 - 3
pubspec.yaml

@@ -100,7 +100,7 @@ dependency_overrides:
   fis_measure:
     git:
       url: http://git.ius.plus/Project-Wing/fis_lib_measure.git
-      ref: 'e52baa9'
+      ref: '9958bd8'
     # path: ../fis_lib_measure
     # path: ../fis_packages/fis_lib_measure
   fis_lib_report:
@@ -148,7 +148,7 @@ dependency_overrides:
   fis_jsonrpc:
     git:
       url: http://git.ius.plus:88/Project-Wing/fis_lib_jsonrpc.git
-      ref: dff040d
+      ref: 2a45e13
     # path: ../../fis_lib_jsonrpc
   fis_theme:
     git:
@@ -161,7 +161,7 @@ dependency_overrides:
   vid:
     git:
       url: http://git.ius.plus:88/Project-Wing/flutter_vid
-      ref: ba7f064d04
+      ref: 1feed85
   fis_vid:
     git:
       url: http://git.ius.plus/Project-Wing/fis_lib_vid.git