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:
@@ -155,46 +155,7 @@ class _AdministratorListState extends State<AdministratorList> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 데이터 테이블 컬럼 정의
|
||||
List<DataColumn> get _columns => [
|
||||
const DataColumn(label: Text('이름')),
|
||||
const DataColumn(label: Text('이메일')),
|
||||
const DataColumn(label: Text('전화번호')),
|
||||
const DataColumn(label: Text('휴대폰')),
|
||||
const DataColumn(label: Text('작업')),
|
||||
];
|
||||
|
||||
/// 데이터 테이블 행 생성
|
||||
List<DataRow> _buildRows(List<AdministratorDto> administrators) {
|
||||
return administrators.map((admin) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text(admin.name)),
|
||||
DataCell(Text(admin.email)),
|
||||
DataCell(Text(admin.phone)),
|
||||
DataCell(Text(admin.mobile)),
|
||||
DataCell(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEditDialog(admin),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showDeleteDialog(admin),
|
||||
child: const Icon(Icons.delete, size: 16, color: Colors.red),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
// 기존 DataTable 구현 제거 (ShadTable.list로 이식)
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -333,52 +294,113 @@ class _AdministratorListState extends State<AdministratorList> {
|
||||
),
|
||||
),
|
||||
|
||||
// Data Table
|
||||
// Data Table (ShadTable.list)
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ShadCard(
|
||||
child: controller.administrators.isEmpty
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(64),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(Icons.inbox, size: 64, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'관리자가 없습니다',
|
||||
style: TextStyle(fontSize: 18, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ShadCard(
|
||||
child: controller.administrators.isEmpty
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(64),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(Icons.inbox, size: 64, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text('관리자가 없습니다', style: TextStyle(fontSize: 18, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: DataTable(
|
||||
columns: _columns,
|
||||
rows: _buildRows(controller.administrators),
|
||||
columnSpacing: 24,
|
||||
headingRowHeight: 56,
|
||||
dataRowMinHeight: 48,
|
||||
dataRowMaxHeight: 56,
|
||||
),
|
||||
),
|
||||
)
|
||||
: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 최소 폭 추정: 이름(160) + 이메일(260) + 전화(160) + 휴대폰(160) + 작업(160) + 여백(24)
|
||||
const double minW = 160 + 260 + 160 + 160 + 160 + 24;
|
||||
final double tableW = constraints.maxWidth >= minW ? constraints.maxWidth : minW;
|
||||
const double emailBase = 260.0;
|
||||
final double emailW = emailBase; // 고정 폭, 남는 폭은 filler가 흡수
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableW,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(160); // 이름
|
||||
case 1:
|
||||
return FixedTableSpanExtent(emailW); // 이메일
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(160); // 전화
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(160); // 휴대폰
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(160); // 작업
|
||||
case 5:
|
||||
return const RemainingTableSpanExtent(); // filler
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('이름')),
|
||||
ShadTableCell.header(child: SizedBox(width: emailW, child: const Text('이메일'))),
|
||||
const ShadTableCell.header(child: Text('전화번호')),
|
||||
const ShadTableCell.header(child: Text('휴대폰')),
|
||||
const ShadTableCell.header(child: Text('작업')),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: controller.administrators.map((admin) {
|
||||
return [
|
||||
ShadTableCell(child: Text(admin.name, overflow: TextOverflow.ellipsis)),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: emailW,
|
||||
child: Text(admin.email, overflow: TextOverflow.ellipsis)),
|
||||
),
|
||||
ShadTableCell(child: Text(admin.phone, overflow: TextOverflow.ellipsis)),
|
||||
ShadTableCell(child: Text(admin.mobile, overflow: TextOverflow.ellipsis)),
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEditDialog(admin),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showDeleteDialog(admin),
|
||||
child: const Icon(Icons.delete, size: 16, color: Colors.red),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Pagination
|
||||
if (controller.totalPages > 1)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Pagination(
|
||||
totalCount: controller.totalCount,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: controller.pageSize,
|
||||
onPageChanged: (page) => controller.goToPage(page),
|
||||
),
|
||||
// Pagination (항상 표시)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Pagination(
|
||||
totalCount: controller.totalCount,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: controller.pageSize,
|
||||
onPageChanged: (page) => controller.goToPage(page),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ class _AppLayoutState extends State<AppLayout>
|
||||
static const double _sidebarExpandedWidth = 260.0;
|
||||
static const double _sidebarCollapsedWidth = 72.0;
|
||||
static const double _headerHeight = 64.0;
|
||||
static const double _maxContentWidth = 1440.0;
|
||||
static const double _maxContentWidth = 1600.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -313,8 +313,9 @@ class _AppLayoutState extends State<AppLayout>
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: isWideScreen ? _maxContentWidth : double.infinity,
|
||||
// 최대 폭 제한을 해제하여(=무한대) 사이드바를 제외한 남은 전폭을 모두 사용
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: double.infinity,
|
||||
),
|
||||
padding: EdgeInsets.all(
|
||||
isWideScreen ? ShadcnTheme.spacing6 : ShadcnTheme.spacing4
|
||||
@@ -1267,13 +1268,13 @@ class SidebarMenu extends StatelessWidget {
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange,
|
||||
color: ShadcnTheme.warning,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
badge,
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
@@ -1390,4 +1391,4 @@ class SidebarMenu extends StatelessWidget {
|
||||
return outlinedIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ class BaseListScreen extends StatelessWidget {
|
||||
final VoidCallback? onRefresh;
|
||||
final String emptyMessage;
|
||||
final IconData emptyIcon;
|
||||
// 데이터 테이블 영역 좌우 패딩(기본: spacing6). 화면별로 전체폭 사용이 필요할 경우 0으로 설정.
|
||||
final EdgeInsetsGeometry dataAreaPadding;
|
||||
|
||||
const BaseListScreen({
|
||||
super.key,
|
||||
@@ -30,6 +32,8 @@ class BaseListScreen extends StatelessWidget {
|
||||
this.onRefresh,
|
||||
this.emptyMessage = '데이터가 없습니다',
|
||||
this.emptyIcon = Icons.inbox_outlined,
|
||||
// 기본값을 0으로 설정해 테이블 영역이 가용 폭을 모두 사용하도록 함
|
||||
this.dataAreaPadding = EdgeInsets.zero,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -78,7 +82,7 @@ class BaseListScreen extends StatelessWidget {
|
||||
// 데이터 테이블 - 헤더 고정, 바디만 스크롤
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: ShadcnTheme.spacing6),
|
||||
padding: dataAreaPadding,
|
||||
child: dataTable,
|
||||
),
|
||||
),
|
||||
@@ -125,7 +129,7 @@ class BaseListScreen extends StatelessWidget {
|
||||
onPressed: onRefresh,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ShadcnTheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
foregroundColor: ShadcnTheme.primaryForeground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
@@ -153,4 +157,4 @@ class BaseListScreen extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class FormLayoutTemplate extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
title,
|
||||
style: ShadcnTheme.headingH3.copyWith( // Phase 10: 표준 헤딩 스타일
|
||||
style: ShadcnTheme.headingH3.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: ShadcnTheme.foreground,
|
||||
),
|
||||
@@ -76,7 +76,7 @@ class FormLayoutTemplate extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.fromLTRB(24, 16, 24, 24),
|
||||
padding: const EdgeInsets.fromLTRB(24, 16, 24, 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -122,30 +122,30 @@ class FormSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ShadcnCard(
|
||||
padding: padding ?? EdgeInsets.all(24),
|
||||
padding: padding ?? const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title != null) ...[
|
||||
Text(
|
||||
title!,
|
||||
style: ShadcnTheme.bodyLarge.copyWith( // Phase 10: 표준 바디 라지
|
||||
style: ShadcnTheme.bodyLarge.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: ShadcnTheme.foreground, // Phase 10: 전경색
|
||||
color: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
SizedBox(height: 4),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle!,
|
||||
style: ShadcnTheme.bodyMedium.copyWith( // Phase 10: 표준 바디 미디엄
|
||||
color: ShadcnTheme.mutedForeground, // Phase 10: 뮤트된 전경색
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 20),
|
||||
Divider(color: ShadcnTheme.border, height: 1), // Phase 10: 테두리 색상
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
Divider(color: ShadcnTheme.border, height: 1),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
if (children.isNotEmpty)
|
||||
...children.asMap().entries.map((entry) {
|
||||
@@ -153,7 +153,7 @@ class FormSection extends StatelessWidget {
|
||||
final child = entry.value;
|
||||
if (index < children.length - 1) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: child,
|
||||
);
|
||||
} else {
|
||||
@@ -190,33 +190,23 @@ class FormFieldWrapper extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF374151),
|
||||
),
|
||||
style: ShadcnTheme.labelMedium,
|
||||
),
|
||||
if (required)
|
||||
Text(
|
||||
' *',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFFEF4444),
|
||||
),
|
||||
style: ShadcnTheme.labelMedium.copyWith(color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (hint != null) ...[
|
||||
SizedBox(height: 4),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
hint!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF6B7280),
|
||||
),
|
||||
style: ShadcnTheme.bodyXs,
|
||||
),
|
||||
],
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
child,
|
||||
],
|
||||
);
|
||||
@@ -236,10 +226,10 @@ class UIConstants {
|
||||
static const double columnWidthLarge = 200.0; // 긴 텍스트
|
||||
|
||||
// 색상
|
||||
static const Color backgroundColor = Color(0xFFF5F7FA);
|
||||
static const Color cardBackground = Colors.white;
|
||||
static const Color borderColor = Color(0xFFE5E7EB);
|
||||
static const Color textPrimary = Color(0xFF1A1F36);
|
||||
static const Color textSecondary = Color(0xFF6B7280);
|
||||
static const Color textMuted = Color(0xFF9CA3AF);
|
||||
}
|
||||
static const Color backgroundColor = ShadcnTheme.backgroundSecondary;
|
||||
static const Color cardBackground = ShadcnTheme.card;
|
||||
static const Color borderColor = ShadcnTheme.border;
|
||||
static const Color textPrimary = ShadcnTheme.foreground;
|
||||
static const Color textSecondary = ShadcnTheme.foregroundSecondary;
|
||||
static const Color textMuted = ShadcnTheme.foregroundMuted;
|
||||
}
|
||||
|
||||
@@ -132,21 +132,14 @@ class _AddressInputState extends State<AddressInput> {
|
||||
showWhenUnlinked: false,
|
||||
offset: const Offset(0, 45),
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
elevation: 0,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
color: ShadcnTheme.card,
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
constraints: BoxConstraints(maxHeight: maxHeight),
|
||||
child: SingleChildScrollView(
|
||||
@@ -244,7 +237,7 @@ class _AddressInputState extends State<AddressInput> {
|
||||
color:
|
||||
_selectedRegion.isEmpty
|
||||
? Colors.grey.shade600
|
||||
: Colors.black,
|
||||
: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
|
||||
@@ -22,13 +22,20 @@ class Pagination extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 전체 페이지 수 계산
|
||||
final int totalPages = (totalCount / pageSize).ceil();
|
||||
// 방어적 계산: pageSize, currentPage, totalPages 모두 안전 범위로 보정
|
||||
final int safePageSize = pageSize <= 0 ? 1 : pageSize;
|
||||
final int computedTotalPages = (totalCount / safePageSize).ceil();
|
||||
final int totalPages = computedTotalPages < 1 ? 1 : computedTotalPages;
|
||||
final int current = currentPage < 1
|
||||
? 1
|
||||
: (currentPage > totalPages ? totalPages : currentPage);
|
||||
|
||||
// 페이지네이션 버튼 최대 10개
|
||||
final int maxButtons = 10;
|
||||
// 시작 페이지 계산
|
||||
int startPage = ((currentPage - 1) ~/ maxButtons) * maxButtons + 1;
|
||||
int endPage = (startPage + maxButtons - 1).clamp(1, totalPages);
|
||||
const int maxButtons = 10;
|
||||
// 시작/끝 페이지 계산
|
||||
int startPage = ((current - 1) ~/ maxButtons) * maxButtons + 1;
|
||||
int endPage = startPage + maxButtons - 1;
|
||||
if (endPage > totalPages) endPage = totalPages;
|
||||
|
||||
List<Widget> pageButtons = [];
|
||||
for (int i = startPage; i <= endPage; i++) {
|
||||
@@ -36,25 +43,25 @@ class Pagination extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: InkWell(
|
||||
onTap: i == currentPage ? null : () => onPageChanged(i),
|
||||
onTap: i == current ? null : () => onPageChanged(i),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
child: Container(
|
||||
height: 32,
|
||||
constraints: const BoxConstraints(minWidth: 32),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: i == currentPage ? ShadcnTheme.primary : Colors.transparent,
|
||||
color: i == current ? ShadcnTheme.primary : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
border: Border.all(
|
||||
color: i == currentPage ? ShadcnTheme.primary : Colors.black,
|
||||
color: i == currentPage ? ShadcnTheme.primary : ShadcnTheme.border,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'$i',
|
||||
style: ShadcnTheme.labelMedium.copyWith(
|
||||
color: i == currentPage
|
||||
? ShadcnTheme.primaryForeground
|
||||
color: i == current
|
||||
? ShadcnTheme.primaryForeground
|
||||
: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
@@ -73,14 +80,14 @@ class Pagination extends StatelessWidget {
|
||||
_buildNavigationButton(
|
||||
icon: Icons.first_page,
|
||||
tooltip: '처음',
|
||||
onPressed: currentPage > 1 ? () => onPageChanged(1) : null,
|
||||
onPressed: current > 1 ? () => onPageChanged(1) : null,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
// 이전 페이지로 이동
|
||||
_buildNavigationButton(
|
||||
icon: Icons.chevron_left,
|
||||
tooltip: '이전',
|
||||
onPressed: currentPage > 1 ? () => onPageChanged(currentPage - 1) : null,
|
||||
onPressed: current > 1 ? () => onPageChanged(current - 1) : null,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 페이지 번호 버튼들
|
||||
@@ -90,8 +97,8 @@ class Pagination extends StatelessWidget {
|
||||
_buildNavigationButton(
|
||||
icon: Icons.chevron_right,
|
||||
tooltip: '다음',
|
||||
onPressed: currentPage < totalPages
|
||||
? () => onPageChanged(currentPage + 1)
|
||||
onPressed: current < totalPages
|
||||
? () => onPageChanged(current + 1)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
@@ -99,7 +106,7 @@ class Pagination extends StatelessWidget {
|
||||
_buildNavigationButton(
|
||||
icon: Icons.last_page,
|
||||
tooltip: '마짉',
|
||||
onPressed: currentPage < totalPages ? () => onPageChanged(totalPages) : null,
|
||||
onPressed: current < totalPages ? () => onPageChanged(totalPages) : null,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -123,7 +130,7 @@ class Pagination extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
border: Border.all(
|
||||
color: isDisabled ? ShadcnTheme.muted : Colors.black,
|
||||
color: isDisabled ? ShadcnTheme.muted : ShadcnTheme.border,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
|
||||
@@ -141,7 +141,7 @@ class StandardActionButtons {
|
||||
text: text,
|
||||
onPressed: onPressed,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: Icon(icon, size: 16),
|
||||
);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ class StandardFilterDropdown<T> extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
@@ -252,4 +252,4 @@ class StandardFilterDropdown<T> extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ class StandardDataRow extends StatelessWidget {
|
||||
? ShadcnTheme.muted.withValues(alpha: 0.1)
|
||||
: null,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.black),
|
||||
bottom: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -418,4 +418,4 @@ class StandardActionButtons extends StatelessWidget {
|
||||
tooltip: tooltip,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ class StandardErrorState extends StatelessWidget {
|
||||
],
|
||||
if (onRetry != null) ...[
|
||||
const SizedBox(height: ShadcnTheme.spacing6),
|
||||
ShadcnButton(
|
||||
text: '다시 시도',
|
||||
onPressed: onRetry,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
icon: const Icon(Icons.refresh, size: 16),
|
||||
),
|
||||
ShadcnButton(
|
||||
text: '다시 시도',
|
||||
onPressed: onRetry,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: const Icon(Icons.refresh, size: 16),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -185,10 +185,7 @@ class StandardInfoMessage extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: displayColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
style: ShadcnTheme.bodySmall.copyWith(color: displayColor),
|
||||
),
|
||||
),
|
||||
if (onClose != null)
|
||||
@@ -235,14 +232,8 @@ class StandardStatCard extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
border: Border.all(color: Colors.black),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -294,4 +285,4 @@ class StandardStatCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class UnifiedSearchBar extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
@@ -77,7 +77,7 @@ class UnifiedSearchBar extends StatelessWidget {
|
||||
text: '검색',
|
||||
onPressed: onSearch,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: const Icon(Icons.search, size: 16),
|
||||
),
|
||||
),
|
||||
@@ -106,4 +106,4 @@ class UnifiedSearchBar extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ class _BranchFormScreenState extends State<BranchFormScreen> {
|
||||
onPressed: controller.isSaving ? null : _saveBranch,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ShadcnTheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
foregroundColor: ShadcnTheme.primaryForeground,
|
||||
minimumSize: const Size.fromHeight(48),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -387,7 +387,7 @@ class _BranchFormScreenState extends State<BranchFormScreen> {
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(ShadcnTheme.primaryForeground),
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
@@ -411,4 +411,4 @@ class _BranchFormScreenState extends State<BranchFormScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,79 +338,137 @@ class _CompanyListState extends State<CompanyList> {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('번호')),
|
||||
ShadTableCell.header(child: Text('회사명')),
|
||||
ShadTableCell.header(child: Text('구분')),
|
||||
ShadTableCell.header(child: Text('주소')),
|
||||
ShadTableCell.header(child: Text('담당자')),
|
||||
ShadTableCell.header(child: Text('연락처')),
|
||||
ShadTableCell.header(child: Text('파트너/고객')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('등록/수정일')),
|
||||
ShadTableCell.header(child: Text('비고')),
|
||||
ShadTableCell.header(child: Text('관리')),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < items.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(child: Text(((((controller.currentPage - 1) * controller.pageSize) + index + 1)).toString(), style: ShadcnTheme.bodySmall)),
|
||||
// 회사명 (본사>지점 표기 유지)
|
||||
ShadTableCell(child: _buildDisplayNameText(items[index])),
|
||||
// 구분 (본사/지점)
|
||||
ShadTableCell(child: _buildCompanyTypeLabel(items[index].isBranch)),
|
||||
// 주소
|
||||
ShadTableCell(child: Text(items[index].address.isNotEmpty ? items[index].address : '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
// 담당자 요약
|
||||
ShadTableCell(child: _buildContactInfo(items[index])),
|
||||
// 연락처 상세
|
||||
ShadTableCell(child: _buildContactDetails(items[index])),
|
||||
// 파트너/고객 플래그
|
||||
ShadTableCell(child: _buildPartnerCustomerFlags(items[index])),
|
||||
// 상태
|
||||
ShadTableCell(child: _buildStatusBadge(items[index].isActive)),
|
||||
// 등록/수정일
|
||||
ShadTableCell(child: _buildDateInfo(items[index])),
|
||||
// 비고
|
||||
ShadTableCell(child: Text(items[index].remark ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
// 관리(편집/삭제)
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (items[index].id != null) ...[
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () async {
|
||||
// 기존 편집 흐름 유지
|
||||
final args = {'companyId': items[index].id};
|
||||
final result = await Navigator.pushNamed(context, '/company/edit', arguments: args);
|
||||
if (result == true) {
|
||||
controller.refresh();
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 최소폭 추정 (다컬럼): 번호(64)+회사명(240)+구분(120)+주소(320)+담당자(200)+연락처(220)+파트너/고객(160)+상태(120)+등록/수정일(200)+비고(220)+관리(160)+여백(24)
|
||||
const double actionsW = 160.0;
|
||||
const double minTableWidth = 64 + 240 + 120 + 320 + 200 + 220 + 160 + 120 + 200 + 220 + actionsW + 24;
|
||||
final double tableWidth = constraints.maxWidth >= minTableWidth
|
||||
? constraints.maxWidth
|
||||
: minTableWidth;
|
||||
const double addressColumnWidth = 320.0; // 고정, 남는 폭은 filler가 흡수
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(64);
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(240);
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(120);
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(addressColumnWidth);
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(200);
|
||||
case 5:
|
||||
return const FixedTableSpanExtent(220);
|
||||
case 6:
|
||||
return const FixedTableSpanExtent(160);
|
||||
case 7:
|
||||
return const FixedTableSpanExtent(120);
|
||||
case 8:
|
||||
return const FixedTableSpanExtent(200);
|
||||
case 9:
|
||||
return const FixedTableSpanExtent(220);
|
||||
case 10:
|
||||
return const FixedTableSpanExtent(actionsW);
|
||||
case 11:
|
||||
return const RemainingTableSpanExtent();
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('번호')),
|
||||
const ShadTableCell.header(child: Text('회사명')),
|
||||
const ShadTableCell.header(child: Text('구분')),
|
||||
ShadTableCell.header(child: SizedBox(width: addressColumnWidth, 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('비고')),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('관리'))),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < items.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(child: Text(((((controller.currentPage - 1) * controller.pageSize) + index + 1)).toString(), style: ShadcnTheme.bodySmall)),
|
||||
// 회사명 (본사>지점 표기 유지)
|
||||
ShadTableCell(child: _buildDisplayNameText(items[index])),
|
||||
// 구분 (본사/지점)
|
||||
ShadTableCell(child: _buildCompanyTypeLabel(items[index].isBranch)),
|
||||
// 주소 (가변 폭)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: addressColumnWidth,
|
||||
child: Text(items[index].address.isNotEmpty ? items[index].address : '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () {
|
||||
if (items[index].isBranch) {
|
||||
_deleteBranch(items[index].parentCompanyId!, items[index].id!);
|
||||
} else {
|
||||
_deleteCompany(items[index].id!);
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
// 담당자 요약
|
||||
ShadTableCell(child: _buildContactInfo(items[index])),
|
||||
// 연락처 상세
|
||||
ShadTableCell(child: _buildContactDetails(items[index])),
|
||||
// 파트너/고객 플래그
|
||||
ShadTableCell(child: _buildPartnerCustomerFlags(items[index])),
|
||||
// 상태
|
||||
ShadTableCell(child: _buildStatusBadge(items[index].isActive)),
|
||||
// 등록/수정일
|
||||
ShadTableCell(child: _buildDateInfo(items[index])),
|
||||
// 비고
|
||||
ShadTableCell(child: Text(items[index].remark ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
// 관리(편집/삭제)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (items[index].id != null) ...[
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () async {
|
||||
// 기존 편집 흐름 유지
|
||||
final args = {'companyId': items[index].id};
|
||||
final result = await Navigator.pushNamed(context, '/company/edit', arguments: args);
|
||||
if (result == true) {
|
||||
controller.refresh();
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () {
|
||||
if (items[index].isBranch) {
|
||||
_deleteBranch(items[index].parentCompanyId!, items[index].id!);
|
||||
} else {
|
||||
_deleteCompany(items[index].id!);
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -602,6 +660,7 @@ class _CompanyListState extends State<CompanyList> {
|
||||
controller.goToPage(page);
|
||||
},
|
||||
),
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -347,7 +347,7 @@ class _CompanyBranchDialogState extends State<CompanyBranchDialog> {
|
||||
label: const Text('지점 추가'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ShadcnTheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
foregroundColor: ShadcnTheme.primaryForeground,
|
||||
minimumSize: const Size(100, 36),
|
||||
),
|
||||
),
|
||||
@@ -468,4 +468,4 @@ class _CompanyBranchDialogState extends State<CompanyBranchDialog> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,16 +75,11 @@ class CompanyNameAutocomplete extends StatelessWidget {
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withAlpha(77),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
border: Border.all(color: Theme.of(context).dividerColor),
|
||||
boxShadow: const [
|
||||
BoxShadow(color: Colors.transparent),
|
||||
],
|
||||
),
|
||||
child:
|
||||
@@ -98,10 +93,7 @@ class CompanyNameAutocomplete extends StatelessWidget {
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: filteredCompanyNames.length,
|
||||
separatorBuilder:
|
||||
(context, index) => Divider(
|
||||
height: 1,
|
||||
color: Colors.grey.shade200,
|
||||
),
|
||||
(context, index) => Divider(height: 1, color: Theme.of(context).dividerColor),
|
||||
itemBuilder: (context, index) {
|
||||
final companyName = filteredCompanyNames[index];
|
||||
final text = nameController.text.toLowerCase();
|
||||
@@ -138,8 +130,8 @@ class CompanyNameAutocomplete extends StatelessWidget {
|
||||
0,
|
||||
matchIndex,
|
||||
),
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
// 일치하는 부분
|
||||
@@ -161,10 +153,9 @@ class CompanyNameAutocomplete extends StatelessWidget {
|
||||
matchIndex + text.length,
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
matchIndex == 0
|
||||
? Colors.grey[600]
|
||||
: Colors.black,
|
||||
color: matchIndex == 0
|
||||
? Theme.of(context).textTheme.bodySmall?.color?.withOpacity(0.7)
|
||||
: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -146,7 +146,7 @@ class _CompanyRestoreDialogState extends State<CompanyRestoreDialog> {
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -206,4 +206,4 @@ Future<bool?> showCompanyRestoreDialog(
|
||||
onRestored: onRestored,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
|
||||
required PaginationParams params,
|
||||
Map<String, dynamic>? additionalFilters,
|
||||
}) async {
|
||||
// API 호출 (페이지 크기를 명시적으로 10개로 고정)
|
||||
// API 호출: BaseListController에서 넘겨준 page/perPage를 그대로 전달
|
||||
final apiEquipmentDtos = await ErrorHandler.handleApiCall(
|
||||
() => _equipmentService.getEquipmentsWithStatus(
|
||||
page: params.page,
|
||||
perPage: 10, // 🎯 장비 리스트는 항상 10개로 고정
|
||||
perPage: params.perPage,
|
||||
status: _statusFilter != null ?
|
||||
EquipmentStatusConverter.clientToServer(_statusFilter) : null,
|
||||
search: params.search,
|
||||
@@ -598,4 +598,4 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
|
||||
(statusItem) => statusItem,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,49 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
final allSelected = items.isNotEmpty &&
|
||||
items.every((e) => _selectedItems.contains(e.equipment.id));
|
||||
|
||||
// 표시 컬럼 판정 (기존 조건과 동일)
|
||||
final showCompany = availableWidth > 900;
|
||||
final showWarehouse = availableWidth > 1100;
|
||||
final showDate = availableWidth > 800;
|
||||
|
||||
// 컬럼 최소 폭 추정치 (px)
|
||||
// 체크박스 컬럼은 셀 기본 좌우 패딩(16+16)을 고려해 최소 50px 이상 필요
|
||||
const checkboxW = 56.0;
|
||||
const statusW = 80.0;
|
||||
const equipNoW = 120.0;
|
||||
const serialW = 160.0;
|
||||
const vendorW = 160.0;
|
||||
const modelBaseW = 240.0; // 남는 폭은 이 컬럼이 흡수
|
||||
const companyW = 180.0;
|
||||
const warehouseW = 180.0;
|
||||
const dateW = 140.0;
|
||||
const actionsW = 160.0; // 아이콘 3개 수용
|
||||
|
||||
double minTableWidth = checkboxW + statusW + equipNoW + serialW + vendorW + modelBaseW + actionsW;
|
||||
if (showCompany) minTableWidth += companyW;
|
||||
if (showWarehouse) minTableWidth += warehouseW;
|
||||
if (showDate) minTableWidth += dateW;
|
||||
|
||||
final extra = (availableWidth - minTableWidth);
|
||||
final double modelColumnWidth = modelBaseW; // 모델은 고정 폭, 남는 폭은 filler가 흡수
|
||||
|
||||
// 컬럼 폭 정의(마지막 filler가 잔여 폭 흡수)
|
||||
final columnExtents = <TableSpanExtent>[
|
||||
const FixedTableSpanExtent(checkboxW),
|
||||
const FixedTableSpanExtent(statusW),
|
||||
const FixedTableSpanExtent(equipNoW),
|
||||
const FixedTableSpanExtent(serialW),
|
||||
const FixedTableSpanExtent(vendorW),
|
||||
const FixedTableSpanExtent(modelBaseW),
|
||||
if (showCompany) const FixedTableSpanExtent(companyW),
|
||||
if (showWarehouse) const FixedTableSpanExtent(warehouseW),
|
||||
if (showDate) const FixedTableSpanExtent(dateW),
|
||||
const FixedTableSpanExtent(actionsW),
|
||||
const RemainingTableSpanExtent(),
|
||||
];
|
||||
|
||||
return ShadTable.list(
|
||||
columnSpanExtent: (index) => columnExtents[index],
|
||||
header: [
|
||||
// 선택
|
||||
ShadTableCell.header(
|
||||
@@ -128,11 +170,13 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
ShadTableCell.header(child: const Text('장비번호')),
|
||||
ShadTableCell.header(child: const Text('시리얼')),
|
||||
ShadTableCell.header(child: const Text('제조사')),
|
||||
ShadTableCell.header(child: const Text('모델')),
|
||||
if (availableWidth > 900) ShadTableCell.header(child: const Text('회사')),
|
||||
if (availableWidth > 1100) ShadTableCell.header(child: const Text('창고')),
|
||||
if (availableWidth > 800) ShadTableCell.header(child: const Text('일자')),
|
||||
ShadTableCell.header(child: const Text('관리')),
|
||||
// 남는 폭을 모델 컬럼이 흡수
|
||||
ShadTableCell.header(child: SizedBox(width: modelColumnWidth, child: const Text('모델'))),
|
||||
if (showCompany) ShadTableCell.header(child: const Text('회사')),
|
||||
if (showWarehouse) ShadTableCell.header(child: const Text('창고')),
|
||||
if (showDate) ShadTableCell.header(child: const Text('일자')),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('관리'))),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: items.map((item) {
|
||||
final id = item.equipment.id;
|
||||
@@ -177,15 +221,18 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
item.vendorName ?? item.equipment.manufacturer,
|
||||
),
|
||||
),
|
||||
// 모델
|
||||
// 모델 (가변 폭)
|
||||
ShadTableCell(
|
||||
child: _buildTextWithTooltip(
|
||||
item.modelName ?? item.equipment.modelName,
|
||||
item.modelName ?? item.equipment.modelName,
|
||||
child: SizedBox(
|
||||
width: modelColumnWidth,
|
||||
child: _buildTextWithTooltip(
|
||||
item.modelName ?? item.equipment.modelName,
|
||||
item.modelName ?? item.equipment.modelName,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 회사 (반응형)
|
||||
if (availableWidth > 900)
|
||||
if (showCompany)
|
||||
ShadTableCell(
|
||||
child: _buildTextWithTooltip(
|
||||
item.companyName ?? item.currentCompany ?? '-',
|
||||
@@ -193,7 +240,7 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
),
|
||||
),
|
||||
// 창고 (반응형)
|
||||
if (availableWidth > 1100)
|
||||
if (showWarehouse)
|
||||
ShadTableCell(
|
||||
child: _buildTextWithTooltip(
|
||||
item.warehouseLocation ?? '-',
|
||||
@@ -201,49 +248,57 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
),
|
||||
),
|
||||
// 일자 (반응형)
|
||||
if (availableWidth > 800)
|
||||
if (showDate)
|
||||
ShadTableCell(
|
||||
child: _buildTextWithTooltip(
|
||||
_formatDate(item.date),
|
||||
_formatDate(item.date),
|
||||
),
|
||||
),
|
||||
// 관리 액션
|
||||
// 관리 액션 (오버플로우 방지)
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Tooltip(
|
||||
message: '이력 보기',
|
||||
child: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEquipmentHistoryDialog(item.equipment.id ?? 0),
|
||||
child: const Icon(Icons.history, size: 16),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Tooltip(
|
||||
message: '이력 보기',
|
||||
child: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEquipmentHistoryDialog(item.equipment.id ?? 0),
|
||||
child: const Icon(Icons.history, size: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Tooltip(
|
||||
message: '수정',
|
||||
child: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _handleEdit(item),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Tooltip(
|
||||
message: '삭제',
|
||||
child: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _handleDelete(item),
|
||||
child: const Icon(Icons.delete_outline, size: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Tooltip(
|
||||
message: '수정',
|
||||
child: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _handleEdit(item),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Tooltip(
|
||||
message: '삭제',
|
||||
child: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _handleDelete(item),
|
||||
child: const Icon(Icons.delete_outline, size: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -784,15 +839,16 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
// 데이터 테이블
|
||||
dataTable: _buildDataTable(filteredEquipments),
|
||||
|
||||
// 페이지네이션 - 조건 수정으로 표시 개선
|
||||
pagination: controller.total > controller.pageSize ? Pagination(
|
||||
// 페이지네이션 - 항상 하단 표시
|
||||
pagination: Pagination(
|
||||
totalCount: controller.total,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: controller.pageSize,
|
||||
onPageChanged: (page) {
|
||||
controller.goToPage(page);
|
||||
},
|
||||
) : null,
|
||||
),
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -811,7 +867,7 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
@@ -837,7 +893,7 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
text: '검색',
|
||||
onPressed: _onSearch,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: const Icon(Icons.search, size: 16),
|
||||
),
|
||||
),
|
||||
@@ -963,7 +1019,7 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
}
|
||||
},
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: const Icon(Icons.add, size: 16),
|
||||
),
|
||||
],
|
||||
@@ -1052,14 +1108,14 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
}
|
||||
},
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: const Icon(Icons.add, size: 16),
|
||||
),
|
||||
ShadcnButton(
|
||||
text: '출고',
|
||||
onPressed: selectedInCount > 0 ? _handleOutEquipment : null,
|
||||
variant: selectedInCount > 0 ? ShadcnButtonVariant.primary : ShadcnButtonVariant.secondary,
|
||||
textColor: selectedInCount > 0 ? Colors.white : null,
|
||||
textColor: selectedInCount > 0 ? ShadcnTheme.primaryForeground : null,
|
||||
icon: const Icon(Icons.local_shipping, size: 16),
|
||||
),
|
||||
ShadcnButton(
|
||||
@@ -1156,31 +1212,19 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final availableWidth = constraints.maxWidth;
|
||||
final minimumWidth = _getMinimumTableWidth(pagedEquipments, availableWidth);
|
||||
final needsHorizontalScroll = minimumWidth > availableWidth;
|
||||
|
||||
// ShadTable 경로로 일괄 전환 (가로 스크롤은 ShadTable 외부에서 처리)
|
||||
if (needsHorizontalScroll) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: _horizontalScrollController,
|
||||
child: SizedBox(
|
||||
width: minimumWidth,
|
||||
child: _buildShadTable(pagedEquipments, availableWidth: availableWidth),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final availableWidth = constraints.maxWidth;
|
||||
// 수평 스크롤 배제: 가용 너비 기준으로 컬럼 가감 처리 (내부에서 반응형 처리)
|
||||
return _buildShadTable(pagedEquipments, availableWidth: availableWidth);
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ class _EquipmentOutFormScreenState extends State<EquipmentOutFormScreen> {
|
||||
// 회사 이름을 표시하는 위젯 (지점 포함)
|
||||
Widget _buildCompanyDropdownItem(String item, EquipmentOutFormController controller) {
|
||||
final TextStyle defaultStyle = TextStyle(
|
||||
color: Colors.black87,
|
||||
color: ShadcnTheme.foreground,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
);
|
||||
@@ -758,7 +758,7 @@ class _EquipmentOutFormScreenState extends State<EquipmentOutFormScreen> {
|
||||
child: Icon(
|
||||
Icons.subdirectory_arrow_right,
|
||||
size: 16,
|
||||
color: Colors.grey,
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
),
|
||||
@@ -770,8 +770,8 @@ class _EquipmentOutFormScreenState extends State<EquipmentOutFormScreen> {
|
||||
TextSpan(text: ' ', style: defaultStyle),
|
||||
TextSpan(
|
||||
text: branchName, // 지점명
|
||||
style: const TextStyle(
|
||||
color: Colors.indigo,
|
||||
style: TextStyle(
|
||||
color: ShadcnTheme.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
),
|
||||
@@ -789,7 +789,7 @@ class _EquipmentOutFormScreenState extends State<EquipmentOutFormScreen> {
|
||||
style: defaultStyle, // 기본 스타일 설정
|
||||
children: [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.business, size: 16, color: Colors.black54),
|
||||
child: Icon(Icons.business, size: 16, color: ShadcnTheme.mutedForeground),
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
),
|
||||
TextSpan(text: ' ', style: defaultStyle),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
|
||||
/// 자동완성 텍스트 필드 위젯
|
||||
///
|
||||
@@ -136,16 +137,10 @@ class _AutocompleteTextFieldState extends State<AutocompleteTextField> {
|
||||
right: 0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
color: ShadcnTheme.card,
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
constraints: const BoxConstraints(maxHeight: 200),
|
||||
child: ListView.builder(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
|
||||
/// 드롭다운 기능이 있는 재사용 가능한 TextFormField 위젯
|
||||
class CustomDropdownField extends StatefulWidget {
|
||||
@@ -59,21 +60,14 @@ class _CustomDropdownFieldState extends State<CustomDropdownField> {
|
||||
showWhenUnlinked: false,
|
||||
offset: const Offset(0, 45),
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
elevation: 0,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
color: ShadcnTheme.card,
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
constraints: const BoxConstraints(maxHeight: 200),
|
||||
child: SingleChildScrollView(
|
||||
@@ -175,4 +169,4 @@ class _CustomDropdownFieldState extends State<CustomDropdownField> {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:superport/data/models/equipment_history_dto.dart';
|
||||
import 'package:superport/services/equipment_service.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
|
||||
/// 장비 이력을 표시하는 팝업 다이얼로그
|
||||
class EquipmentHistoryDialog extends StatefulWidget {
|
||||
@@ -190,17 +191,17 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
|
||||
Color _getTransactionTypeColor(String? type) {
|
||||
switch (type) {
|
||||
case 'I':
|
||||
return Colors.green;
|
||||
return ShadcnTheme.equipmentIn;
|
||||
case 'O':
|
||||
return Colors.blue;
|
||||
return ShadcnTheme.equipmentOut;
|
||||
case 'R':
|
||||
return Colors.orange;
|
||||
return ShadcnTheme.equipmentRepair;
|
||||
case 'T':
|
||||
return Colors.teal;
|
||||
return ShadcnTheme.equipmentRent;
|
||||
case 'D':
|
||||
return Colors.red;
|
||||
return ShadcnTheme.destructive;
|
||||
default:
|
||||
return Colors.grey;
|
||||
return ShadcnTheme.secondary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,16 +212,10 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.grey.shade200),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.02),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
@@ -359,15 +354,9 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
|
||||
minHeight: 400,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade50,
|
||||
color: ShadcnTheme.background,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.15),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
boxShadow: ShadcnTheme.shadowLg,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -375,13 +364,13 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
topRight: Radius.circular(12),
|
||||
),
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.shade200),
|
||||
bottom: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -580,13 +569,13 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(12),
|
||||
bottomRight: Radius.circular(12),
|
||||
),
|
||||
border: Border(
|
||||
top: BorderSide(color: Colors.grey.shade200),
|
||||
top: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -628,4 +617,4 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class _EquipmentRestoreDialogState extends State<EquipmentRestoreDialog> {
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -207,4 +207,4 @@ Future<bool?> showEquipmentRestoreDialog(
|
||||
onRestored: onRestored,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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 {
|
||||
@@ -13,7 +14,7 @@ class EquipmentStatusChip extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
// 캐시된 상태 정보 조회 시도
|
||||
String statusText = status;
|
||||
Color backgroundColor = Colors.grey;
|
||||
Color backgroundColor = ShadcnTheme.secondary;
|
||||
|
||||
try {
|
||||
final lookupsService = GetIt.instance<LookupsService>();
|
||||
@@ -37,46 +38,46 @@ class EquipmentStatusChip extends StatelessWidget {
|
||||
switch (status) {
|
||||
case EquipmentStatus.in_:
|
||||
case 'in':
|
||||
backgroundColor = Colors.green;
|
||||
backgroundColor = ShadcnTheme.equipmentIn;
|
||||
if (statusText == status) statusText = '입고';
|
||||
break;
|
||||
case EquipmentStatus.out:
|
||||
case 'out':
|
||||
backgroundColor = Colors.orange;
|
||||
backgroundColor = ShadcnTheme.equipmentOut;
|
||||
if (statusText == status) statusText = '출고';
|
||||
break;
|
||||
case EquipmentStatus.rent:
|
||||
case 'rent':
|
||||
backgroundColor = Colors.blue;
|
||||
backgroundColor = ShadcnTheme.equipmentRent;
|
||||
if (statusText == status) statusText = '대여';
|
||||
break;
|
||||
case EquipmentStatus.repair:
|
||||
case 'repair':
|
||||
backgroundColor = Colors.blue;
|
||||
backgroundColor = ShadcnTheme.equipmentRepair;
|
||||
if (statusText == status) statusText = '수리중';
|
||||
break;
|
||||
case EquipmentStatus.damaged:
|
||||
case 'damaged':
|
||||
backgroundColor = Colors.red;
|
||||
backgroundColor = ShadcnTheme.error;
|
||||
if (statusText == status) statusText = '손상';
|
||||
break;
|
||||
case EquipmentStatus.lost:
|
||||
case 'lost':
|
||||
backgroundColor = Colors.purple;
|
||||
backgroundColor = ShadcnTheme.purple;
|
||||
if (statusText == status) statusText = '분실';
|
||||
break;
|
||||
case EquipmentStatus.disposed:
|
||||
case 'disposed':
|
||||
backgroundColor = Colors.black;
|
||||
backgroundColor = ShadcnTheme.equipmentDisposal;
|
||||
if (statusText == status) statusText = '폐기';
|
||||
break;
|
||||
case EquipmentStatus.etc:
|
||||
case 'etc':
|
||||
backgroundColor = Colors.grey;
|
||||
backgroundColor = ShadcnTheme.secondary;
|
||||
if (statusText == status) statusText = '기타';
|
||||
break;
|
||||
default:
|
||||
backgroundColor = Colors.grey;
|
||||
backgroundColor = ShadcnTheme.equipmentUnknown;
|
||||
if (statusText == status) statusText = '알 수 없음';
|
||||
}
|
||||
|
||||
@@ -84,11 +85,15 @@ class EquipmentStatusChip extends StatelessWidget {
|
||||
return Chip(
|
||||
label: Text(
|
||||
statusText,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 12),
|
||||
style: ShadcnTheme.labelSmall.copyWith(color: ShadcnTheme.primaryForeground),
|
||||
),
|
||||
backgroundColor: backgroundColor,
|
||||
visualDensity: VisualDensity.compact,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusFull),
|
||||
side: BorderSide(color: backgroundColor.withValues(alpha: 0.2)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
|
||||
// 장비 요약 정보 행 위젯 (SRP, 재사용성)
|
||||
class EquipmentSummaryRow extends StatelessWidget {
|
||||
@@ -30,7 +31,9 @@ class EquipmentSummaryRow extends StatelessWidget {
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: value == '정보 없음' ? Colors.grey.shade600 : Colors.black,
|
||||
color: value == '정보 없음'
|
||||
? ShadcnTheme.mutedForeground
|
||||
: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -121,7 +121,7 @@ class _EquipmentHistoryDetailDialogState
|
||||
shape: BoxShape.circle,
|
||||
color: color,
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
width: 2,
|
||||
),
|
||||
boxShadow: [
|
||||
@@ -134,7 +134,7 @@ class _EquipmentHistoryDetailDialogState
|
||||
),
|
||||
child: Icon(
|
||||
_getTransactionIcon(history.transactionType),
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
@@ -163,7 +163,7 @@ class _EquipmentHistoryDetailDialogState
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
color: ShadcnTheme.foreground.withValues(alpha: 0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -534,4 +534,4 @@ class _EquipmentHistoryDetailDialogState
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'controllers/equipment_history_controller.dart';
|
||||
@@ -172,7 +173,7 @@ class _InventoryDashboardState extends State<InventoryDashboard> {
|
||||
),
|
||||
child: Text(
|
||||
history.transactionType == 'I' ? '입고' : '출고',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 12),
|
||||
style: TextStyle(color: ShadcnTheme.primaryForeground, fontSize: 12),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
@@ -255,4 +256,4 @@ class _InventoryDashboardState extends State<InventoryDashboard> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class _InventoryHistoryScreenState extends State<InventoryHistoryScreen> {
|
||||
text: '검색',
|
||||
onPressed: _onSearch,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: const Icon(Icons.search, size: 16),
|
||||
),
|
||||
),
|
||||
@@ -297,12 +297,12 @@ class _InventoryHistoryScreenState extends State<InventoryHistoryScreen> {
|
||||
),
|
||||
if (controller.hasActiveFilters) ...[
|
||||
const SizedBox(width: 8),
|
||||
const Text('|', style: TextStyle(color: Colors.grey)),
|
||||
Text('|', style: ShadcnTheme.bodySmall.copyWith(color: ShadcnTheme.mutedForeground)),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'필터링됨',
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: Colors.orange,
|
||||
color: ShadcnTheme.warning,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
@@ -404,63 +404,113 @@ class _InventoryHistoryScreenState extends State<InventoryHistoryScreen> {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('장비명')),
|
||||
ShadTableCell.header(child: Text('시리얼번호')),
|
||||
ShadTableCell.header(child: Text('위치')),
|
||||
ShadTableCell.header(child: Text('변동일')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
ShadTableCell.header(child: Text('비고')),
|
||||
],
|
||||
children: historyList.map((history) {
|
||||
return [
|
||||
// 장비명
|
||||
ShadTableCell(
|
||||
child: Tooltip(
|
||||
message: history.equipmentName,
|
||||
child: Text(history.equipmentName, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500)),
|
||||
),
|
||||
),
|
||||
// 시리얼번호
|
||||
ShadTableCell(
|
||||
child: Tooltip(
|
||||
message: history.serialNumber,
|
||||
child: Text(history.serialNumber, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall),
|
||||
),
|
||||
),
|
||||
// 위치
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(history.isCustomerLocation ? Icons.business : Icons.warehouse, size: 14, color: history.isCustomerLocation ? ShadcnTheme.companyCustomer : ShadcnTheme.equipmentIn),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(child: Text(history.location, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 고정폭 + 마지막 filler 컬럼
|
||||
const double actionsW = 160.0;
|
||||
const double minTableWidth = 260 + 200 + 260 + 140 + actionsW + 240 + 24;
|
||||
final double tableWidth = constraints.maxWidth >= minTableWidth
|
||||
? constraints.maxWidth
|
||||
: minTableWidth;
|
||||
const double remarkColumnWidth = 240.0;
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(260); // 장비명
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(200); // 시리얼
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(260); // 위치
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(140); // 변동일
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(actionsW); // 작업
|
||||
case 5:
|
||||
return const FixedTableSpanExtent(remarkColumnWidth); // 비고
|
||||
case 6:
|
||||
return const RemainingTableSpanExtent(); // filler
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('장비명')),
|
||||
const ShadTableCell.header(child: Text('시리얼번호')),
|
||||
const ShadTableCell.header(child: Text('위치')),
|
||||
const ShadTableCell.header(child: Text('변동일')),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('작업'))),
|
||||
ShadTableCell.header(child: SizedBox(width: remarkColumnWidth, child: const Text('비고'))),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 변동일
|
||||
ShadTableCell(child: Text(history.formattedDate, style: ShadcnTheme.bodySmall)),
|
||||
// 작업
|
||||
children: historyList.map((history) {
|
||||
return [
|
||||
// 장비명
|
||||
ShadTableCell(
|
||||
child: Tooltip(
|
||||
message: history.equipmentName,
|
||||
child: Text(history.equipmentName, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500)),
|
||||
),
|
||||
),
|
||||
// 시리얼번호
|
||||
ShadTableCell(
|
||||
child: Tooltip(
|
||||
message: history.serialNumber,
|
||||
child: Text(history.serialNumber, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall),
|
||||
),
|
||||
),
|
||||
// 위치
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(history.isCustomerLocation ? Icons.business : Icons.warehouse, size: 14, color: history.isCustomerLocation ? ShadcnTheme.companyCustomer : ShadcnTheme.equipmentIn),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(child: Text(history.location, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 변동일
|
||||
ShadTableCell(child: Text(history.formattedDate, style: ShadcnTheme.bodySmall)),
|
||||
// 작업
|
||||
ShadTableCell(
|
||||
child: ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEquipmentHistoryDetail(history),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [Icon(Icons.history, size: 14), SizedBox(width: 4), Text('상세보기', style: TextStyle(fontSize: 12))],
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEquipmentHistoryDetail(history),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [Icon(Icons.history, size: 14), SizedBox(width: 4), Text('상세보기', style: TextStyle(fontSize: 12))],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 비고
|
||||
ShadTableCell(
|
||||
child: Tooltip(
|
||||
message: history.remark ?? '비고 없음',
|
||||
child: Text(history.remark ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall.copyWith(color: ShadcnTheme.mutedForeground)),
|
||||
// 비고
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: remarkColumnWidth,
|
||||
child: Tooltip(
|
||||
message: history.remark ?? '비고 없음',
|
||||
child: Text(history.remark ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall.copyWith(color: ShadcnTheme.mutedForeground)),
|
||||
),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
];
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -491,15 +541,14 @@ class _InventoryHistoryScreenState extends State<InventoryHistoryScreen> {
|
||||
// 데이터 테이블
|
||||
dataTable: _buildDataTable(controller.historyItems),
|
||||
|
||||
// 페이지네이션
|
||||
pagination: controller.totalPages > 1
|
||||
? Pagination(
|
||||
totalCount: controller.totalCount,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: controller.pageSize,
|
||||
onPageChanged: (page) => controller.goToPage(page),
|
||||
)
|
||||
: null,
|
||||
// 페이지네이션 (항상 표시)
|
||||
pagination: Pagination(
|
||||
totalCount: controller.totalCount,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: controller.pageSize,
|
||||
onPageChanged: (page) => controller.goToPage(page),
|
||||
),
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -145,7 +145,7 @@ class _LoginViewState extends State<LoginView>
|
||||
child: Icon(
|
||||
Icons.directions_boat,
|
||||
size: 48,
|
||||
color: Colors.white,
|
||||
color: theme.colorScheme.primaryForeground,
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -251,12 +251,12 @@ class _LoginViewState extends State<LoginView>
|
||||
onPressed: controller.isLoading ? null : _handleLogin,
|
||||
size: ShadButtonSize.lg,
|
||||
child: controller.isLoading
|
||||
? const SizedBox(
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(ShadTheme.of(context).colorScheme.primaryForeground),
|
||||
),
|
||||
)
|
||||
: const Text('로그인'),
|
||||
@@ -331,4 +331,4 @@ class _LoginViewState extends State<LoginView>
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../data/models/maintenance_dto.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
|
||||
class MaintenanceCalendar extends StatefulWidget {
|
||||
final List<MaintenanceDto> maintenances;
|
||||
@@ -42,14 +43,8 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
color: ShadcnTheme.card,
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -104,9 +99,11 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Text(
|
||||
weekdays[i],
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: i == 0 ? Colors.red : (i == 6 ? Colors.blue : Colors.black),
|
||||
style: ShadcnTheme.labelMedium.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: i == 0
|
||||
? ShadcnTheme.destructive
|
||||
: (i == 6 ? ShadcnTheme.accent : ShadcnTheme.foreground),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -140,15 +137,15 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
margin: const EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? Theme.of(context).primaryColor.withValues(alpha: 0.2)
|
||||
? ShadcnTheme.primary.withValues(alpha: 0.12)
|
||||
: isToday
|
||||
? Colors.blue.withValues(alpha: 0.1)
|
||||
? ShadcnTheme.accent.withValues(alpha: 0.08)
|
||||
: Colors.transparent,
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? Theme.of(context).primaryColor
|
||||
? ShadcnTheme.primary
|
||||
: isToday
|
||||
? Colors.blue
|
||||
? ShadcnTheme.accent
|
||||
: Colors.transparent,
|
||||
width: isSelected || isToday ? 2 : 1,
|
||||
),
|
||||
@@ -162,11 +159,13 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
left: 8,
|
||||
child: Text(
|
||||
day.toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: isToday ? FontWeight.bold : FontWeight.normal,
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
fontWeight: isToday ? FontWeight.w700 : FontWeight.w400,
|
||||
color: isWeekend
|
||||
? (date.weekday == DateTime.sunday ? Colors.red : Colors.blue)
|
||||
: Colors.black,
|
||||
? (date.weekday == DateTime.sunday
|
||||
? ShadcnTheme.destructive
|
||||
: ShadcnTheme.accent)
|
||||
: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -188,9 +187,9 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
),
|
||||
child: Text(
|
||||
'#${m.equipmentHistoryId}',
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.white,
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -207,14 +206,14 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[600],
|
||||
color: ShadcnTheme.secondaryDark,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Text(
|
||||
'+${dayMaintenances.length - 3}',
|
||||
style: const TextStyle(
|
||||
fontSize: 8,
|
||||
color: Colors.white,
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
fontSize: 9,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -276,24 +275,23 @@ class _MaintenanceCalendarState extends State<MaintenanceCalendar> {
|
||||
|
||||
switch (status.toLowerCase()) {
|
||||
case 'overdue':
|
||||
return Colors.red;
|
||||
return ShadcnTheme.alertExpired;
|
||||
case 'scheduled':
|
||||
case 'upcoming':
|
||||
// nextMaintenanceDate 필드가 없으므로 startedAt 기반으로 계산
|
||||
final daysUntil = maintenance.startedAt.difference(DateTime.now()).inDays;
|
||||
if (daysUntil <= 7) {
|
||||
return Colors.orange;
|
||||
return ShadcnTheme.alertWarning30;
|
||||
} else if (daysUntil <= 30) {
|
||||
return Colors.yellow[700]!;
|
||||
return ShadcnTheme.alertWarning60;
|
||||
}
|
||||
return Colors.blue;
|
||||
return ShadcnTheme.info;
|
||||
case 'inprogress':
|
||||
case 'ongoing':
|
||||
return Colors.purple;
|
||||
return ShadcnTheme.purple;
|
||||
case 'completed':
|
||||
return Colors.green;
|
||||
return ShadcnTheme.success;
|
||||
default:
|
||||
return Colors.grey;
|
||||
return ShadcnTheme.secondary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
import 'package:superport/data/models/maintenance_dto.dart';
|
||||
import 'package:superport/data/models/equipment_history_dto.dart';
|
||||
import 'package:superport/data/repositories/equipment_history_repository.dart';
|
||||
@@ -563,7 +564,7 @@ class MaintenanceController extends ChangeNotifier {
|
||||
case '완료': return Colors.grey;
|
||||
case '만료됨': return Colors.red;
|
||||
case '삭제됨': return Colors.grey.withValues(alpha: 0.5);
|
||||
default: return Colors.black;
|
||||
default: return ShadcnTheme.foreground;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,8 +637,13 @@ class MaintenanceController extends ChangeNotifier {
|
||||
// 백엔드에서 직접 제공하는 company_name 사용
|
||||
debugPrint('getCompanyName - ID: ${maintenance.id}, companyName: "${maintenance.companyName}", companyId: ${maintenance.companyId}');
|
||||
|
||||
if (maintenance.companyName != null && maintenance.companyName!.isNotEmpty) {
|
||||
return maintenance.companyName!;
|
||||
final name = maintenance.companyName;
|
||||
if (name != null) {
|
||||
final trimmed = name.trim();
|
||||
// 백엔드가 문자열 'null'을 반환하는 케이스 방지
|
||||
if (trimmed.isNotEmpty && trimmed.toLowerCase() != 'null') {
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
return '-';
|
||||
}
|
||||
@@ -707,4 +713,4 @@ class MaintenanceController extends ChangeNotifier {
|
||||
reset();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,15 +99,8 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
color: ShadcnTheme.card,
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -132,7 +125,7 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
.length;
|
||||
return Text(
|
||||
'완료된 유지보수: $completedCount건',
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
style: ShadcnTheme.bodySmall.copyWith(color: ShadcnTheme.mutedForeground),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -272,9 +265,9 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.card,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey[300]!),
|
||||
bottom: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -298,7 +291,7 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Theme.of(context).primaryColor : Colors.grey[100],
|
||||
color: isSelected ? ShadcnTheme.primary : ShadcnTheme.muted,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
@@ -307,13 +300,13 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: isSelected ? Colors.white : Colors.grey[600],
|
||||
color: isSelected ? ShadcnTheme.primaryForeground : ShadcnTheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: isSelected ? Colors.white : Colors.grey[600],
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: isSelected ? ShadcnTheme.primaryForeground : ShadcnTheme.mutedForeground,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
@@ -374,8 +367,8 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
),
|
||||
child: Text(
|
||||
DateFormat('yyyy년 MM월 dd일').format(DateTime.parse(date)),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
style: TextStyle(
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
@@ -394,15 +387,9 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
margin: const EdgeInsets.only(left: 20, bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: Theme.of(context).primaryColor,
|
||||
@@ -547,8 +534,8 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
color: index.isEven
|
||||
? ShadcnTheme.muted.withValues(alpha: 0.1)
|
||||
: null,
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Colors.black),
|
||||
border: Border(
|
||||
bottom: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -634,7 +621,7 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
@@ -644,7 +631,7 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: Colors.black)),
|
||||
border: Border(bottom: BorderSide(color: ShadcnTheme.border)),
|
||||
),
|
||||
child: Row(children: _buildHeaderCells()),
|
||||
),
|
||||
@@ -743,15 +730,9 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.card,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
boxShadow: ShadcnTheme.shadowMd,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -931,10 +912,10 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
Text(
|
||||
'통계 요약',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -961,15 +942,15 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.8),
|
||||
color: ShadcnTheme.primaryForeground.withValues(alpha: 0.8),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
style: TextStyle(
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -1048,4 +1029,4 @@ class _MaintenanceHistoryScreenState extends State<MaintenanceHistoryScreen>
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,59 +283,84 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// 고정 헤더
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: ShadcnTheme.spacing4, vertical: ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: ShadcnTheme.border)),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(ShadcnTheme.radiusMd),
|
||||
topRight: Radius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: _horizontalScrollController,
|
||||
child: _buildFixedHeader(),
|
||||
),
|
||||
),
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 기본 컬럼 폭 합산
|
||||
const double selectW = 60;
|
||||
const double idW = 80;
|
||||
const double equipInfoBaseW = 200; // 이 컬럼이 남는 폭을 흡수
|
||||
const double typeW = 120;
|
||||
const double startW = 100;
|
||||
const double endW = 100;
|
||||
const double periodW = 80;
|
||||
const double statusW = 100;
|
||||
const double remainW = 100;
|
||||
const double actionsW = 120;
|
||||
|
||||
// 스크롤 가능한 바디
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: _horizontalScrollController,
|
||||
child: SizedBox(
|
||||
width: _calculateTableWidth(),
|
||||
child: ListView.builder(
|
||||
itemCount: maintenances.length,
|
||||
itemBuilder: (context, index) => _buildTableRow(maintenances[index], index),
|
||||
double baseWidth = selectW + idW + equipInfoBaseW + typeW + startW + endW + actionsW;
|
||||
if (_showDetailedColumns) {
|
||||
baseWidth += periodW + statusW + remainW;
|
||||
}
|
||||
|
||||
final extra = (constraints.maxWidth - baseWidth);
|
||||
final double equipInfoWidth = equipInfoBaseW + (extra > 0 ? extra : 0.0);
|
||||
final double tableWidth = (constraints.maxWidth > baseWidth) ? constraints.maxWidth : baseWidth;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// 고정 헤더
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: ShadcnTheme.spacing4, vertical: ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: ShadcnTheme.border)),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(ShadcnTheme.radiusMd),
|
||||
topRight: Radius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: _horizontalScrollController,
|
||||
child: _buildFixedHeader(equipInfoWidth, tableWidth),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 스크롤 가능한 바디
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: _horizontalScrollController,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ListView.builder(
|
||||
itemCount: maintenances.length,
|
||||
itemBuilder: (context, index) => _buildTableRow(maintenances[index], index, equipInfoWidth),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 고정 헤더 빌드
|
||||
Widget _buildFixedHeader() {
|
||||
Widget _buildFixedHeader(double equipInfoWidth, double tableWidth) {
|
||||
return SizedBox(
|
||||
width: _calculateTableWidth(),
|
||||
width: tableWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
_buildHeaderCell('선택', 60),
|
||||
_buildHeaderCell('ID', 80),
|
||||
_buildHeaderCell('장비 정보', 200),
|
||||
_buildHeaderCell('장비 정보', equipInfoWidth),
|
||||
_buildHeaderCell('유지보수 타입', 120),
|
||||
_buildHeaderCell('시작일', 100),
|
||||
_buildHeaderCell('종료일', 100),
|
||||
@@ -350,14 +375,7 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 테이블 총 너비 계산
|
||||
double _calculateTableWidth() {
|
||||
double width = 60 + 80 + 200 + 120 + 100 + 100 + 120; // 기본 컬럼들
|
||||
if (_showDetailedColumns) {
|
||||
width += 80 + 100 + 100; // 상세 컬럼들
|
||||
}
|
||||
return width;
|
||||
}
|
||||
// 기존 _calculateTableWidth 제거: LayoutBuilder에서 계산
|
||||
|
||||
/// 헤더 셀 빌드
|
||||
Widget _buildHeaderCell(String text, double width) {
|
||||
@@ -372,7 +390,7 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
}
|
||||
|
||||
/// 테이블 행 빌드
|
||||
Widget _buildTableRow(MaintenanceDto maintenance, int index) {
|
||||
Widget _buildTableRow(MaintenanceDto maintenance, int index, double equipInfoWidth) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: index.isEven ? ShadcnTheme.muted.withValues(alpha: 0.1) : null,
|
||||
@@ -412,9 +430,9 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
),
|
||||
),
|
||||
|
||||
// 장비 정보
|
||||
// 장비 정보 (가변 폭)
|
||||
SizedBox(
|
||||
width: 200,
|
||||
width: equipInfoWidth,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -448,9 +466,9 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
),
|
||||
child: Text(
|
||||
MaintenanceType.getDisplayName(maintenance.maintenanceType),
|
||||
style: const TextStyle(
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
fontSize: 12,
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -498,9 +516,9 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
),
|
||||
child: Text(
|
||||
_controller.getMaintenanceStatusText(maintenance),
|
||||
style: const TextStyle(
|
||||
style: ShadcnTheme.caption.copyWith(
|
||||
fontSize: 12,
|
||||
color: Colors.white,
|
||||
color: ShadcnTheme.primaryForeground,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -729,4 +747,4 @@ class _MaintenanceListState extends State<MaintenanceList> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../domain/entities/maintenance_schedule.dart';
|
||||
import 'controllers/maintenance_controller.dart';
|
||||
import 'maintenance_form_dialog.dart';
|
||||
import 'components/maintenance_calendar.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
|
||||
class MaintenanceScheduleScreen extends StatefulWidget {
|
||||
const MaintenanceScheduleScreen({super.key});
|
||||
@@ -42,7 +43,7 @@ class _MaintenanceScheduleScreenState extends State<MaintenanceScheduleScreen>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
backgroundColor: ShadcnTheme.backgroundSecondary,
|
||||
body: Column(
|
||||
children: [
|
||||
_buildHeader(),
|
||||
@@ -97,15 +98,8 @@ class _MaintenanceScheduleScreenState extends State<MaintenanceScheduleScreen>
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
color: ShadcnTheme.card,
|
||||
boxShadow: ShadcnTheme.shadowSm,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -128,9 +122,7 @@ class _MaintenanceScheduleScreenState extends State<MaintenanceScheduleScreen>
|
||||
'총 ${controller.totalCount}건 | '
|
||||
'예정 ${controller.upcomingCount}건 | '
|
||||
'지연 ${controller.overdueCount}건',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
style: ShadcnTheme.bodySmall.copyWith(color: ShadcnTheme.mutedForeground),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -183,8 +175,8 @@ class _MaintenanceScheduleScreenState extends State<MaintenanceScheduleScreen>
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(bottom: BorderSide(color: Colors.grey[300]!)),
|
||||
color: ShadcnTheme.card,
|
||||
border: Border(bottom: BorderSide(color: ShadcnTheme.border)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -201,7 +193,7 @@ class _MaintenanceScheduleScreenState extends State<MaintenanceScheduleScreen>
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey[300]!),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
@@ -464,7 +456,7 @@ class _MaintenanceScheduleScreenState extends State<MaintenanceScheduleScreen>
|
||||
return Chip(
|
||||
label: Text(
|
||||
'${alert.daysUntilDue < 0 ? "지연 " : ""}${alert.daysUntilDue.abs()}일',
|
||||
style: TextStyle(fontSize: 12, color: Colors.white),
|
||||
style: TextStyle(fontSize: 12, color: ShadcnTheme.primaryForeground),
|
||||
),
|
||||
backgroundColor: color,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
|
||||
@@ -94,6 +94,7 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
isLoading: controller.isLoading,
|
||||
error: controller.errorMessage,
|
||||
onRefresh: () => controller.loadInitialData(),
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -245,41 +246,105 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('ID')),
|
||||
ShadTableCell.header(child: Text('제조사')),
|
||||
ShadTableCell.header(child: Text('모델명')),
|
||||
ShadTableCell.header(child: Text('등록일')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
],
|
||||
children: currentPageModels.map((model) {
|
||||
final vendor = _controller.getVendorById(model.vendorsId);
|
||||
return [
|
||||
ShadTableCell(child: Text(model.id.toString(), style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text(vendor?.name ?? '알 수 없음', overflow: TextOverflow.ellipsis)),
|
||||
ShadTableCell(child: Text(model.name, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500))),
|
||||
ShadTableCell(child: Text(model.registeredAt != null ? DateFormat('yyyy-MM-dd').format(model.registeredAt) : '-', style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: _buildStatusChip(model.isDeleted)),
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showEditDialog(model),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showDeleteConfirmDialog(model),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 고정폭 + 마지막 filler 컬럼이 남는 폭을 흡수
|
||||
const double actionsW = 200.0;
|
||||
const double minTableWidth = 80 + 260 + 320 + 120 + 100 + actionsW + 24;
|
||||
final double tableWidth = constraints.maxWidth >= minTableWidth
|
||||
? constraints.maxWidth
|
||||
: minTableWidth;
|
||||
const double modelColumnWidth = 320.0;
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(80); // ID
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(260); // 제조사
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(modelColumnWidth); // 모델명
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(120); // 등록일
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(100); // 상태
|
||||
case 5:
|
||||
return const FixedTableSpanExtent(actionsW); // 작업
|
||||
case 6:
|
||||
return const RemainingTableSpanExtent(); // filler
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('ID')),
|
||||
const ShadTableCell.header(child: Text('제조사')),
|
||||
ShadTableCell.header(child: SizedBox(width: modelColumnWidth, child: const Text('모델명'))),
|
||||
ShadTableCell.header(child: SizedBox(width: 120, child: const Text('등록일'))),
|
||||
ShadTableCell.header(child: SizedBox(width: 100, child: const Text('상태'))),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('작업'))),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: currentPageModels.map((model) {
|
||||
final vendor = _controller.getVendorById(model.vendorsId);
|
||||
return [
|
||||
ShadTableCell(child: Text(model.id.toString(), style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text(vendor?.name ?? '알 수 없음', overflow: TextOverflow.ellipsis)),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: modelColumnWidth,
|
||||
child: Text(
|
||||
model.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
model.registeredAt != null ? DateFormat('yyyy-MM-dd').format(model.registeredAt) : '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
ShadTableCell(child: SizedBox(width: 100, child: _buildStatusChip(model.isDeleted))),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showEditDialog(model),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showDeleteConfirmDialog(model),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
];
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -290,27 +355,6 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
final totalCount = controller.models.length;
|
||||
final totalPages = _getTotalPages();
|
||||
|
||||
if (totalCount <= _pageSize) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
border: Border(
|
||||
top: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'총 $totalCount개 모델',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
@@ -171,13 +172,13 @@ class _RentFormDialogState extends State<RentFormDialog> {
|
||||
|
||||
// 3단계 상태 처리 (UserForm 패턴 적용)
|
||||
_isLoadingHistories
|
||||
? const SizedBox(
|
||||
? SizedBox(
|
||||
height: 56,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ShadProgress(),
|
||||
children: const [
|
||||
SizedBox(width: 120, child: ShadProgress()),
|
||||
SizedBox(width: 8),
|
||||
Text('장비 이력을 불러오는 중...'),
|
||||
],
|
||||
@@ -229,33 +230,33 @@ class _RentFormDialogState extends State<RentFormDialog> {
|
||||
options: _historyController.historyList.map((history) {
|
||||
return ShadOption(
|
||||
value: history.id!,
|
||||
child: Row(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'${history.equipment?.serialNumber ?? "Serial N/A"} - ${history.equipment?.modelName ?? "Model N/A"}',
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
'거래: ${history.transactionType} | 수량: ${history.quantity} | ${history.transactedAt.toString().split(' ')[0]}',
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'${history.equipment?.serialNumber ?? "Serial N/A"} - ${history.equipment?.modelName ?? "Model N/A"}',
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
'거래: ${history.transactionType} | 수량: ${history.quantity} | ${history.transactedAt.toString().split(' ')[0]}',
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (_historyController.historyList.isEmpty) {
|
||||
return const Text('이력 없음');
|
||||
}
|
||||
final selectedHistory = _historyController.historyList
|
||||
.firstWhere((h) => h.id == value);
|
||||
.firstWhere(
|
||||
(h) => h.id == value,
|
||||
orElse: () => _historyController.historyList.first,
|
||||
);
|
||||
return Text(
|
||||
'${selectedHistory.equipment?.serialNumber ?? "Serial N/A"} - ${selectedHistory.equipment?.modelName ?? "Model N/A"}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -328,7 +329,7 @@ class _RentFormDialogState extends State<RentFormDialog> {
|
||||
: '날짜 선택',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: _endDate != null ? Colors.black : Colors.grey,
|
||||
color: _endDate != null ? ShadcnTheme.foreground : ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -397,4 +398,4 @@ class _RentFormDialogState extends State<RentFormDialog> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
}
|
||||
|
||||
|
||||
/// 데이터 테이블 빌더
|
||||
/// 데이터 테이블 빌더 (ShadTable)
|
||||
Widget _buildDataTable(RentController controller) {
|
||||
final rents = controller.rents;
|
||||
|
||||
@@ -185,18 +185,9 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.business_center_outlined,
|
||||
size: 64,
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
Icon(Icons.business_center_outlined, size: 64, color: ShadcnTheme.mutedForeground),
|
||||
const SizedBox(height: ShadcnTheme.spacing4),
|
||||
Text(
|
||||
'등록된 임대 계약이 없습니다',
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
Text('등록된 임대 계약이 없습니다', style: ShadcnTheme.bodyMedium.copyWith(color: ShadcnTheme.mutedForeground)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -207,40 +198,109 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// 고정 헤더
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: ShadcnTheme.spacing4, vertical: ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: ShadcnTheme.border)),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(ShadcnTheme.radiusMd),
|
||||
topRight: Radius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildHeaderCell('ID', 60),
|
||||
_buildHeaderCell('장비 이력 ID', 120),
|
||||
_buildHeaderCell('시작일', 100),
|
||||
_buildHeaderCell('종료일', 100),
|
||||
_buildHeaderCell('기간 (일)', 80),
|
||||
_buildHeaderCell('상태', 80),
|
||||
_buildHeaderCell('작업', 140),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 고정폭 + 마지막 filler
|
||||
const double idW = 60;
|
||||
const double equipHistoryW = 180;
|
||||
const double startW = 120;
|
||||
const double endW = 120;
|
||||
const double daysW = 80;
|
||||
const double statusW = 80;
|
||||
const double actionsW = 160;
|
||||
|
||||
// 스크롤 가능한 바디
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: rents.length,
|
||||
itemBuilder: (context, index) => _buildTableRow(rents[index], index),
|
||||
),
|
||||
),
|
||||
],
|
||||
final double minTableWidth = idW + equipHistoryW + startW + endW + daysW + statusW + actionsW + 24;
|
||||
final double tableWidth = constraints.maxWidth >= minTableWidth ? constraints.maxWidth : minTableWidth;
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(idW);
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(equipHistoryW);
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(startW);
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(endW);
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(daysW);
|
||||
case 5:
|
||||
return const FixedTableSpanExtent(statusW);
|
||||
case 6:
|
||||
return const FixedTableSpanExtent(actionsW);
|
||||
case 7:
|
||||
return const RemainingTableSpanExtent();
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('ID')),
|
||||
ShadTableCell.header(child: Text('장비 이력 ID')),
|
||||
ShadTableCell.header(child: Text('시작일')),
|
||||
ShadTableCell.header(child: Text('종료일')),
|
||||
ShadTableCell.header(child: Text('기간 (일)')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: rents.map((rent) {
|
||||
final days = _controller.calculateRentDays(rent.startedAt, rent.endedAt);
|
||||
final status = _controller.getRentStatus(rent);
|
||||
return [
|
||||
ShadTableCell(child: Text(rent.id?.toString() ?? '-', style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text(rent.equipmentHistoryId.toString(), style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text(DateFormat('yyyy-MM-dd').format(rent.startedAt), style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text(DateFormat('yyyy-MM-dd').format(rent.endedAt), style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text('$days', style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: _buildStatusChip(status)),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEditDialog(rent),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
if (status == '진행중')
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _returnRent(rent),
|
||||
child: const Icon(Icons.assignment_return, size: 16),
|
||||
),
|
||||
if (status == '진행중') const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _deleteRent(rent),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -257,7 +317,7 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
}
|
||||
|
||||
/// 테이블 행 빌드
|
||||
Widget _buildTableRow(RentDto rent, int index) {
|
||||
Widget _buildTableRow(RentDto rent, int index, double equipHistoryW) {
|
||||
final days = _controller.calculateRentDays(rent.startedAt, rent.endedAt);
|
||||
final status = _controller.getRentStatus(rent);
|
||||
|
||||
@@ -285,7 +345,7 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
|
||||
// 장비 이력 ID
|
||||
SizedBox(
|
||||
width: 120,
|
||||
width: equipHistoryW,
|
||||
child: Text(
|
||||
rent.equipmentHistoryId.toString(),
|
||||
style: ShadcnTheme.bodyMedium,
|
||||
@@ -327,34 +387,38 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
|
||||
// 작업 버튼들
|
||||
SizedBox(
|
||||
width: 140,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEditDialog(rent),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
if (status == '진행중')
|
||||
width: 180,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _returnRent(rent),
|
||||
child: const Icon(Icons.assignment_return, size: 16),
|
||||
onPressed: () => _showEditDialog(rent),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
if (status == '진행중')
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _deleteRent(rent),
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
size: 16,
|
||||
color: ShadcnTheme.destructive,
|
||||
if (status == '진행중')
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _returnRent(rent),
|
||||
child: const Icon(Icons.assignment_return, size: 16),
|
||||
),
|
||||
if (status == '진행중')
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _deleteRent(rent),
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
size: 16,
|
||||
color: ShadcnTheme.destructive,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -445,21 +509,14 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
Widget? _buildPagination() {
|
||||
return Consumer<RentController>(
|
||||
builder: (context, controller, child) {
|
||||
// 항상 페이지네이션 정보 표시 (총 개수라도)
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: ShadcnTheme.spacing2),
|
||||
child: controller.totalPages > 1
|
||||
? Pagination(
|
||||
totalCount: controller.totalRents,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: AppConstants.rentPageSize,
|
||||
onPageChanged: (page) => controller.loadRents(page: page),
|
||||
)
|
||||
: Text(
|
||||
'총 ${controller.totalRents}개 임대 계약',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
child: Pagination(
|
||||
totalCount: controller.totalRents,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: AppConstants.rentPageSize,
|
||||
onPageChanged: (page) => controller.loadRents(page: page),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -481,9 +538,10 @@ class _RentListScreenState extends State<RentListScreen> {
|
||||
onRefresh: () => controller.loadRents(refresh: true),
|
||||
emptyMessage: '등록된 임대 계약이 없습니다',
|
||||
emptyIcon: Icons.business_center_outlined,
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ class _UserListState extends State<UserList> {
|
||||
isLoading: _controller.isLoading && _controller.users.isEmpty,
|
||||
error: _controller.error,
|
||||
onRefresh: () => _controller.loadUsers(refresh: true),
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -298,55 +299,109 @@ class _UserListState extends State<UserList> {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('번호')),
|
||||
ShadTableCell.header(child: Text('이름')),
|
||||
ShadTableCell.header(child: Text('이메일')),
|
||||
ShadTableCell.header(child: Text('회사')),
|
||||
ShadTableCell.header(child: Text('권한')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < users.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(child: Text(((_controller.currentPage - 1) * _controller.pageSize + index + 1).toString(), style: ShadcnTheme.bodySmall)),
|
||||
// 이름
|
||||
ShadTableCell(child: Text(users[index].name, overflow: TextOverflow.ellipsis)),
|
||||
// 이메일
|
||||
ShadTableCell(child: Text(users[index].email ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
// 회사
|
||||
ShadTableCell(child: Text(users[index].companyName ?? '-', overflow: TextOverflow.ellipsis)),
|
||||
// 권한
|
||||
ShadTableCell(child: _buildUserRoleBadge(users[index].role)),
|
||||
// 상태
|
||||
ShadTableCell(child: _buildStatusChip(users[index].isActive)),
|
||||
// 작업
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: users[index].id != null ? () => _navigateToEdit(users[index].id!) : null,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showStatusChangeDialog(users[index]),
|
||||
child: Icon(users[index].isActive ? Icons.person_off : Icons.person, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: users[index].id != null ? () => _showDeleteDialog(users[index].id!, users[index].name) : null,
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 고정폭 + 마지막 filler 컬럼
|
||||
const double actionsW = 240.0; // 아이콘 3개
|
||||
const double minTableWidth = 64 + 200 + 300 + 200 + 120 + 120 + actionsW + 24;
|
||||
final double tableWidth = constraints.maxWidth >= minTableWidth
|
||||
? constraints.maxWidth
|
||||
: minTableWidth;
|
||||
const double emailColumnWidth = 300.0;
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(64); // 번호
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(200); // 이름
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(emailColumnWidth); // 이메일
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(200); // 회사
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(120); // 권한
|
||||
case 5:
|
||||
return const FixedTableSpanExtent(120); // 상태
|
||||
case 6:
|
||||
return const FixedTableSpanExtent(actionsW); // 작업
|
||||
case 7:
|
||||
return const RemainingTableSpanExtent(); // filler
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('번호')),
|
||||
const ShadTableCell.header(child: Text('이름')),
|
||||
ShadTableCell.header(child: SizedBox(width: emailColumnWidth, child: const Text('이메일'))),
|
||||
const ShadTableCell.header(child: Text('회사')),
|
||||
const ShadTableCell.header(child: Text('권한')),
|
||||
const ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('작업'))),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < users.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(child: Text(((_controller.currentPage - 1) * _controller.pageSize + index + 1).toString(), style: ShadcnTheme.bodySmall)),
|
||||
// 이름
|
||||
ShadTableCell(child: Text(users[index].name, overflow: TextOverflow.ellipsis)),
|
||||
// 이메일
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: emailColumnWidth,
|
||||
child: Text(users[index].email ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall),
|
||||
),
|
||||
),
|
||||
// 회사
|
||||
ShadTableCell(child: Text(users[index].companyName ?? '-', overflow: TextOverflow.ellipsis)),
|
||||
// 권한
|
||||
ShadTableCell(child: _buildUserRoleBadge(users[index].role)),
|
||||
// 상태
|
||||
ShadTableCell(child: _buildStatusChip(users[index].isActive)),
|
||||
// 작업 (오버플로우 방지)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: users[index].id != null ? () => _navigateToEdit(users[index].id!) : null,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showStatusChangeDialog(users[index]),
|
||||
child: Icon(users[index].isActive ? Icons.person_off : Icons.person, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: users[index].id != null ? () => _showDeleteDialog(users[index].id!, users[index].name) : null,
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -355,8 +410,6 @@ class _UserListState extends State<UserList> {
|
||||
// (Deprecated) 기존 커스텀 테이블 빌더 유틸들은 ShadTable 전환으로 제거되었습니다.
|
||||
|
||||
Widget _buildPagination() {
|
||||
if (_controller.totalPages <= 1) return const SizedBox();
|
||||
|
||||
return Pagination(
|
||||
currentPage: _controller.currentPage,
|
||||
totalCount: _controller.total,
|
||||
|
||||
307
lib/screens/vendor/components/vendor_table.dart
vendored
307
lib/screens/vendor/components/vendor_table.dart
vendored
@@ -31,109 +31,216 @@ class VendorTable extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShadCard(
|
||||
child: SingleChildScrollView(
|
||||
child: DataTable(
|
||||
horizontalMargin: 16,
|
||||
columnSpacing: 24,
|
||||
columns: const [
|
||||
DataColumn(label: Text('No')),
|
||||
DataColumn(label: Text('벤더명')),
|
||||
DataColumn(label: Text('등록일')),
|
||||
DataColumn(label: Text('상태')),
|
||||
DataColumn(label: Text('작업')),
|
||||
],
|
||||
rows: vendors.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final vendor = entry.value;
|
||||
final rowNumber = (currentPage - 1) * AppConstants.vendorPageSize + index + 1;
|
||||
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(
|
||||
Text(
|
||||
rowNumber.toString(),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Text(
|
||||
vendor.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Text(
|
||||
vendor.createdAt != null
|
||||
? vendor.createdAt!.toLocal().toString().split(' ')[0]
|
||||
: '-',
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: vendor.isActive
|
||||
? Colors.green.withValues(alpha: 0.1)
|
||||
: Colors.grey.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
vendor.isActive ? '활성' : '비활성',
|
||||
style: TextStyle(
|
||||
color: vendor.isActive
|
||||
? Colors.green.shade700
|
||||
: Colors.grey.shade700,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 최소폭 추정: No(64) + 벤더명(240) + 등록일(140) + 상태(120) + 작업(200) + 여백(24)
|
||||
const double actionsW = 256.0; // 아이콘 2개 + 내부 패딩 여유(단일 행 유지)
|
||||
const double minW = 64 + 240 + 140 + 120 + actionsW + 24;
|
||||
final double extra = constraints.maxWidth - minW;
|
||||
final double tableW = extra >= 0 ? constraints.maxWidth : minW;
|
||||
const double nameBase = 240.0;
|
||||
final double nameW = nameBase; // 넓은 화면에서도 벤더명은 고정 폭, 남는 폭은 빈 컬럼이 흡수
|
||||
|
||||
// 스크롤이 필요 없으면 전체 폭 사용
|
||||
if (constraints.maxWidth >= minW) {
|
||||
return SizedBox(
|
||||
width: constraints.maxWidth,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(64);
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(nameBase);
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(120);
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(100);
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(actionsW);
|
||||
case 5:
|
||||
return const RemainingTableSpanExtent();
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('No')),
|
||||
ShadTableCell.header(child: SizedBox(width: nameW, child: const Text('벤더명'))),
|
||||
const ShadTableCell.header(child: Text('등록일')),
|
||||
const ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('작업'))),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: vendors.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final vendor = entry.value;
|
||||
final rowNumber = (currentPage - 1) * AppConstants.vendorPageSize + index + 1;
|
||||
return [
|
||||
ShadTableCell(child: Text(rowNumber.toString(), style: const TextStyle(color: Colors.grey))),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: nameW,
|
||||
child: Text(vendor.name, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (vendor.id != null) ...[
|
||||
if (vendor.isActive) ...[
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onEdit(vendor.id!),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
vendor.createdAt != null ? vendor.createdAt!.toLocal().toString().split(' ')[0] : '-',
|
||||
maxLines: 1,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
child: ShadBadge(
|
||||
backgroundColor: vendor.isActive ? const Color(0xFF22C55E).withValues(alpha: 0.1) : Colors.grey.withValues(alpha: 0.1),
|
||||
foregroundColor: vendor.isActive ? const Color(0xFF16A34A) : Colors.grey.shade700,
|
||||
child: Text(vendor.isActive ? '활성' : '비활성'),
|
||||
),
|
||||
),
|
||||
),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (vendor.id != null) ...[
|
||||
if (vendor.isActive) ...[
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onEdit(vendor.id!),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onDelete(vendor.id!, vendor.name),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(Icons.delete, size: 16, color: theme.colorScheme.destructive),
|
||||
),
|
||||
] else
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onRestore(vendor.id!),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.restore, size: 16, color: Color(0xFF10B981)),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onDelete(vendor.id!, vendor.name),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
size: 16,
|
||||
color: theme.colorScheme.destructive,
|
||||
),
|
||||
),
|
||||
] else
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onRestore(vendor.id!),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(
|
||||
Icons.restore,
|
||||
size: 16,
|
||||
color: Color(0xFF10B981),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
}
|
||||
// 스크롤 필요한 경우만 수평 스크롤 허용
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableW,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(64);
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(nameBase);
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(120);
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(100);
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(actionsW);
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('No')),
|
||||
ShadTableCell.header(child: SizedBox(width: nameW, child: const Text('벤더명'))),
|
||||
ShadTableCell.header(child: SizedBox(width: 120, child: const Text('등록일'))),
|
||||
ShadTableCell.header(child: SizedBox(width: 100, child: const Text('상태'))),
|
||||
ShadTableCell.header(child: SizedBox(width: actionsW, child: const Text('작업'))),
|
||||
],
|
||||
children: vendors.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final vendor = entry.value;
|
||||
final rowNumber = (currentPage - 1) * AppConstants.vendorPageSize + index + 1;
|
||||
return [
|
||||
ShadTableCell(child: Text(rowNumber.toString(), style: const TextStyle(color: Colors.grey))),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: nameW,
|
||||
child: Text(vendor.name, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
),
|
||||
),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
vendor.createdAt != null ? vendor.createdAt!.toLocal().toString().split(' ')[0] : '-',
|
||||
maxLines: 1,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
),
|
||||
ShadTableCell(
|
||||
child: ShadBadge(
|
||||
backgroundColor: vendor.isActive ? const Color(0xFF22C55E).withValues(alpha: 0.1) : Colors.grey.withValues(alpha: 0.1),
|
||||
foregroundColor: vendor.isActive ? const Color(0xFF16A34A) : Colors.grey.shade700,
|
||||
child: Text(vendor.isActive ? '활성' : '비활성'),
|
||||
),
|
||||
),
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
spacing: 4,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
if (vendor.id != null) ...[
|
||||
if (vendor.isActive) ...[
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onEdit(vendor.id!),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onDelete(vendor.id!, vendor.name),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(Icons.delete, size: 16, color: theme.colorScheme.destructive),
|
||||
),
|
||||
] else
|
||||
ShadButton.ghost(
|
||||
onPressed: () => onRestore(vendor.id!),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.restore, size: 16, color: Color(0xFF10B981)),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -212,4 +319,4 @@ class VendorTable extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
438
lib/screens/vendor/vendor_list_screen.dart
vendored
438
lib/screens/vendor/vendor_list_screen.dart
vendored
@@ -32,17 +32,18 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
void _showCreateDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => VendorFormDialog(
|
||||
onSave: (vendor) async {
|
||||
final success = await _controller.createVendor(vendor);
|
||||
if (success) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
_showSuccessToast('벤더가 성공적으로 등록되었습니다.');
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
builder:
|
||||
(context) => VendorFormDialog(
|
||||
onSave: (vendor) async {
|
||||
final success = await _controller.createVendor(vendor);
|
||||
if (success) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
_showSuccessToast('벤더가 성공적으로 등록되었습니다.');
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,18 +52,19 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
if (_controller.selectedVendor != null && mounted) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => VendorFormDialog(
|
||||
vendor: _controller.selectedVendor,
|
||||
onSave: (vendor) async {
|
||||
final success = await _controller.updateVendor(id, vendor);
|
||||
if (success) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
_showSuccessToast('벤더가 성공적으로 수정되었습니다.');
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
builder:
|
||||
(context) => VendorFormDialog(
|
||||
vendor: _controller.selectedVendor,
|
||||
onSave: (vendor) async {
|
||||
final success = await _controller.updateVendor(id, vendor);
|
||||
if (success) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
_showSuccessToast('벤더가 성공적으로 수정되었습니다.');
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -70,42 +72,42 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
void _showDeleteConfirmDialog(int id, String name) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog(
|
||||
title: const Text('벤더 삭제'),
|
||||
description: Text('$name 벤더를 삭제하시겠습니까?\n삭제된 벤더는 복원할 수 있습니다.'),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('취소'),
|
||||
builder:
|
||||
(context) => ShadDialog(
|
||||
title: const Text('벤더 삭제'),
|
||||
description: Text('$name 벤더를 삭제하시겠습니까?\n삭제된 벤더는 복원할 수 있습니다.'),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final success = await _controller.deleteVendor(id);
|
||||
if (success) {
|
||||
_showSuccessToast('벤더가 삭제되었습니다.');
|
||||
} else {
|
||||
_showErrorToast(
|
||||
_controller.errorMessage ?? '삭제에 실패했습니다.',
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final success = await _controller.deleteVendor(id);
|
||||
if (success) {
|
||||
_showSuccessToast('벤더가 삭제되었습니다.');
|
||||
} else {
|
||||
_showErrorToast(_controller.errorMessage ?? '삭제에 실패했습니다.');
|
||||
}
|
||||
},
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showSuccessToast(String message) {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast(
|
||||
title: const Text('성공'),
|
||||
description: Text(message),
|
||||
),
|
||||
);
|
||||
ShadToaster.of(
|
||||
context,
|
||||
).show(ShadToast(title: const Text('성공'), description: Text(message)));
|
||||
}
|
||||
|
||||
void _showErrorToast(String message) {
|
||||
@@ -125,14 +127,8 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'벤더 관리',
|
||||
style: ShadcnTheme.headingH4,
|
||||
),
|
||||
Text(
|
||||
'장비 제조사 및 공급업체를 관리합니다',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
Text('벤더 관리', style: ShadcnTheme.headingH4),
|
||||
Text('장비 제조사 및 공급업체를 관리합니다', style: ShadcnTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
backgroundColor: ShadcnTheme.background,
|
||||
@@ -149,6 +145,8 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
isLoading: controller.isLoading,
|
||||
error: controller.errorMessage,
|
||||
onRefresh: () => controller.initialize(),
|
||||
// 데이터 테이블이 카드 좌우 아웃라인까지 꽉 차도록 내부 패딩 제거
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -157,7 +155,7 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
|
||||
Widget _buildStatisticsCards(VendorController controller) {
|
||||
if (controller.isLoading) return const SizedBox();
|
||||
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
_buildStatCard(
|
||||
@@ -204,7 +202,10 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
return StandardActionBar(
|
||||
totalCount: _controller.totalCount,
|
||||
leftActions: const [
|
||||
Text('벤더 목록', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
'벤더 목록',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
rightActions: [
|
||||
ShadButton(
|
||||
@@ -222,10 +223,9 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildDataTable(VendorController controller) {
|
||||
final vendors = controller.vendors;
|
||||
|
||||
|
||||
if (vendors.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
@@ -254,59 +254,259 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('번호')),
|
||||
ShadTableCell.header(child: Text('벤더명')),
|
||||
ShadTableCell.header(child: Text('등록일')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < vendors.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(child: Text(((_controller.currentPage - 1) * _controller.pageSize + index + 1).toString(), style: ShadcnTheme.bodySmall)),
|
||||
// 벤더명
|
||||
ShadTableCell(child: Text(vendors[index].name, overflow: TextOverflow.ellipsis)),
|
||||
// 등록일
|
||||
ShadTableCell(child: Text(
|
||||
vendors[index].createdAt != null
|
||||
? DateFormat('yyyy-MM-dd').format(vendors[index].createdAt!)
|
||||
: '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
)),
|
||||
// 상태
|
||||
ShadTableCell(child: _buildStatusChip(vendors[index].isDeleted)),
|
||||
// 작업
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showEditDialog(vendors[index].id!),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
// 수평 패딩을 제거해 테이블이 카드 내부 전체 폭을 사용하도록 함
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 12.0),
|
||||
// 가용 너비를 최대로 활용하고, 필요 시 수평 스크롤 허용
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 컬럼 대략 폭 합: 번호(64) + 벤더명(320) + 등록일(120) + 상태(100) + 작업(256) + 여백
|
||||
const double actionsW = 256.0; // 아이콘 2개 + 내부 패딩 여유(단일 행 유지)
|
||||
const double minTableWidth = 64 + 320 + 120 + 100 + actionsW + 24;
|
||||
final double tableWidth =
|
||||
constraints.maxWidth > 0
|
||||
? (constraints.maxWidth >= minTableWidth
|
||||
? constraints.maxWidth
|
||||
: minTableWidth)
|
||||
: minTableWidth;
|
||||
|
||||
const double nameBaseWidth = 320.0;
|
||||
final double nameColumnWidth = nameBaseWidth; // 벤더명 고정 폭
|
||||
|
||||
// 스크롤이 필요 없는 경우: 수평 스크롤 제거, 전체 폭 사용
|
||||
if (constraints.maxWidth >= minTableWidth) {
|
||||
return SizedBox(
|
||||
width: constraints.maxWidth,
|
||||
child: ShadTable.list(
|
||||
// 0: 번호, 1: 벤더명(고정), 2: 등록일, 3: 상태, 4: 작업, 5: 여백(남는 폭 흡수)
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(64);
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(nameBaseWidth);
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(120);
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(100);
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(actionsW);
|
||||
case 5:
|
||||
return const RemainingTableSpanExtent();
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('번호')),
|
||||
ShadTableCell.header(
|
||||
child: SizedBox(
|
||||
width: nameColumnWidth,
|
||||
child: const Text('벤더명'),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showDeleteConfirmDialog(vendors[index].id!, vendors[index].name),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ShadTableCell.header(child: SizedBox(width: 120, child: const Text('등록일'))),
|
||||
ShadTableCell.header(child: SizedBox(width: 100, child: const Text('상태'))),
|
||||
ShadTableCell.header(
|
||||
child: SizedBox(width: actionsW, child: const Text('작업')),
|
||||
),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < vendors.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
(((_controller.currentPage - 1) *
|
||||
_controller.pageSize) +
|
||||
index +
|
||||
1)
|
||||
.toString(),
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
// 벤더명 (가변 폭, 말줄임)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: nameColumnWidth,
|
||||
child: Text(
|
||||
vendors[index].name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 등록일
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
vendors[index].createdAt != null
|
||||
? DateFormat('yyyy-MM-dd').format(vendors[index].createdAt!)
|
||||
: '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
maxLines: 1,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 상태
|
||||
ShadTableCell(
|
||||
child: SizedBox(width: 100, child: _buildStatusChip(vendors[index].isDeleted)),
|
||||
),
|
||||
// 작업 (아이콘 그룹 - 단일 행 유지)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEditDialog(vendors[index].id!),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showDeleteConfirmDialog(vendors[index].id!, vendors[index].name),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 남는 폭 흡수용 빈 컬럼(전폭 사용)
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 스크롤이 필요한 경우만 수평 스크롤 사용
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: ShadTable.list(
|
||||
// 작은 화면에서도 최소 폭을 지키도록 고정 폭 지정
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(64);
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(nameBaseWidth);
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(120);
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(100);
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(actionsW);
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('번호')),
|
||||
ShadTableCell.header(
|
||||
child: SizedBox(
|
||||
width: nameColumnWidth,
|
||||
child: const Text('벤더명'),
|
||||
),
|
||||
),
|
||||
ShadTableCell.header(child: SizedBox(width: 120, child: const Text('등록일'))),
|
||||
ShadTableCell.header(child: SizedBox(width: 100, child: const Text('상태'))),
|
||||
ShadTableCell.header(
|
||||
child: SizedBox(width: actionsW, child: const Text('작업')),
|
||||
),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < vendors.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(
|
||||
child: Text(
|
||||
(((_controller.currentPage - 1) *
|
||||
_controller.pageSize) +
|
||||
index +
|
||||
1)
|
||||
.toString(),
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
// 벤더명 (가변 폭, 말줄임)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: nameColumnWidth,
|
||||
child: Text(
|
||||
vendors[index].name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 등록일
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
vendors[index].createdAt != null
|
||||
? DateFormat('yyyy-MM-dd').format(vendors[index].createdAt!)
|
||||
: '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
maxLines: 1,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 상태
|
||||
ShadTableCell(
|
||||
child: SizedBox(width: 100, child: _buildStatusChip(vendors[index].isDeleted)),
|
||||
),
|
||||
// 작업 (아이콘 그룹 - 단일 행 유지)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: actionsW,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showEditDialog(vendors[index].id!),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _showDeleteConfirmDialog(vendors[index].id!, vendors[index].name),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 별도 필러 컬럼 없이 벤더명 컬럼으로 남는 공간을 흡수
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildPagination(VendorController controller) {
|
||||
if (controller.totalPages <= 1) return const SizedBox();
|
||||
|
||||
return Pagination(
|
||||
currentPage: controller.currentPage,
|
||||
totalCount: controller.totalCount,
|
||||
@@ -333,26 +533,17 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
color: color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusLg),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 20,
|
||||
),
|
||||
child: Icon(icon, color: color, size: 20),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing3),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
Text(title, style: ShadcnTheme.bodySmall),
|
||||
Text(
|
||||
value,
|
||||
style: ShadcnTheme.headingH6.copyWith(
|
||||
color: color,
|
||||
),
|
||||
style: ShadcnTheme.headingH6.copyWith(color: color),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -379,5 +570,4 @@ class _VendorListScreenState extends State<VendorListScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ class _WarehouseLocationListState
|
||||
text: '창고 추가',
|
||||
onPressed: _navigateToAdd,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
textColor: Colors.white,
|
||||
textColor: ShadcnTheme.primaryForeground,
|
||||
icon: Icon(Icons.add),
|
||||
),
|
||||
],
|
||||
@@ -262,15 +262,16 @@ class _WarehouseLocationListState
|
||||
// 데이터 테이블
|
||||
dataTable: _buildDataTable(pagedLocations),
|
||||
|
||||
// 페이지네이션
|
||||
pagination: controller.totalPages > 1 ? Pagination(
|
||||
// 페이지네이션 (항상 표시)
|
||||
pagination: Pagination(
|
||||
totalCount: controller.total,
|
||||
currentPage: controller.currentPage,
|
||||
pageSize: controller.pageSize,
|
||||
onPageChanged: (page) {
|
||||
controller.goToPage(page);
|
||||
},
|
||||
) : null,
|
||||
),
|
||||
dataAreaPadding: EdgeInsets.zero,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -341,8 +342,8 @@ class _WarehouseLocationListState
|
||||
color: index.isEven
|
||||
? ShadcnTheme.muted.withValues(alpha: 0.1)
|
||||
: null,
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Colors.black),
|
||||
border: Border(
|
||||
bottom: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -438,7 +439,7 @@ class _WarehouseLocationListState
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
@@ -448,7 +449,7 @@ class _WarehouseLocationListState
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: Colors.black)),
|
||||
border: Border(bottom: BorderSide(color: ShadcnTheme.border)),
|
||||
),
|
||||
child: Row(children: _buildHeaderCells()),
|
||||
),
|
||||
@@ -485,4 +486,4 @@ class _WarehouseLocationListState
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,173 +39,134 @@ class ZipcodeTable extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShadCard(
|
||||
child: SingleChildScrollView(
|
||||
child: DataTable(
|
||||
horizontalMargin: 16,
|
||||
columnSpacing: 24,
|
||||
columns: const [
|
||||
DataColumn(
|
||||
label: Text(
|
||||
'우편번호',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
'시도',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
'구/군',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
'상세주소',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
'작업',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: zipcodes.map((zipcode) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
// 우편번호
|
||||
DataCell(
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
zipcode.zipcode.toString().padLeft(5, '0'),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.primary,
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _copyToClipboard(
|
||||
context,
|
||||
zipcode.zipcode.toString().padLeft(5, '0'),
|
||||
'우편번호'
|
||||
),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(
|
||||
Icons.copy,
|
||||
size: 14,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 고정폭 + 마지막 filler
|
||||
const double minW = 160 + 180 + 180 + 320 + 140 + 24;
|
||||
final double tableW = constraints.maxWidth >= minW ? constraints.maxWidth : minW;
|
||||
const double etcW = 320.0;
|
||||
|
||||
// 시도
|
||||
DataCell(
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.location_city,
|
||||
size: 16,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
zipcode.sido,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 구/군
|
||||
DataCell(
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.location_on,
|
||||
size: 16,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
zipcode.gu,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 상세주소
|
||||
DataCell(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 300),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
zipcode.etc,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.foreground,
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableW,
|
||||
child: ShadTable.list(
|
||||
columnSpanExtent: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FixedTableSpanExtent(160); // 우편번호
|
||||
case 1:
|
||||
return const FixedTableSpanExtent(180); // 시도
|
||||
case 2:
|
||||
return const FixedTableSpanExtent(180); // 구/군
|
||||
case 3:
|
||||
return const FixedTableSpanExtent(etcW); // 상세주소
|
||||
case 4:
|
||||
return const FixedTableSpanExtent(140); // 작업
|
||||
case 5:
|
||||
return const RemainingTableSpanExtent(); // filler
|
||||
default:
|
||||
return const FixedTableSpanExtent(100);
|
||||
}
|
||||
},
|
||||
header: [
|
||||
const ShadTableCell.header(child: Text('우편번호')),
|
||||
const ShadTableCell.header(child: Text('시도')),
|
||||
const ShadTableCell.header(child: Text('구/군')),
|
||||
ShadTableCell.header(child: SizedBox(width: etcW, child: const Text('상세주소'))),
|
||||
const ShadTableCell.header(child: Text('작업')),
|
||||
const ShadTableCell.header(child: SizedBox.shrink()),
|
||||
],
|
||||
children: zipcodes.map((zipcode) {
|
||||
return [
|
||||
// 우편번호 (오버플로우 방지)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: 160,
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
zipcode.zipcode.toString().padLeft(5, '0'),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.primary,
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _copyToClipboard(
|
||||
context,
|
||||
zipcode.fullAddress,
|
||||
'전체주소'
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _copyToClipboard(context, zipcode.zipcode.toString().padLeft(5, '0'), '우편번호'),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(Icons.copy, size: 14, color: theme.colorScheme.mutedForeground),
|
||||
),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(
|
||||
Icons.copy,
|
||||
size: 14,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 작업
|
||||
DataCell(
|
||||
ShadButton(
|
||||
onPressed: () => onSelect(zipcode),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Text('선택', style: TextStyle(fontSize: 11)),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
// 시도
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.location_city, size: 16, color: theme.colorScheme.mutedForeground),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(child: Text(zipcode.sido, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.w500))),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 구/군
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.location_on, size: 16, color: theme.colorScheme.mutedForeground),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(child: Text(zipcode.gu, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.w500))),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 상세주소 (가변 폭)
|
||||
ShadTableCell(
|
||||
child: SizedBox(
|
||||
width: etcW,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(zipcode.etc, overflow: TextOverflow.ellipsis, style: TextStyle(color: theme.colorScheme.foreground))),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _copyToClipboard(context, zipcode.fullAddress, '전체주소'),
|
||||
size: ShadButtonSize.sm,
|
||||
child: Icon(Icons.copy, size: 14, color: theme.colorScheme.mutedForeground),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// 작업
|
||||
ShadTableCell(
|
||||
child: ShadButton(
|
||||
onPressed: () => onSelect(zipcode),
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Text('선택', style: TextStyle(fontSize: 11)),
|
||||
),
|
||||
),
|
||||
const ShadTableCell(child: SizedBox.shrink()),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user