158 lines
3.8 KiB
Dart
158 lines
3.8 KiB
Dart
/// Domain Entity: Showroom
|
|
///
|
|
/// Represents a virtual showroom display.
|
|
library;
|
|
|
|
/// Showroom Entity
|
|
///
|
|
/// Contains information about a showroom:
|
|
/// - Showroom details and description
|
|
/// - Media (images, 360 view)
|
|
/// - Metadata (style, location, area)
|
|
/// - Visibility settings
|
|
class Showroom {
|
|
/// Unique showroom identifier
|
|
final String showroomId;
|
|
|
|
/// Showroom title
|
|
final String title;
|
|
|
|
/// Showroom description
|
|
final String? description;
|
|
|
|
/// Cover image URL
|
|
final String? coverImage;
|
|
|
|
/// 360-degree view link
|
|
final String? link360;
|
|
|
|
/// Showroom area (square meters)
|
|
final double? area;
|
|
|
|
/// Design style
|
|
final String? style;
|
|
|
|
/// Location/address
|
|
final String? location;
|
|
|
|
/// Gallery image URLs
|
|
final List<String> galleryImages;
|
|
|
|
/// View count
|
|
final int viewCount;
|
|
|
|
/// Showroom is featured
|
|
final bool isFeatured;
|
|
|
|
/// Showroom is active and visible
|
|
final bool isActive;
|
|
|
|
/// Publication timestamp
|
|
final DateTime? publishedAt;
|
|
|
|
/// User ID who created the showroom
|
|
final String? createdBy;
|
|
|
|
const Showroom({
|
|
required this.showroomId,
|
|
required this.title,
|
|
this.description,
|
|
this.coverImage,
|
|
this.link360,
|
|
this.area,
|
|
this.style,
|
|
this.location,
|
|
required this.galleryImages,
|
|
required this.viewCount,
|
|
required this.isFeatured,
|
|
required this.isActive,
|
|
this.publishedAt,
|
|
this.createdBy,
|
|
});
|
|
|
|
/// Check if showroom is published
|
|
bool get isPublished =>
|
|
publishedAt != null && DateTime.now().isAfter(publishedAt!);
|
|
|
|
/// Check if showroom has 360 view
|
|
bool get has360View => link360 != null && link360!.isNotEmpty;
|
|
|
|
/// Check if showroom has gallery
|
|
bool get hasGallery => galleryImages.isNotEmpty;
|
|
|
|
/// Get gallery size
|
|
int get gallerySize => galleryImages.length;
|
|
|
|
/// Check if showroom has cover image
|
|
bool get hasCoverImage => coverImage != null && coverImage!.isNotEmpty;
|
|
|
|
/// Get display image (cover or first gallery image)
|
|
String? get displayImage {
|
|
if (hasCoverImage) return coverImage;
|
|
if (hasGallery) return galleryImages.first;
|
|
return null;
|
|
}
|
|
|
|
/// Check if showroom can be viewed
|
|
bool get canBeViewed => isActive && isPublished;
|
|
|
|
/// Copy with method for immutability
|
|
Showroom copyWith({
|
|
String? showroomId,
|
|
String? title,
|
|
String? description,
|
|
String? coverImage,
|
|
String? link360,
|
|
double? area,
|
|
String? style,
|
|
String? location,
|
|
List<String>? galleryImages,
|
|
int? viewCount,
|
|
bool? isFeatured,
|
|
bool? isActive,
|
|
DateTime? publishedAt,
|
|
String? createdBy,
|
|
}) {
|
|
return Showroom(
|
|
showroomId: showroomId ?? this.showroomId,
|
|
title: title ?? this.title,
|
|
description: description ?? this.description,
|
|
coverImage: coverImage ?? this.coverImage,
|
|
link360: link360 ?? this.link360,
|
|
area: area ?? this.area,
|
|
style: style ?? this.style,
|
|
location: location ?? this.location,
|
|
galleryImages: galleryImages ?? this.galleryImages,
|
|
viewCount: viewCount ?? this.viewCount,
|
|
isFeatured: isFeatured ?? this.isFeatured,
|
|
isActive: isActive ?? this.isActive,
|
|
publishedAt: publishedAt ?? this.publishedAt,
|
|
createdBy: createdBy ?? this.createdBy,
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
|
|
return other is Showroom &&
|
|
other.showroomId == showroomId &&
|
|
other.title == title &&
|
|
other.style == style &&
|
|
other.isFeatured == isFeatured &&
|
|
other.isActive == isActive;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return Object.hash(showroomId, title, style, isFeatured, isActive);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'Showroom(showroomId: $showroomId, title: $title, style: $style, '
|
|
'area: $area, viewCount: $viewCount, isFeatured: $isFeatured, '
|
|
'isActive: $isActive)';
|
|
}
|
|
}
|