96 lines
2.5 KiB
Dart
96 lines
2.5 KiB
Dart
/// Domain Entity: Sample Project
|
|
///
|
|
/// Represents a sample/model house project with 360° view.
|
|
/// Based on API response from building_material.building_material.api.sample_project
|
|
library;
|
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
/// Project File Entity
|
|
///
|
|
/// Shared entity for file attachments used by:
|
|
/// - SampleProject (model houses)
|
|
/// - DesignRequest (design requests)
|
|
///
|
|
/// API field mapping:
|
|
/// - name -> id
|
|
/// - file_url -> fileUrl
|
|
class ProjectFile extends Equatable {
|
|
/// Unique file identifier (API: name)
|
|
final String id;
|
|
|
|
/// Full URL to the file (API: file_url)
|
|
final String fileUrl;
|
|
|
|
const ProjectFile({
|
|
required this.id,
|
|
required this.fileUrl,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [id, fileUrl];
|
|
}
|
|
|
|
/// Sample Project Entity
|
|
///
|
|
/// Contains information about a model house/sample project.
|
|
/// API field mapping:
|
|
/// - name -> id
|
|
/// - project_name -> projectName
|
|
/// - notes -> description (HTML content)
|
|
/// - link -> viewUrl (360° viewer URL)
|
|
/// - thumbnail -> thumbnailUrl
|
|
/// - files_list -> filesList (detail only)
|
|
class SampleProject extends Equatable {
|
|
/// Unique project identifier (API: name)
|
|
final String id;
|
|
|
|
/// Project display name (API: project_name)
|
|
final String projectName;
|
|
|
|
/// Project description/notes - may contain HTML (API: notes)
|
|
final String? description;
|
|
|
|
/// URL to 360° view (API: link)
|
|
final String? viewUrl;
|
|
|
|
/// Thumbnail image URL (API: thumbnail)
|
|
final String? thumbnailUrl;
|
|
|
|
/// List of attached files/images (API: files_list) - available in detail
|
|
final List<ProjectFile> filesList;
|
|
|
|
const SampleProject({
|
|
required this.id,
|
|
required this.projectName,
|
|
this.description,
|
|
this.viewUrl,
|
|
this.thumbnailUrl,
|
|
this.filesList = const [],
|
|
});
|
|
|
|
/// Check if project has 360° view available
|
|
bool get has360View => viewUrl != null && viewUrl!.isNotEmpty;
|
|
|
|
/// Get plain text description (strips HTML tags)
|
|
String get plainDescription {
|
|
if (description == null) return '';
|
|
// Simple HTML tag removal
|
|
return description!
|
|
.replaceAll(RegExp(r'<[^>]*>'), '')
|
|
.replaceAll(' ', ' ')
|
|
.trim();
|
|
}
|
|
|
|
/// Get all image URLs for gallery (from filesList)
|
|
List<String> get imageUrls => filesList.map((f) => f.fileUrl).toList();
|
|
|
|
@override
|
|
List<Object?> get props => [id, projectName, description, viewUrl, thumbnailUrl, filesList];
|
|
|
|
@override
|
|
String toString() {
|
|
return 'SampleProject(id: $id, projectName: $projectName, has360View: $has360View, filesCount: ${filesList.length})';
|
|
}
|
|
}
|