사용하지 않는 파일 정리 전 백업 (Phase 10 완료 후 상태)

This commit is contained in:
JiWoong Sul
2025-08-29 15:11:59 +09:00
parent a740ff10c8
commit d916b281a7
333 changed files with 53617 additions and 22574 deletions

View File

@@ -0,0 +1,179 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
class VendorSearchFilter extends StatefulWidget {
final Function(String) onSearch;
final Function(bool?) onFilterChanged;
final VoidCallback onClearFilters;
const VendorSearchFilter({
super.key,
required this.onSearch,
required this.onFilterChanged,
required this.onClearFilters,
});
@override
State<VendorSearchFilter> createState() => _VendorSearchFilterState();
}
class _VendorSearchFilterState extends State<VendorSearchFilter> {
final TextEditingController _searchController = TextEditingController();
Timer? _debounceTimer;
bool? _selectedStatus;
bool _hasFilters = false;
@override
void dispose() {
_searchController.dispose();
_debounceTimer?.cancel();
super.dispose();
}
void _onSearchChanged(String value) {
// 디바운스 처리 (500ms)
_debounceTimer?.cancel();
_debounceTimer = Timer(const Duration(milliseconds: 500), () {
widget.onSearch(value);
});
_updateHasFilters();
}
void _onStatusChanged(bool? value) {
setState(() {
_selectedStatus = value;
});
widget.onFilterChanged(value);
_updateHasFilters();
}
void _clearFilters() {
setState(() {
_searchController.clear();
_selectedStatus = null;
_hasFilters = false;
});
_debounceTimer?.cancel();
widget.onClearFilters();
}
void _updateHasFilters() {
setState(() {
_hasFilters =
_searchController.text.isNotEmpty || _selectedStatus != null;
});
}
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
return Row(
children: [
// 검색 입력
Expanded(
flex: 2,
child: Row(
children: [
Icon(
Icons.search,
size: 16,
color: theme.colorScheme.mutedForeground,
),
const SizedBox(width: 8),
Expanded(
child: ShadInputFormField(
controller: _searchController,
placeholder: const Text('벤더명으로 검색'),
onChanged: _onSearchChanged,
),
),
if (_searchController.text.isNotEmpty) ...[
const SizedBox(width: 8),
ShadButton.ghost(
onPressed: () {
_searchController.clear();
_onSearchChanged('');
},
size: ShadButtonSize.sm,
child: Icon(
Icons.clear,
size: 14,
color: theme.colorScheme.mutedForeground,
),
),
],
],
),
),
const SizedBox(width: 16),
// 상태 필터
SizedBox(
width: 180,
child: ShadSelect<bool?>(
placeholder: const Text('상태 선택'),
onChanged: _onStatusChanged,
options: [
ShadOption(value: null, child: const Text('전체')),
ShadOption(value: true, child: const Text('활성')),
ShadOption(value: false, child: const Text('비활성')),
],
selectedOptionBuilder: (context, value) {
String label = '';
if (value == null) {
label = '전체';
} else if (value == true) {
label = '활성';
} else if (value == false) {
label = '비활성';
}
return Row(
children: [
if (value == true)
const Icon(
Icons.check_circle,
size: 14,
color: Color(0xFF10B981),
)
else if (value == false)
Icon(
Icons.cancel,
size: 14,
color: theme.colorScheme.mutedForeground,
)
else
Icon(
Icons.all_inclusive,
size: 14,
color: theme.colorScheme.foreground,
),
const SizedBox(width: 8),
Text(label),
],
);
},
),
),
const SizedBox(width: 16),
// 필터 초기화 버튼
if (_hasFilters)
ShadButton.outline(
onPressed: _clearFilters,
size: ShadButtonSize.sm,
child: Row(
children: [
Icon(Icons.filter_alt_off, size: 14),
SizedBox(width: 4),
Text('필터 초기화'),
],
),
),
],
);
}
}

View File

