import 'package:vid/us/vid_us_unit.dart'; /// 测量项配置元信息 class ItemMeta { /// 名称 String name; /// 描述 String description; /// 简介注释 String briefAnnotation; /// 测量类型 String measureType; /// 计算输出元信息 List outputs; /// 子项元信息集合 List childItems; /// 多测量方法 List multiMethodItems; /// 当前测量项的购买状态 /// 0: Free 免费 /// 1: Probation 试用中 /// 2: Unpaid 未购买 /// 3: Purchased 已购买 /// /// 【TODO】 暂时屏蔽 buyStatus // WorkingItemStatusEnum? buyStatus; int? rimWidth; ItemMeta( this.name, { required this.measureType, required this.description, required this.outputs, // this.buyStatus, this.rimWidth, this.briefAnnotation = '', this.childItems = const [], this.multiMethodItems = const [], }); /// 根据名称获取子项 ItemMeta? getChildByName(String name) { final matchList = childItems.where((e) => e.name == name); if (matchList.isNotEmpty) { return matchList.first; } return null; } /// 根据类型获取子项 ItemMeta? getChildByType(String type) { final matchList = childItems.where((e) => e.measureType == type); if (matchList.isNotEmpty) { return matchList.first; } return null; } } class ItemOutputMeta { /// 名称 String name; /// 描述 String description; /// 单位 VidUsUnit unit; /// 简介注释 String? briefAnnotation; /// 额外注释 String? additionalAnnotation; /// 小数精度 int fractionalDigits; ItemOutputMeta( this.name, this.description, this.unit, { this.briefAnnotation, this.additionalAnnotation, this.fractionalDigits = 2, }); ItemOutputMeta copyWith({ String? name, String? description, VidUsUnit? unit, String? briefAnnotation, String? additionalAnnotation, int? fractionalDigits, }) { final meta = ItemOutputMeta( name ?? this.name, description ?? this.description, unit ?? this.unit, additionalAnnotation: additionalAnnotation ?? this.additionalAnnotation, fractionalDigits: fractionalDigits ?? this.fractionalDigits, ); return meta; } }