backup: 사용하지 않는 파일 삭제 전 복구 지점
- 전체 371개 파일 중 82개 미사용 파일 식별 - Phase 1: 33개 파일 삭제 예정 (100% 안전) - Phase 2: 30개 파일 삭제 검토 예정 - Phase 3: 19개 파일 수동 검토 예정 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -29,81 +29,100 @@ class StandardActionBar extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// 왼쪽 액션 버튼들
|
||||
Row(
|
||||
children: [
|
||||
...leftActions.map((action) => Padding(
|
||||
padding: const EdgeInsets.only(right: ShadcnTheme.spacing2),
|
||||
child: action,
|
||||
)),
|
||||
],
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Wrap(
|
||||
spacing: ShadcnTheme.spacing2,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
...leftActions,
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 오른쪽 상태 표시 및 액션들
|
||||
Row(
|
||||
children: [
|
||||
// 추가 상태 메시지 (작은 글자 크기로 통일)
|
||||
if (statusMessage != null) ...[
|
||||
Text(statusMessage!, style: ShadcnTheme.bodySmall),
|
||||
const SizedBox(width: ShadcnTheme.spacing3),
|
||||
],
|
||||
|
||||
// 선택된 항목 수 표시
|
||||
if (selectedCount != null && selectedCount! > 0) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.primary.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusSm),
|
||||
border: Border.all(color: ShadcnTheme.primary.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Text(
|
||||
'$selectedCount개 선택됨',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ShadcnTheme.primary,
|
||||
// 오른쪽 상태 표시 및 액션들 - 오버플로우 방지
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 추가 상태 메시지 (작은 글자 크기로 통일) - 텍스트 오버플로우 방지
|
||||
if (statusMessage != null) ...[
|
||||
Flexible(
|
||||
child: Text(
|
||||
statusMessage!,
|
||||
style: ShadcnTheme.bodySmall,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing3),
|
||||
const SizedBox(width: ShadcnTheme.spacing2),
|
||||
],
|
||||
|
||||
// 선택된 항목 수 표시
|
||||
if (selectedCount != null && selectedCount! > 0) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6,
|
||||
horizontal: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.primary.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusSm),
|
||||
border: Border.all(color: ShadcnTheme.primary.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Text(
|
||||
'$selectedCount개',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ShadcnTheme.primary,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing2),
|
||||
],
|
||||
|
||||
// 전체 항목 수 표시 (statusMessage에 "총 X개"가 없을 때만 표시)
|
||||
if (statusMessage == null || !statusMessage!.contains('총'))
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4,
|
||||
horizontal: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusSm),
|
||||
),
|
||||
child: Text(
|
||||
'총 $totalCount개',
|
||||
style: ShadcnTheme.bodySmall.copyWith(fontSize: 11),
|
||||
),
|
||||
),
|
||||
|
||||
// 새로고침 버튼
|
||||
if (onRefresh != null) ...[
|
||||
const SizedBox(width: ShadcnTheme.spacing2),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: onRefresh,
|
||||
tooltip: '새로고침',
|
||||
iconSize: 18,
|
||||
padding: const EdgeInsets.all(4),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 32,
|
||||
minHeight: 32,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
// 오른쪽 액션 버튼들
|
||||
...rightActions.map((action) => Padding(
|
||||
padding: const EdgeInsets.only(left: ShadcnTheme.spacing1),
|
||||
child: action,
|
||||
)),
|
||||
],
|
||||
|
||||
// 전체 항목 수 표시 (statusMessage에 "총 X개"가 없을 때만 표시)
|
||||
if (statusMessage == null || !statusMessage!.contains('총'))
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6,
|
||||
horizontal: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusSm),
|
||||
),
|
||||
child: Text(
|
||||
'총 $totalCount개',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
|
||||
// 새로고침 버튼
|
||||
if (onRefresh != null) ...[
|
||||
const SizedBox(width: ShadcnTheme.spacing3),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: onRefresh,
|
||||
tooltip: '새로고침',
|
||||
iconSize: 20,
|
||||
),
|
||||
],
|
||||
|
||||
// 오른쪽 액션 버튼들
|
||||
...rightActions.map((action) => Padding(
|
||||
padding: const EdgeInsets.only(left: ShadcnTheme.spacing2),
|
||||
child: action,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
273
lib/screens/common/widgets/standard_dropdown.dart
Normal file
273
lib/screens/common/widgets/standard_dropdown.dart
Normal file
@@ -0,0 +1,273 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
/// 표준화된 드롭다운 위젯
|
||||
/// 3단계 상태 (로딩/오류/정상)를 자동으로 처리하며,
|
||||
/// 모든 Form에서 일관된 사용자 경험을 제공합니다.
|
||||
class StandardDropdown<T> extends StatelessWidget {
|
||||
/// 드롭다운 라벨
|
||||
final String label;
|
||||
|
||||
/// 필수 항목 여부 (라벨에 * 표시)
|
||||
final bool isRequired;
|
||||
|
||||
/// 드롭다운 옵션 데이터
|
||||
final List<T> items;
|
||||
|
||||
/// 로딩 상태
|
||||
final bool isLoading;
|
||||
|
||||
/// 오류 메시지 (null이면 오류 없음)
|
||||
final String? error;
|
||||
|
||||
/// 재시도 콜백 함수
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
/// 선택 변경 콜백
|
||||
final void Function(T?) onChanged;
|
||||
|
||||
/// 현재 선택된 값
|
||||
final T? selectedValue;
|
||||
|
||||
/// 각 항목을 위젯으로 변환하는 빌더
|
||||
final Widget Function(T item) itemBuilder;
|
||||
|
||||
/// 선택된 항목을 표시하는 빌더
|
||||
final Widget Function(T item) selectedItemBuilder;
|
||||
|
||||
/// 값에서 고유 ID를 추출하는 함수
|
||||
final dynamic Function(T item) valueExtractor;
|
||||
|
||||
/// 플레이스홀더 텍스트
|
||||
final String placeholder;
|
||||
|
||||
/// 폼 검증 함수
|
||||
final String? Function(T? value)? validator;
|
||||
|
||||
/// 비활성화 여부
|
||||
final bool enabled;
|
||||
|
||||
const StandardDropdown({
|
||||
super.key,
|
||||
required this.label,
|
||||
this.isRequired = false,
|
||||
required this.items,
|
||||
this.isLoading = false,
|
||||
this.error,
|
||||
this.onRetry,
|
||||
required this.onChanged,
|
||||
this.selectedValue,
|
||||
required this.itemBuilder,
|
||||
required this.selectedItemBuilder,
|
||||
required this.valueExtractor,
|
||||
this.placeholder = '선택하세요',
|
||||
this.validator,
|
||||
this.enabled = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 라벨
|
||||
Text(
|
||||
isRequired ? '$label *' : label,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 3단계 상태 처리
|
||||
_buildStateWidget(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 상태에 따른 위젯 빌드
|
||||
Widget _buildStateWidget() {
|
||||
// 1. 로딩 상태
|
||||
if (isLoading) {
|
||||
return _buildLoadingWidget();
|
||||
}
|
||||
|
||||
// 2. 오류 상태
|
||||
if (error != null) {
|
||||
return _buildErrorWidget();
|
||||
}
|
||||
|
||||
// 3. 정상 상태
|
||||
return _buildDropdownWidget();
|
||||
}
|
||||
|
||||
/// 로딩 위젯
|
||||
Widget _buildLoadingWidget() {
|
||||
return SizedBox(
|
||||
height: 56,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120, // 명시적 너비 지정으로 무한 너비 제약 해결
|
||||
child: const ShadProgress(),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('$label 목록을 불러오는 중...'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 오류 위젯
|
||||
Widget _buildErrorWidget() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.shade50,
|
||||
border: Border.all(color: Colors.red.shade200),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.error, color: Colors.red.shade600, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'$label 로딩 실패',
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
error!,
|
||||
style: TextStyle(color: Colors.red.shade700, fontSize: 14),
|
||||
),
|
||||
if (onRetry != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
ShadButton(
|
||||
onPressed: onRetry,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.refresh, size: 16),
|
||||
SizedBox(width: 4),
|
||||
Text('다시 시도'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 드롭다운 위젯 (정상 상태)
|
||||
Widget _buildDropdownWidget() {
|
||||
// 비어있는 경우 처리
|
||||
if (items.isEmpty) {
|
||||
return Container(
|
||||
height: 56,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade50,
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$label이(가) 없습니다',
|
||||
style: TextStyle(color: Colors.grey.shade600),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ShadSelect<dynamic>(
|
||||
placeholder: Text(placeholder),
|
||||
options: items.map((item) {
|
||||
return ShadOption(
|
||||
value: valueExtractor(item),
|
||||
child: itemBuilder(item),
|
||||
);
|
||||
}).toList(),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) return Text(placeholder);
|
||||
|
||||
// 선택된 값에 해당하는 항목 찾기
|
||||
try {
|
||||
final selectedItem = items.firstWhere(
|
||||
(item) => valueExtractor(item) == value,
|
||||
);
|
||||
return selectedItemBuilder(selectedItem);
|
||||
} catch (e) {
|
||||
return Text('알 수 없는 항목 (값: $value)');
|
||||
}
|
||||
},
|
||||
onChanged: enabled ? (value) {
|
||||
if (value == null) {
|
||||
onChanged(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// 값에 해당하는 실제 객체 찾기
|
||||
try {
|
||||
final selectedItem = items.firstWhere(
|
||||
(item) => valueExtractor(item) == value,
|
||||
);
|
||||
onChanged(selectedItem);
|
||||
} catch (e) {
|
||||
onChanged(null);
|
||||
}
|
||||
} : null,
|
||||
initialValue: selectedValue != null ? valueExtractor(selectedValue as T) : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Int ID 타입을 위한 편의 클래스
|
||||
class StandardIntDropdown<T> extends StandardDropdown<T> {
|
||||
StandardIntDropdown({
|
||||
super.key,
|
||||
required super.label,
|
||||
super.isRequired = false,
|
||||
required super.items,
|
||||
super.isLoading = false,
|
||||
super.error,
|
||||
super.onRetry,
|
||||
required super.onChanged,
|
||||
super.selectedValue,
|
||||
required super.itemBuilder,
|
||||
required super.selectedItemBuilder,
|
||||
required int Function(T item) idExtractor,
|
||||
super.placeholder = '선택하세요',
|
||||
super.validator,
|
||||
super.enabled = true,
|
||||
}) : super(
|
||||
valueExtractor: (item) => idExtractor(item),
|
||||
);
|
||||
}
|
||||
|
||||
/// String 값 타입을 위한 편의 클래스
|
||||
class StandardStringDropdown<T> extends StandardDropdown<T> {
|
||||
StandardStringDropdown({
|
||||
super.key,
|
||||
required super.label,
|
||||
super.isRequired = false,
|
||||
required super.items,
|
||||
super.isLoading = false,
|
||||
super.error,
|
||||
super.onRetry,
|
||||
required super.onChanged,
|
||||
super.selectedValue,
|
||||
required super.itemBuilder,
|
||||
required super.selectedItemBuilder,
|
||||
required super.valueExtractor,
|
||||
super.placeholder = '선택하세요',
|
||||
super.validator,
|
||||
super.enabled = true,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user