- 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).
100 lines
3.3 KiB
Dart
100 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:superport/utils/constants.dart';
|
|
import 'package:superport/core/services/lookups_service.dart';
|
|
import 'package:superport/screens/common/theme_shadcn.dart';
|
|
|
|
// 장비 상태에 따라 칩(Chip) 위젯을 반환하는 함수형 위젯
|
|
class EquipmentStatusChip extends StatelessWidget {
|
|
final String status;
|
|
|
|
const EquipmentStatusChip({super.key, required this.status});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 캐시된 상태 정보 조회 시도
|
|
String statusText = status;
|
|
Color backgroundColor = ShadcnTheme.secondary;
|
|
|
|
try {
|
|
final lookupsService = GetIt.instance<LookupsService>();
|
|
final statusResult = lookupsService.getEquipmentStatusById(status);
|
|
|
|
if (statusResult.isRight()) {
|
|
statusResult.fold(
|
|
(failure) => null,
|
|
(statusItem) {
|
|
if (statusItem != null) {
|
|
statusText = statusItem.name;
|
|
}
|
|
},
|
|
);
|
|
}
|
|
} catch (e) {
|
|
// LookupsService가 등록되지 않았거나 사용할 수 없는 경우 폴백 로직 사용
|
|
}
|
|
|
|
// 상태별 색상 지정 (하드코딩된 매핑을 폴백으로 유지)
|
|
switch (status) {
|
|
case EquipmentStatus.in_:
|
|
case 'in':
|
|
backgroundColor = ShadcnTheme.equipmentIn;
|
|
if (statusText == status) statusText = '입고';
|
|
break;
|
|
case EquipmentStatus.out:
|
|
case 'out':
|
|
backgroundColor = ShadcnTheme.equipmentOut;
|
|
if (statusText == status) statusText = '출고';
|
|
break;
|
|
case EquipmentStatus.rent:
|
|
case 'rent':
|
|
backgroundColor = ShadcnTheme.equipmentRent;
|
|
if (statusText == status) statusText = '대여';
|
|
break;
|
|
case EquipmentStatus.repair:
|
|
case 'repair':
|
|
backgroundColor = ShadcnTheme.equipmentRepair;
|
|
if (statusText == status) statusText = '수리중';
|
|
break;
|
|
case EquipmentStatus.damaged:
|
|
case 'damaged':
|
|
backgroundColor = ShadcnTheme.error;
|
|
if (statusText == status) statusText = '손상';
|
|
break;
|
|
case EquipmentStatus.lost:
|
|
case 'lost':
|
|
backgroundColor = ShadcnTheme.purple;
|
|
if (statusText == status) statusText = '분실';
|
|
break;
|
|
case EquipmentStatus.disposed:
|
|
case 'disposed':
|
|
backgroundColor = ShadcnTheme.equipmentDisposal;
|
|
if (statusText == status) statusText = '폐기';
|
|
break;
|
|
case EquipmentStatus.etc:
|
|
case 'etc':
|
|
backgroundColor = ShadcnTheme.secondary;
|
|
if (statusText == status) statusText = '기타';
|
|
break;
|
|
default:
|
|
backgroundColor = ShadcnTheme.equipmentUnknown;
|
|
if (statusText == status) statusText = '알 수 없음';
|
|
}
|
|
|
|
// 칩 위젯 반환
|
|
return Chip(
|
|
label: Text(
|
|
statusText,
|
|
style: ShadcnTheme.labelSmall.copyWith(color: ShadcnTheme.primaryForeground),
|
|
),
|
|
backgroundColor: backgroundColor,
|
|
visualDensity: VisualDensity.compact,
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 0),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusFull),
|
|
side: BorderSide(color: backgroundColor.withValues(alpha: 0.2)),
|
|
),
|
|
);
|
|
}
|
|
}
|