사용하지 않는 파일 정리 전 백업 (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,
),
],
),
),
],
);
}
}