feat(ui): full‑width ShadTable across app; fix rent dialog width; correct equipment pagination
- ShadTable: ensure full-width via LayoutBuilder+ConstrainedBox minWidth - BaseListScreen: default data area padding = 0 for table edge-to-edge - Vendor/Model/User/Company/Inventory/Zipcode: set columnSpanExtent per column and add final filler column to absorb remaining width; pin date/status/actions widths; ensure date text is single-line - Equipment: unify card/border style; define fixed column widths + filler; increase checkbox column to 56px to avoid overflow - Rent list: migrate to ShadTable.list with fixed widths + filler column - Rent form dialog: prevent infinite width by bounding ShadProgress with SizedBox and remove Expanded from option rows; add safe selectedOptionBuilder - Admin list: fix const with non-const argument in table column extents - Services/Controller: remove hardcoded perPage=10; use BaseListController perPage; trust server meta (total/totalPages) in equipment pagination - widgets/shad_table: ConstrainedBox(minWidth=viewport) so table stretches Run: flutter analyze → 0 errors (warnings remain).
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
@@ -7,7 +8,8 @@ import 'package:superport/screens/maintenance/controllers/maintenance_controller
|
||||
import 'package:superport/screens/maintenance/widgets/status_summary_cards.dart';
|
||||
import 'package:superport/screens/maintenance/maintenance_form_dialog.dart';
|
||||
import 'package:superport/data/models/maintenance_dto.dart';
|
||||
import 'package:superport/screens/common/widgets/standard_data_table.dart';
|
||||
// Removed StandardDataTable in favor of ShadTable.list
|
||||
import 'package:superport/screens/common/widgets/pagination.dart';
|
||||
|
||||
/// 유지보수 대시보드 화면 (Phase 9.2)
|
||||
/// StatusSummaryCards + 필터링된 유지보수 목록으로 구성
|
||||
@@ -21,6 +23,8 @@ class MaintenanceAlertDashboard extends StatefulWidget {
|
||||
|
||||
class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
String _activeFilter = 'all'; // all, expiring_60, expiring_30, expiring_7, expired
|
||||
int _alertPage = 1;
|
||||
final int _alertPageSize = 10;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -207,7 +211,7 @@ class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
icon = Icons.schedule_outlined;
|
||||
break;
|
||||
case 'expired':
|
||||
color = ShadcnTheme.alertExpired; // 만료됨 - 심각 (진한 레드)
|
||||
color = ShadcnTheme.alertExpired; // 만료됨 - 심각 (진한 레드)
|
||||
icon = Icons.error_outline;
|
||||
break;
|
||||
default:
|
||||
@@ -294,7 +298,7 @@ class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 필터링된 유지보수 목록 (테이블 형태)
|
||||
/// 필터링된 유지보수 목록 (ShadTable.list)
|
||||
Widget _buildFilteredMaintenanceList(MaintenanceController controller) {
|
||||
if (controller.isLoading && controller.upcomingAlerts.isEmpty && controller.overdueAlerts.isEmpty) {
|
||||
return ShadCard(
|
||||
@@ -309,14 +313,13 @@ class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
|
||||
final filteredList = _getFilteredMaintenanceList(controller);
|
||||
|
||||
if (filteredList.isEmpty) {
|
||||
return StandardDataTable(
|
||||
columns: _buildTableColumns(),
|
||||
rows: const [],
|
||||
emptyMessage: _getEmptyMessage(),
|
||||
emptyIcon: Icons.check_circle_outline,
|
||||
);
|
||||
}
|
||||
// 항상 테이블 헤더 + 페이지네이션을 유지
|
||||
|
||||
// 페이지네이션 적용 (UI 레벨)
|
||||
final total = filteredList.length;
|
||||
final start = ((_alertPage - 1) * _alertPageSize).clamp(0, total);
|
||||
final end = (start + _alertPageSize).clamp(0, total);
|
||||
final paged = filteredList.sublist(start, end);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -357,183 +360,149 @@ class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
],
|
||||
),
|
||||
),
|
||||
// 테이블
|
||||
StandardDataTable(
|
||||
columns: _buildTableColumns(),
|
||||
rows: filteredList.map((maintenance) =>
|
||||
_buildMaintenanceTableRow(maintenance, controller)
|
||||
).toList(),
|
||||
maxHeight: 400,
|
||||
// 테이블 (ShadTable.list)
|
||||
// 주의: TwoDimensionalViewport 제약 오류 방지를 위해 고정/제한 높이 부여
|
||||
SizedBox(
|
||||
height: _computeTableHeight(paged.length),
|
||||
child: LayoutBuilder(builder: (context, constraints) {
|
||||
// 최소 폭 추정: 장비명(260)+시리얼(200)+고객사(240)+만료일(140)+타입(120)+상태(180)+주기(100)+여백(24)
|
||||
const double minTableWidth = 260 + 200 + 240 + 140 + 120 + 180 + 100 + 24;
|
||||
final double extra = constraints.maxWidth - minTableWidth;
|
||||
final double fillerWidth = extra > 0 ? extra : 0.0;
|
||||
const double nameBaseWidth = 260.0;
|
||||
final double nameColumnWidth = nameBaseWidth + fillerWidth; // 남는 폭은 장비명이 흡수
|
||||
|
||||
return ShadTable.list(
|
||||
header: [
|
||||
ShadTableCell.header(child: SizedBox(width: nameColumnWidth, child: const Text('장비명'))),
|
||||
const ShadTableCell.header(child: Text('시리얼번호')),
|
||||
const ShadTableCell.header(child: Text('고객사')),
|
||||
const ShadTableCell.header(child: Text('만료일')),
|
||||
const ShadTableCell.header(child: Text('타입')),
|
||||
const ShadTableCell.header(child: Text('상태')),
|
||||
const ShadTableCell.header(child: Text('주기')),
|
||||
],
|
||||
// 남은 폭을 채우는 필러 컬럼은 위에서 header에 추가함
|
||||
children: paged.map((maintenance) {
|
||||
final today = DateTime.now();
|
||||
final daysRemaining = maintenance.endedAt.difference(today).inDays;
|
||||
final isExpiringSoon = daysRemaining <= 7;
|
||||
final isExpired = daysRemaining < 0;
|
||||
|
||||
Color typeBg = _getMaintenanceTypeColor(maintenance.maintenanceType);
|
||||
final typeLabel = _getMaintenanceTypeLabel(maintenance.maintenanceType);
|
||||
|
||||
return [
|
||||
// 장비명
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: nameColumnWidth,
|
||||
child: InkWell(
|
||||
onTap: () => _showMaintenanceDetails(maintenance),
|
||||
child: Text(
|
||||
controller.getEquipmentName(maintenance),
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: ShadcnTheme.primary,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 시리얼번호
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
controller.getEquipmentSerial(maintenance),
|
||||
style: ShadcnTheme.bodySmall,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
// 고객사
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
controller.getCompanyName(maintenance),
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: ShadcnTheme.companyCustomer,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
// 만료일
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
'${maintenance.endedAt.year}-${maintenance.endedAt.month.toString().padLeft(2, '0')}-${maintenance.endedAt.day.toString().padLeft(2, '0')}',
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: isExpired
|
||||
? ShadcnTheme.alertExpired
|
||||
: isExpiringSoon
|
||||
? ShadcnTheme.alertWarning30
|
||||
: ShadcnTheme.alertNormal,
|
||||
fontWeight: isExpired || isExpiringSoon ? FontWeight.w600 : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 타입
|
||||
ShadTableCell(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: typeBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
typeLabel,
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 상태 (남은 일수/지연)
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
isExpired ? '${daysRemaining.abs()}일 지연' : '$daysRemaining일 남음',
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: isExpired
|
||||
? ShadcnTheme.alertExpired
|
||||
: isExpiringSoon
|
||||
? ShadcnTheme.alertWarning30
|
||||
: ShadcnTheme.alertNormal,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 주기
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
'${maintenance.periodMonth}개월',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
// 바디에는 빈 셀로 컬럼만 유지
|
||||
// 남는 폭은 장비명 컬럼이 흡수
|
||||
];
|
||||
}).toList(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
||||
// 하단 페이지네이션 (항상 표시)
|
||||
const SizedBox(height: 12),
|
||||
Pagination(
|
||||
totalCount: total,
|
||||
currentPage: _alertPage,
|
||||
pageSize: _alertPageSize,
|
||||
onPageChanged: (p) => setState(() => _alertPage = p),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// 테이블 컬럼 정의
|
||||
List<StandardDataColumn> _buildTableColumns() {
|
||||
return [
|
||||
StandardDataColumn(
|
||||
label: '장비명',
|
||||
flex: 3,
|
||||
),
|
||||
StandardDataColumn(
|
||||
label: '시리얼번호',
|
||||
flex: 2,
|
||||
),
|
||||
StandardDataColumn(
|
||||
label: '고객사',
|
||||
flex: 2,
|
||||
),
|
||||
StandardDataColumn(
|
||||
label: '만료일',
|
||||
flex: 2,
|
||||
),
|
||||
StandardDataColumn(
|
||||
label: '타입',
|
||||
flex: 1,
|
||||
),
|
||||
StandardDataColumn(
|
||||
label: '상태',
|
||||
flex: 2,
|
||||
),
|
||||
StandardDataColumn(
|
||||
label: '주기',
|
||||
flex: 1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/// 유지보수 테이블 행 생성
|
||||
StandardDataRow _buildMaintenanceTableRow(
|
||||
MaintenanceDto maintenance,
|
||||
MaintenanceController controller,
|
||||
) {
|
||||
// 만료까지 남은 일수 계산
|
||||
final today = DateTime.now();
|
||||
final daysRemaining = maintenance.endedAt.difference(today).inDays;
|
||||
final isExpiringSoon = daysRemaining <= 7;
|
||||
final isExpired = daysRemaining < 0;
|
||||
|
||||
return StandardDataRow(
|
||||
index: 0, // index는 StandardDataTable에서 자동 설정
|
||||
columns: _buildTableColumns(),
|
||||
cells: [
|
||||
// 장비명
|
||||
InkWell(
|
||||
onTap: () => _showMaintenanceDetails(maintenance),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Text(
|
||||
controller.getEquipmentName(maintenance),
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: ShadcnTheme.primary,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 시리얼번호
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Text(
|
||||
controller.getEquipmentSerial(maintenance),
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: ShadcnTheme.foreground,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
|
||||
// 고객사 - Phase 10: 회사 타입별 색상 적용
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Text(
|
||||
controller.getCompanyName(maintenance),
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: ShadcnTheme.companyCustomer, // 고객사 - 진한 그린
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
|
||||
// 만료일
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Text(
|
||||
'${maintenance.endedAt.year}-${maintenance.endedAt.month.toString().padLeft(2, '0')}-${maintenance.endedAt.day.toString().padLeft(2, '0')}',
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
// Phase 10: 만료 상태별 색상 체계 적용
|
||||
color: isExpired
|
||||
? ShadcnTheme.alertExpired // 만료됨 - 심각 (진한 레드)
|
||||
: isExpiringSoon
|
||||
? ShadcnTheme.alertWarning30 // 만료 임박 - 경고 (오렌지)
|
||||
: ShadcnTheme.alertNormal, // 정상 - 안전 (그린)
|
||||
fontWeight: isExpired || isExpiringSoon ? FontWeight.w600 : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 타입 (방문/원격 변환)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _getMaintenanceTypeColor(maintenance.maintenanceType),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
_getMaintenanceTypeLabel(maintenance.maintenanceType),
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 상태 (남은 일수/지연)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Text(
|
||||
isExpired
|
||||
? '${daysRemaining.abs()}일 지연'
|
||||
: '$daysRemaining일 남음',
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
// Phase 10: 남은 일수 상태별 색상 체계 적용
|
||||
color: isExpired
|
||||
? ShadcnTheme.alertExpired // 지연 - 심각 (진한 레드)
|
||||
: isExpiringSoon
|
||||
? ShadcnTheme.alertWarning30 // 임박 - 경고 (오렌지)
|
||||
: ShadcnTheme.alertNormal, // 충분 - 안전 (그린)
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 주기
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
child: Text(
|
||||
'${maintenance.periodMonth}개월',
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 유지보수 타입을 방문(V)/원격(R)로 변환
|
||||
String _getMaintenanceTypeLabel(String maintenanceType) {
|
||||
switch (maintenanceType) {
|
||||
@@ -559,6 +528,17 @@ class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
}
|
||||
}
|
||||
|
||||
// 테이블 높이 계산 (ShadTable.list가 내부 스크롤을 가지므로 부모에서 높이를 제한)
|
||||
double _computeTableHeight(int rows) {
|
||||
const rowHeight = 48.0; // 셀 높이(대략)
|
||||
const headerHeight = 48.0;
|
||||
const minH = 200.0; // 너무 작지 않게 최소 높이
|
||||
const maxH = 560.0; // 페이지에서 과도하게 커지지 않도록 상한
|
||||
final visible = rows.clamp(1, _alertPageSize); // 페이지당 행 수 이내로 계산
|
||||
final h = headerHeight + (visible * rowHeight) + 16.0; // 약간의 패딩
|
||||
return math.max(minH, math.min(maxH, h.toDouble()));
|
||||
}
|
||||
|
||||
/// 빠른 작업 섹션
|
||||
Widget _buildQuickActions() {
|
||||
return ShadCard(
|
||||
@@ -735,4 +715,4 @@ class _MaintenanceAlertDashboardState extends State<MaintenanceAlertDashboard> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user