@@ -0,0 +1,215 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:superport/data/models/vendor_dto.dart';
import 'package:superport/utils/constants.dart';
class VendorTable extends StatelessWidget {
final List<VendorDto> vendors;
final int currentPage;
final int totalPages;
final Function(int) onPageChanged;
final Function(int) onEdit;
final Function(int, String) onDelete;
final Function(int) onRestore;
const VendorTable({
super.key,
required this.vendors,
required this.currentPage,
required this.totalPages,
required this.onPageChanged,
required this.onEdit,
required this.onDelete,
required this.onRestore,
});
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
return Column(
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) * PaginationConstants.defaultPageSize + 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,
),
),
),
),
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),
),
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),
),
),
],
],
),
),
],
);
}).toList(),
),
),
),
),
// 페이지네이션
if (totalPages > 1)
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: theme.colorScheme.border,
width: 1,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ShadButton.ghost(
onPressed: currentPage > 1
? () => onPageChanged(currentPage - 1)
: null,
size: ShadButtonSize.sm,
child: const Icon(Icons.chevron_left, size: 16),
),
const SizedBox(width: 8),
...List.generate(
totalPages > 5 ? 5 : totalPages,
(index) {
int pageNumber;
if (totalPages <= 5) {
pageNumber = index + 1;
} else if (currentPage <= 3) {
pageNumber = index + 1;
} else if (currentPage >= totalPages - 2) {
pageNumber = totalPages - 4 + index;
} else {
pageNumber = currentPage - 2 + index;
}
if (pageNumber > totalPages) return const SizedBox.shrink();
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 2),
child: pageNumber == currentPage
? ShadButton(
onPressed: () => onPageChanged(pageNumber),
size: ShadButtonSize.sm,
child: Text(pageNumber.toString()),
)
: ShadButton.outline(
onPressed: () => onPageChanged(pageNumber),
size: ShadButtonSize.sm,
child: Text(pageNumber.toString()),
),
);
},
),
const SizedBox(width: 8),
ShadButton.ghost(
onPressed: currentPage < totalPages
? () => onPageChanged(currentPage + 1)
: null,
size: ShadButtonSize.sm,
child: const Icon(Icons.chevron_right, size: 16),
),
const SizedBox(width: 24),
Text(
'페이지 $currentPage / $totalPages',
style: theme.textTheme.muted,
),
],
),
),
],
);
}
}

View File

