request detail
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -442,7 +442,7 @@ class ModelHouseDetailPage extends ConsumerWidget {
|
||||
|
||||
void _showImageViewer(
|
||||
BuildContext context,
|
||||
List<SampleProjectFile> images,
|
||||
List<ProjectFile> images,
|
||||
int initialIndex,
|
||||
) {
|
||||
showDialog<void>(
|
||||
@@ -465,7 +465,7 @@ class ModelHouseDetailPage extends ConsumerWidget {
|
||||
|
||||
/// Image Viewer Dialog with Swipe Navigation
|
||||
class _ImageViewerDialog extends StatefulWidget {
|
||||
final List<SampleProjectFile> images;
|
||||
final List<ProjectFile> images;
|
||||
final int initialIndex;
|
||||
|
||||
const _ImageViewerDialog({
|
||||
|
||||
@@ -10,7 +10,9 @@ 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/design_request.dart';
|
||||
import 'package:worker/features/showrooms/domain/entities/sample_project.dart';
|
||||
import 'package:worker/features/showrooms/presentation/providers/design_request_provider.dart';
|
||||
import 'package:worker/features/showrooms/presentation/providers/sample_project_provider.dart';
|
||||
|
||||
/// Model Houses Page
|
||||
@@ -370,90 +372,118 @@ class _LibraryCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Design Requests Tab
|
||||
class _DesignRequestsTab extends StatelessWidget {
|
||||
class _DesignRequestsTab extends ConsumerWidget {
|
||||
const _DesignRequestsTab();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
children: const [
|
||||
_RequestCard(
|
||||
code: '#YC001',
|
||||
status: DesignRequestStatus.completed,
|
||||
date: '20/10/2024',
|
||||
description: 'Thiết kế nhà phố 3 tầng - Anh Minh (Quận 7)',
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final requestsAsync = ref.watch(designRequestsListProvider);
|
||||
|
||||
return requestsAsync.when(
|
||||
data: (requests) {
|
||||
if (requests.isEmpty) {
|
||||
return const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.design_services_outlined,
|
||||
size: 64,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Chưa có yêu cầu thiết kế nào',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => ref.read(designRequestsListProvider.notifier).refresh(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(20),
|
||||
itemCount: requests.length,
|
||||
itemBuilder: (context, index) {
|
||||
final request = requests[index];
|
||||
return _RequestCard(request: request);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
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(designRequestsListProvider),
|
||||
child: const Text('Thử lại'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_RequestCard(
|
||||
code: '#YC002',
|
||||
status: DesignRequestStatus.designing,
|
||||
date: '25/10/2024',
|
||||
description: 'Cải tạo căn hộ chung cư - Chị Lan (Quận 2)',
|
||||
),
|
||||
_RequestCard(
|
||||
code: '#YC003',
|
||||
status: DesignRequestStatus.pending,
|
||||
date: '28/10/2024',
|
||||
description: 'Thiết kế biệt thự 2 tầng - Anh Đức (Bình Dương)',
|
||||
),
|
||||
_RequestCard(
|
||||
code: '#YC004',
|
||||
status: DesignRequestStatus.pending,
|
||||
date: '01/11/2024',
|
||||
description: 'Thiết kế cửa hàng kinh doanh - Chị Mai (Quận 1)',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Design Request Status
|
||||
enum DesignRequestStatus { pending, designing, completed }
|
||||
|
||||
/// Request Card Widget
|
||||
class _RequestCard extends StatelessWidget {
|
||||
const _RequestCard({
|
||||
required this.code,
|
||||
required this.status,
|
||||
required this.date,
|
||||
required this.description,
|
||||
});
|
||||
const _RequestCard({required this.request});
|
||||
|
||||
final String code;
|
||||
final DesignRequestStatus status;
|
||||
final String date;
|
||||
final String description;
|
||||
final DesignRequest request;
|
||||
|
||||
Color _getStatusColor() {
|
||||
switch (status) {
|
||||
switch (request.status) {
|
||||
case DesignRequestStatus.pending:
|
||||
return const Color(0xFFffc107); // Warning yellow
|
||||
case DesignRequestStatus.designing:
|
||||
return const Color(0xFF3730a3); // Indigo
|
||||
case DesignRequestStatus.completed:
|
||||
return const Color(0xFF065f46); // Success green
|
||||
case DesignRequestStatus.rejected:
|
||||
return const Color(0xFFdc2626); // Danger red
|
||||
}
|
||||
}
|
||||
|
||||
Color _getStatusBackgroundColor() {
|
||||
switch (status) {
|
||||
switch (request.status) {
|
||||
case DesignRequestStatus.pending:
|
||||
return const Color(0xFFfef3c7); // Light yellow
|
||||
case DesignRequestStatus.designing:
|
||||
return const Color(0xFFe0e7ff); // Light indigo
|
||||
case DesignRequestStatus.completed:
|
||||
return const Color(0xFFd1fae5); // Light green
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatusText() {
|
||||
switch (status) {
|
||||
case DesignRequestStatus.pending:
|
||||
return 'CHỜ TIẾP NHẬN';
|
||||
case DesignRequestStatus.designing:
|
||||
return 'ĐANG THIẾT KẾ';
|
||||
case DesignRequestStatus.completed:
|
||||
return 'HOÀN THÀNH';
|
||||
case DesignRequestStatus.rejected:
|
||||
return const Color(0xFFfee2e2); // Light red
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,9 +495,7 @@ class _RequestCard extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
'/model-houses/design-request/${code.replaceAll('#', '')}',
|
||||
);
|
||||
context.push('/model-houses/design-request/${request.id}');
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
@@ -479,14 +507,18 @@ class _RequestCard extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Mã yêu cầu: $code',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.grey900,
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Mã yêu cầu: #${request.id}',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.grey900,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
@@ -497,7 +529,7 @@ class _RequestCard extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
_getStatusText(),
|
||||
request.statusText.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -511,18 +543,34 @@ class _RequestCard extends StatelessWidget {
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Date
|
||||
Text(
|
||||
'Ngày gửi: $date',
|
||||
style: const TextStyle(fontSize: 14, color: AppColors.grey500),
|
||||
),
|
||||
if (request.dateline != null)
|
||||
Text(
|
||||
'Deadline: ${request.dateline}',
|
||||
style: const TextStyle(fontSize: 14, color: AppColors.grey500),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Description
|
||||
// Subject
|
||||
Text(
|
||||
description,
|
||||
style: const TextStyle(fontSize: 14, color: AppColors.grey900),
|
||||
request.subject,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey900,
|
||||
),
|
||||
),
|
||||
|
||||
if (request.plainDescription.isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
// Description
|
||||
Text(
|
||||
request.plainDescription,
|
||||
style: const TextStyle(fontSize: 14, color: AppColors.grey500),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user