premier app version beta
This commit is contained in:
84
lib/data/models/target.dart
Normal file
84
lib/data/models/target.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'target_type.dart';
|
||||
|
||||
class Target {
|
||||
final String id;
|
||||
final TargetType type;
|
||||
final String imagePath;
|
||||
final DateTime createdAt;
|
||||
|
||||
// Detected target bounds (relative coordinates 0.0-1.0)
|
||||
final double? centerX;
|
||||
final double? centerY;
|
||||
final double? radius; // For concentric targets
|
||||
final double? width; // For silhouette targets
|
||||
final double? height; // For silhouette targets
|
||||
|
||||
Target({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.imagePath,
|
||||
required this.createdAt,
|
||||
this.centerX,
|
||||
this.centerY,
|
||||
this.radius,
|
||||
this.width,
|
||||
this.height,
|
||||
});
|
||||
|
||||
Target copyWith({
|
||||
String? id,
|
||||
TargetType? type,
|
||||
String? imagePath,
|
||||
DateTime? createdAt,
|
||||
double? centerX,
|
||||
double? centerY,
|
||||
double? radius,
|
||||
double? width,
|
||||
double? height,
|
||||
}) {
|
||||
return Target(
|
||||
id: id ?? this.id,
|
||||
type: type ?? this.type,
|
||||
imagePath: imagePath ?? this.imagePath,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
centerX: centerX ?? this.centerX,
|
||||
centerY: centerY ?? this.centerY,
|
||||
radius: radius ?? this.radius,
|
||||
width: width ?? this.width,
|
||||
height: height ?? this.height,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'type': type.name,
|
||||
'image_path': imagePath,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'center_x': centerX,
|
||||
'center_y': centerY,
|
||||
'radius': radius,
|
||||
'width': width,
|
||||
'height': height,
|
||||
};
|
||||
}
|
||||
|
||||
factory Target.fromMap(Map<String, dynamic> map) {
|
||||
return Target(
|
||||
id: map['id'] as String,
|
||||
type: TargetType.fromString(map['type'] as String),
|
||||
imagePath: map['image_path'] as String,
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
centerX: map['center_x'] as double?,
|
||||
centerY: map['center_y'] as double?,
|
||||
radius: map['radius'] as double?,
|
||||
width: map['width'] as double?,
|
||||
height: map['height'] as double?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Target(id: $id, type: $type, imagePath: $imagePath, createdAt: $createdAt)';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user