@@ -0,0 +1,317 @@
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import 'package:superport/data/models/vendor_dto.dart';
import 'package:superport/data/models/vendor_stats_dto.dart';
import 'package:superport/domain/usecases/vendor_usecase.dart';
import 'package:superport/utils/constants.dart';
@injectable
class VendorController extends ChangeNotifier {
final VendorUseCase _vendorUseCase;
VendorController(this._vendorUseCase);
// 상태 변수들
List<VendorDto> _vendors = [];
VendorDto? _selectedVendor;
VendorStatsDto? _vendorStats;
bool _isLoading = false;
bool _isStatsLoading = false;
String? _errorMessage;
// 페이지네이션
int _currentPage = 1;
int _totalPages = 1;
int _totalCount = 0;
final int _pageSize = PaginationConstants.defaultPageSize;
// 필터 및 검색
String _searchQuery = '';
bool? _filterIsActive;
// Getters
List<VendorDto> get vendors => _vendors;
VendorDto? get selectedVendor => _selectedVendor;
VendorStatsDto? get vendorStats => _vendorStats;
bool get isLoading => _isLoading;
bool get isStatsLoading => _isStatsLoading;
String? get errorMessage => _errorMessage;
int get currentPage => _currentPage;
int get totalPages => _totalPages;
int get totalCount => _totalCount;
String get searchQuery => _searchQuery;
bool? get filterIsActive => _filterIsActive;
bool get hasNextPage => _currentPage < _totalPages;
bool get hasPreviousPage => _currentPage > 1;
// 초기 데이터 로드
Future<void> initialize() async {
// 초기 로딩 상태만 설정하고, 실제 데이터 로딩은 다음 프레임에서 실행
_isLoading = true;
notifyListeners();
await Future.wait([
loadVendors(),
loadVendorStats(),
]);
}
// 벤더 목록 로드
Future<void> loadVendors({bool refresh = false}) async {
if (refresh) {
_currentPage = 1;
}
_setLoading(true);
_clearError();
try {
final response = await _vendorUseCase.getVendors(
page: _currentPage,
limit: _pageSize,
search: _searchQuery.isNotEmpty ? _searchQuery : null,
isActive: _filterIsActive,
);
_vendors = List.from(response.items);
_totalCount = response.totalCount;
_totalPages = response.totalPages;
_currentPage = response.currentPage;
notifyListeners();
} catch (e) {
_setError('벤더 목록을 불러오는데 실패했습니다: ${e.toString()}');
} finally {
_setLoading(false);
}
}
// 벤더 상세 조회
Future<void> selectVendor(int id) async {
_setLoading(true);
_clearError();
try {
_selectedVendor = await _vendorUseCase.getVendorById(id);
notifyListeners();
} catch (e) {
_setError('벤더 정보를 불러오는데 실패했습니다: ${e.toString()}');
} finally {
_setLoading(false);
}
}
// 벤더 생성
Future<bool> createVendor(VendorDto vendor) async {
_setLoading(true);
_clearError();
try {
final newVendor = await _vendorUseCase.createVendor(vendor);
// 목록 새로고침
await loadVendors(refresh: true);
return true;
} catch (e) {
_setError('벤더 생성에 실패했습니다: ${e.toString()}');
return false;
} finally {
_setLoading(false);
}
}
// 벤더 수정
Future<bool> updateVendor(int id, VendorDto vendor) async {
_setLoading(true);
_clearError();
try {
final updatedVendor = await _vendorUseCase.updateVendor(id, vendor);
// 목록에서 해당 벤더 업데이트
final index = _vendors.indexWhere((v) => v.id == id);
if (index != -1) {
_vendors = _vendors.map((vendor) =>
vendor.id == id ? updatedVendor : vendor
).toList();
notifyListeners();
}
// 선택된 벤더도 업데이트
if (_selectedVendor?.id == id) {
_selectedVendor = updatedVendor;
}
return true;
} catch (e) {
_setError('벤더 수정에 실패했습니다: ${e.toString()}');
return false;
} finally {
_setLoading(false);
}
}
// 벤더 삭제
Future<bool> deleteVendor(int id) async {
_setLoading(true);
_clearError();
try {
await _vendorUseCase.deleteVendor(id);
// 목록에서 제거
_vendors = _vendors.where((v) => v.id != id).toList();
// 선택된 벤더가 삭제된 경우 초기화
if (_selectedVendor?.id == id) {
_selectedVendor = null;
}
notifyListeners();
return true;
} catch (e) {
_setError('벤더 삭제에 실패했습니다: ${e.toString()}');
return false;
} finally {
_setLoading(false);
}
}
// 벤더 복원
Future<bool> restoreVendor(int id) async {
_setLoading(true);
_clearError();
try {
await _vendorUseCase.restoreVendor(id);
// 목록 새로고침
await loadVendors();
return true;
} catch (e) {
_setError('벤더 복원에 실패했습니다: ${e.toString()}');
return false;
} finally {
_setLoading(false);
}
}
// 검색 쿼리 설정
void setSearchQuery(String query) {
_searchQuery = query;
notifyListeners();
}
// 검색 실행 (디바운스 적용 필요)
Future<void> search() async {
_currentPage = 1;
await loadVendors();
}
// 활성 상태 필터 설정
void setFilterIsActive(bool? isActive) {
_filterIsActive = isActive;
notifyListeners();
}
// 필터 적용
Future<void> applyFilters() async {
_currentPage = 1;
await loadVendors();
}
// 필터 초기화
Future<void> clearFilters() async {
_searchQuery = '';
_filterIsActive = null;
_currentPage = 1;
await loadVendors();
}
// 페이지 이동
Future<void> goToPage(int page) async {
if (page < 1 || page > _totalPages) return;
_currentPage = page;
await loadVendors();
}
// 다음 페이지
Future<void> nextPage() async {
if (hasNextPage) {
await goToPage(_currentPage + 1);
}
}
// 이전 페이지
Future<void> previousPage() async {
if (hasPreviousPage) {
await goToPage(_currentPage - 1);
}
}
// 벤더명 중복 체크
Future<bool> checkDuplicateName(String name, {int? excludeId}) async {
try {
return await _vendorUseCase.checkDuplicateName(name, excludeId: excludeId);
} catch (e) {
return false;
}
}
// 벤더 데이터 검증
Future<bool> validateVendor(VendorDto vendor) async {
try {
return await _vendorUseCase.validateVendor(vendor);
} catch (e) {
_setError('검증 실패: ${e.toString()}');
return false;
}
}
// 선택 초기화
void clearSelection() {
_selectedVendor = null;
notifyListeners();
}
// 내부 헬퍼 메서드
void _setLoading(bool loading) {
_isLoading = loading;
notifyListeners();
}
void _setError(String message) {
_errorMessage = message;
notifyListeners();
}
void _clearError() {
_errorMessage = null;
}
// 벤더 통계 로드
Future<void> loadVendorStats() async {
_isStatsLoading = true;
notifyListeners();
try {
_vendorStats = await _vendorUseCase.getVendorStats();
} catch (e) {
_setError('벤더 통계를 불러오는데 실패했습니다: ${e.toString()}');
} finally {
_isStatsLoading = false;
notifyListeners();
}
}
@override
void dispose() {
_vendors = []; // clear() 대신 새로운 빈 리스트 할당
_selectedVendor = null;
_vendorStats = null;
super.dispose();
}
}

