105 lines
3.1 KiB
Dart
105 lines
3.1 KiB
Dart
import '../motorcycle_image_service.dart' as unified;
|
|
|
|
/// Backward-compatible facade for older Garage imports.
|
|
///
|
|
/// Image resolution is implemented exclusively by the unified service in
|
|
/// `services/motorcycle_image_service.dart`; this facade exists temporarily so
|
|
/// existing callers/tests can migrate without maintaining a second registry.
|
|
class MotorcycleImageReference {
|
|
final String? assetPath;
|
|
final String? networkUrl;
|
|
final String? localFilePath;
|
|
final String caption;
|
|
final String attribution;
|
|
final bool isPhoto;
|
|
|
|
const MotorcycleImageReference({
|
|
this.assetPath,
|
|
this.networkUrl,
|
|
this.localFilePath,
|
|
required this.caption,
|
|
this.attribution = 'Technical Reference',
|
|
this.isPhoto = false,
|
|
});
|
|
|
|
bool get hasImage => assetPath != null || networkUrl != null || localFilePath != null;
|
|
}
|
|
|
|
class MotorcycleImageDescriptor extends unified.MotorcycleImageDescriptor {
|
|
const MotorcycleImageDescriptor({
|
|
required super.make,
|
|
required super.model,
|
|
super.exactYear,
|
|
super.minYear,
|
|
super.maxYear,
|
|
super.modelAliases,
|
|
required super.assetPath,
|
|
required super.caption,
|
|
super.attribution,
|
|
super.isPhoto,
|
|
});
|
|
}
|
|
|
|
/// Compatibility facade. New UI code should import the unified service.
|
|
class MotorcycleImageService {
|
|
static const MotorcycleImageService _instance = MotorcycleImageService._internal();
|
|
factory MotorcycleImageService() => _instance;
|
|
const MotorcycleImageService._internal();
|
|
|
|
static List<String> get bundledPhotographicAssets =>
|
|
unified.MotorcycleImageService.bundledPhotographicAssets;
|
|
|
|
static void registerDescriptor(MotorcycleImageDescriptor descriptor) {
|
|
unified.MotorcycleImageService.registerDescriptor(descriptor);
|
|
}
|
|
|
|
static void resetRegistry() {
|
|
unified.MotorcycleImageService.resetRegistry();
|
|
}
|
|
|
|
List<MotorcycleImageDescriptor> get allDescriptors =>
|
|
unified.MotorcycleImageService.instance.allDescriptors
|
|
.map((d) => MotorcycleImageDescriptor(
|
|
make: d.make,
|
|
model: d.model,
|
|
exactYear: d.exactYear,
|
|
minYear: d.minYear,
|
|
maxYear: d.maxYear,
|
|
modelAliases: d.modelAliases,
|
|
assetPath: d.assetPath,
|
|
caption: d.caption,
|
|
attribution: d.attribution,
|
|
isPhoto: d.isPhoto,
|
|
))
|
|
.toList();
|
|
|
|
MotorcycleImageReference getReferenceImage({
|
|
required String? make,
|
|
required String? model,
|
|
int? year,
|
|
}) {
|
|
final image = unified.MotorcycleImageService.instance.getReferenceImage(
|
|
make: make,
|
|
model: model,
|
|
year: year,
|
|
);
|
|
return MotorcycleImageReference(
|
|
assetPath: image.assetPath,
|
|
networkUrl: image.imageUrl,
|
|
caption: image.caption,
|
|
attribution: image.attribution,
|
|
isPhoto: image.isPhoto,
|
|
);
|
|
}
|
|
|
|
bool hasPhotographicAsset({
|
|
required String? make,
|
|
required String? model,
|
|
int? year,
|
|
}) => unified.MotorcycleImageService.instance.hasPhotographicAsset(
|
|
make: make,
|
|
model: model,
|
|
year: year,
|
|
);
|
|
}
|