sample project
This commit is contained in:
@@ -10,6 +10,8 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:worker/core/constants/ui_constants.dart';
|
||||
import 'package:worker/core/router/app_router.dart';
|
||||
import 'package:worker/core/theme/colors.dart';
|
||||
import 'package:worker/features/showrooms/domain/entities/sample_project.dart';
|
||||
import 'package:worker/features/showrooms/presentation/providers/sample_project_provider.dart';
|
||||
|
||||
/// Model Houses Page
|
||||
///
|
||||
@@ -160,76 +162,94 @@ class _ModelHousesPageState extends ConsumerState<ModelHousesPage>
|
||||
}
|
||||
|
||||
/// Library Tab - Model house 360° library
|
||||
class _LibraryTab extends StatelessWidget {
|
||||
class _LibraryTab extends ConsumerWidget {
|
||||
const _LibraryTab();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
children: const [
|
||||
_LibraryCard(
|
||||
modelId: 'studio-01',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=800&h=200&fit=crop',
|
||||
title: 'Căn hộ Studio',
|
||||
date: '15/11/2024',
|
||||
description:
|
||||
'Thiết kế hiện đại cho căn hộ studio 35m², tối ưu không gian sống với gạch men cao cấp và màu sắc hài hòa.',
|
||||
has360View: true,
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final sampleProjectsAsync = ref.watch(sampleProjectsListProvider);
|
||||
|
||||
return sampleProjectsAsync.when(
|
||||
data: (projects) {
|
||||
if (projects.isEmpty) {
|
||||
return const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.home_work_outlined,
|
||||
size: 64,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Chưa có mẫu nhà nào',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => ref.read(sampleProjectsListProvider.notifier).refresh(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(20),
|
||||
itemCount: projects.length,
|
||||
itemBuilder: (context, index) {
|
||||
final project = projects[index];
|
||||
return _LibraryCard(project: project);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, stack) => Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: AppColors.danger,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Lỗi tải dữ liệu: ${error.toString().replaceAll('Exception: ', '')}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => ref.invalidate(sampleProjectsListProvider),
|
||||
child: const Text('Thử lại'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_LibraryCard(
|
||||
modelId: 'villa-01',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1570129477492-45c003edd2be?w=800&h=200&fit=crop',
|
||||
title: 'Biệt thự Hiện đại',
|
||||
date: '12/11/2024',
|
||||
description:
|
||||
'Biệt thự 3 tầng với phong cách kiến trúc hiện đại, sử dụng gạch granite và ceramic premium tạo điểm nhấn.',
|
||||
has360View: true,
|
||||
),
|
||||
_LibraryCard(
|
||||
modelId: 'townhouse-01',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1562663474-6cbb3eaa4d14?w=800&h=200&fit=crop',
|
||||
title: 'Nhà phố Tối giản',
|
||||
date: '08/11/2024',
|
||||
description:
|
||||
'Nhà phố 4x15m với thiết kế tối giản, tận dụng ánh sáng tự nhiên và gạch men màu trung tính.',
|
||||
has360View: true,
|
||||
),
|
||||
_LibraryCard(
|
||||
modelId: 'apartment-01',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?w=800&h=200&fit=crop',
|
||||
title: 'Chung cư Cao cấp',
|
||||
date: '05/11/2024',
|
||||
description:
|
||||
'Căn hộ 3PN với nội thất sang trọng, sử dụng gạch marble và ceramic cao cấp nhập khẩu Italy.',
|
||||
has360View: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Library Card Widget
|
||||
class _LibraryCard extends StatelessWidget {
|
||||
const _LibraryCard({
|
||||
required this.modelId,
|
||||
required this.imageUrl,
|
||||
required this.title,
|
||||
required this.date,
|
||||
required this.description,
|
||||
this.has360View = false,
|
||||
});
|
||||
const _LibraryCard({required this.project});
|
||||
|
||||
final String modelId;
|
||||
final String imageUrl;
|
||||
final String title;
|
||||
final String date;
|
||||
final String description;
|
||||
final bool has360View;
|
||||
final SampleProject project;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -239,7 +259,7 @@ class _LibraryCard extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(bottom: 20),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
context.push('/model-houses/$modelId');
|
||||
context.push('/model-houses/${project.id}');
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Column(
|
||||
@@ -252,28 +272,38 @@ class _LibraryCard extends StatelessWidget {
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(12),
|
||||
),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
width: double.infinity,
|
||||
height: 200,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => Container(
|
||||
height: 200,
|
||||
color: AppColors.grey100,
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
height: 200,
|
||||
color: AppColors.grey100,
|
||||
child: const Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 48,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: project.thumbnailUrl != null
|
||||
? CachedNetworkImage(
|
||||
imageUrl: project.thumbnailUrl!,
|
||||
width: double.infinity,
|
||||
height: 200,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => Container(
|
||||
height: 200,
|
||||
color: AppColors.grey100,
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
height: 200,
|
||||
color: AppColors.grey100,
|
||||
child: const Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 48,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: 200,
|
||||
color: AppColors.grey100,
|
||||
child: const Icon(
|
||||
Icons.home_work,
|
||||
size: 48,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (has360View)
|
||||
if (project.has360View)
|
||||
Positioned(
|
||||
top: 12,
|
||||
right: 12,
|
||||
@@ -307,7 +337,7 @@ class _LibraryCard extends StatelessWidget {
|
||||
children: [
|
||||
// Title
|
||||
Text(
|
||||
title,
|
||||
project.projectName,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -315,38 +345,20 @@ class _LibraryCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Date
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.calendar_today,
|
||||
size: 14,
|
||||
if (project.plainDescription.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
// Description
|
||||
Text(
|
||||
project.plainDescription,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
height: 1.5,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'Ngày đăng: $date',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Description
|
||||
Text(
|
||||
description,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
height: 1.5,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user