View File

@@ -0,0 +1,140 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:superport/data/models/vendor_dto.dart';
class VendorFormDialog extends StatefulWidget {
final VendorDto? vendor;
final Function(VendorDto) onSave;
const VendorFormDialog({
super.key,
this.vendor,
required this.onSave,
});
@override
State<VendorFormDialog> createState() => _VendorFormDialogState();
}
class _VendorFormDialogState extends State<VendorFormDialog> {
final _formKey = GlobalKey<FormState>();
late final TextEditingController _nameController;
late bool _isActive;
bool _isLoading = false;
@override
void initState() {
super.initState();
final vendor = widget.vendor;
_nameController = TextEditingController(text: vendor?.name ?? '');
_isActive = vendor?.isActive ?? true;
}
@override
void dispose() {
_nameController.dispose();
super.dispose();
}
void _handleSave() async {
if (!_formKey.currentState!.validate()) return;
setState(() => _isLoading = true);
final vendor = VendorDto(
id: widget.vendor?.id,
name: _nameController.text.trim(),
isDeleted: !_isActive,
createdAt: widget.vendor?.createdAt,
updatedAt: DateTime.now(),
);
await widget.onSave(vendor);
setState(() => _isLoading = false);
}
String? _validateRequired(String? value, String fieldName) {
if (value == null || value.trim().isEmpty) {
return '$fieldName은(는) 필수 입력 항목입니다.';
}
return null;
}
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final isEdit = widget.vendor != null;
return ShadDialog(
title: Text(isEdit ? '벤더 수정' : '벤더 등록'),
description: const Text('벤더 정보를 입력하세요'),
child: SizedBox(
width: 500,
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// 벤더명 (필수)
ShadInputFormField(
controller: _nameController,
label: const Text('벤더명 *'),
placeholder: const Text('예: 삼성전자, LG전자, 애플'),
validator: (value) => _validateRequired(value, '벤더명'),
),
const SizedBox(height: 24),
// 활성 상태
Row(
children: [
ShadCheckbox(
value: _isActive,
onChanged: (value) {
setState(() => _isActive = value ?? true);
},
),
const SizedBox(width: 8),
Text(
'활성 벤더',
style: theme.textTheme.p,
),
const SizedBox(width: 8),
Text(
'(비활성 시 선택 목록에서 제외됩니다)',
style: theme.textTheme.muted,
),
],
),
// Actions
const SizedBox(height: 24),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ShadButton.outline(
onPressed: _isLoading ? null : () => Navigator.of(context).pop(),
child: const Text('취소'),
),
const SizedBox(width: 8),
ShadButton(
onPressed: _isLoading ? null : _handleSave,
child: _isLoading
? const SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text(isEdit ? '수정' : '등록'),
),
],
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,383 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:superport/screens/vendor/controllers/vendor_controller.dart';
import 'package:superport/screens/vendor/vendor_form_dialog.dart';
import 'package:superport/screens/vendor/components/vendor_table.dart';
import 'package:superport/screens/vendor/components/vendor_search_filter.dart';
class VendorListScreen extends StatefulWidget {
const VendorListScreen({super.key});
@override
State<VendorListScreen> createState() => _VendorListScreenState();
}
class _VendorListScreenState extends State<VendorListScreen> {
late VendorController _controller;
@override
void initState() {
super.initState();
_controller = context.read<VendorController>();
// 위젯이 완전히 빌드된 후에 초기화 실행
WidgetsBinding.instance.addPostFrameCallback((_) {
_controller.initialize();
});
}
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('벤더가 성공적으로 등록되었습니다.');
}
}
},
),
);
}
void _showEditDialog(int id) async {
await _controller.selectVendor(id);
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('벤더가 성공적으로 수정되었습니다.');
}
}
},
),
);
}
}
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('취소'),
),
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),
),
);
}
void _showErrorToast(String message) {
ShadToaster.of(context).show(
ShadToast.destructive(
title: const Text('오류'),
description: Text(message),
),
);
}
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
return Scaffold(
backgroundColor: theme.colorScheme.background,
body: Consumer<VendorController>(
builder: (context, controller, child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 헤더
Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: theme.colorScheme.card,
border: Border(
bottom: BorderSide(
color: theme.colorScheme.border,
width: 1,
),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'벤더 관리',
style: theme.textTheme.h2,
),
const SizedBox(height: 4),
Text(
'장비 제조사 및 공급업체를 관리합니다',
style: theme.textTheme.muted,
),
],
),
ShadButton(
onPressed: _showCreateDialog,
child: Row(
children: [
Icon(Icons.add, size: 16),
SizedBox(width: 4),
Text('벤더 등록'),
],
),
),
],
),
const SizedBox(height: 16),
// 검색 및 필터
VendorSearchFilter(
onSearch: (query) {
controller.setSearchQuery(query);
controller.search();
},
onFilterChanged: (isActive) {
controller.setFilterIsActive(isActive);
controller.applyFilters();
},
onClearFilters: () {
controller.clearFilters();
},
),
],
),
),
// 통계 카드
if (!controller.isLoading)
Container(
padding: const EdgeInsets.all(24),
child: Row(
children: [
_buildStatCard(
context,
'전체 벤더',
controller.totalCount.toString(),
Icons.business,
theme.colorScheme.primary,
),
const SizedBox(width: 16),
_buildStatCard(
context,
'활성 벤더',
(controller.vendorStats?.activeVendors ??
controller.vendors.where((v) => v.isActive).length)
.toString(),
Icons.check_circle,
const Color(0xFF10B981),
),
const SizedBox(width: 16),
_buildStatCard(
context,
'비활성 벤더',
(controller.vendorStats?.inactiveVendors ??
controller.vendors.where((v) => !v.isActive).length)
.toString(),
Icons.cancel,
theme.colorScheme.mutedForeground,
),
],
),
),
// 테이블
Expanded(
child: controller.isLoading
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 16),
Text(
'데이터를 불러오는 중...',
style: theme.textTheme.muted,
),
],
),
)
: controller.errorMessage != null
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.error_outline,
size: 48,
color: theme.colorScheme.destructive,
),
const SizedBox(height: 16),
Text(
'오류 발생',
style: theme.textTheme.h3,
),
const SizedBox(height: 8),
Text(
controller.errorMessage!,
style: theme.textTheme.muted,
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
ShadButton(
onPressed: () => controller.loadVendors(),
child: const Text('다시 시도'),
),
],
),
)
: controller.vendors.isEmpty
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.inbox,
size: 48,
color: theme.colorScheme.mutedForeground,
),
const SizedBox(height: 16),
Text(
'등록된 벤더가 없습니다',
style: theme.textTheme.h3,
),
const SizedBox(height: 8),
Text(
'새로운 벤더를 등록해주세요',
style: theme.textTheme.muted,
),
const SizedBox(height: 24),
ShadButton(
onPressed: _showCreateDialog,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.add, size: 16),
SizedBox(width: 4),
Text('첫 벤더 등록'),
],
),
),
],
),
)
: Padding(
padding: const EdgeInsets.all(24),
child: VendorTable(
vendors: controller.vendors,
currentPage: controller.currentPage,
totalPages: controller.totalPages,
onPageChanged: controller.goToPage,
onEdit: _showEditDialog,
onDelete: (id, name) =>
_showDeleteConfirmDialog(id, name),
onRestore: (id) async {
final success =
await controller.restoreVendor(id);
if (success) {
_showSuccessToast('벤더가 복원되었습니다.');
}
},
),
),
),
],
);
},
),
);
}
Widget _buildStatCard(
BuildContext context,
String title,
String value,
IconData icon,
Color color,
) {
final theme = ShadTheme.of(context);
return Expanded(
child: ShadCard(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: color.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
icon,
color: color,
size: 24,
),
),
const SizedBox(width: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: theme.textTheme.small.copyWith(
color: theme.colorScheme.mutedForeground,
),
),
const SizedBox(height: 4),
Text(
value,
style: theme.textTheme.h3,
),
],
),
],
),
),
);
}
}