Add FunctionType enum and ValueModel class

- Added FunctionType enum with values Boolean, Enum, Integer, Raw, String.
- Introduced ValueModel class to handle unit, min, max, scale, and step values
  for functions in FunctionModel.
This commit is contained in:
Mohammad Salameh
2024-04-21 16:13:51 +03:00
parent c97e2715f7
commit 506068474b
2 changed files with 137 additions and 37 deletions

View File

@ -1,7 +1,9 @@
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class FunctionModel {
String? code;
String? type;
String? values;
FunctionType? type;
ValueModel? values;
FunctionModel({
required this.code,
@ -25,3 +27,41 @@ class FunctionModel {
};
}
}
//"values": "{\"unit\":\"\",\"min\":1,\"max\":10,\"scale\":0,\"step\":1}",
class ValueModel {
String? unit;
int? min;
int? max;
int? scale;
int? step;
ValueModel({
required this.unit,
required this.min,
required this.max,
required this.scale,
required this.step,
});
factory ValueModel.fromJson(Map<String, dynamic> json) {
return ValueModel(
unit: json['unit'],
min: json['min'],
max: json['max'],
scale: json['scale'],
step: json['step'],
);
}
Map<String, dynamic> toJson() {
return {
'unit': unit,
'min': min,
'max': max,
'scale': scale,
'step': step,
};
}
}