refactor: 사용하지 않는 파일 9개 정리
- 코드베이스 분석을 통해 사용되지 않는 파일 식별 및 삭제 - migration, utils, models, screens 등 미사용 파일 제거 - flutter analyze 결과: 63개 → 48개 오류로 개선 - 전체 .dart 파일 수: 365개로 정리 완료 삭제된 파일: - lib/core/migrations/execute_migration.dart - lib/core/utils/login_diagnostics.dart - lib/utils/equipment_display_helper.dart - lib/utils/formatters/business_number_formatter.dart - lib/utils/user_utils.dart - lib/models/user_phone_field.dart - lib/screens/rent/rent_list_screen_simple.dart - lib/screens/common/widgets/category_autocomplete_field.dart - lib/screens/common/widgets/company_branch_dropdown.dart ✅ 빌드 검증 완료: flutter pub get, build_runner 성공 ✅ Phase 10 이후 추가 코드베이스 정리 완료
This commit is contained in:
@@ -1,193 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../injection_container.dart';
|
||||
import 'controllers/rent_controller.dart';
|
||||
import 'rent_form_dialog.dart';
|
||||
|
||||
class RentListScreen extends StatefulWidget {
|
||||
const RentListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<RentListScreen> createState() => _RentListScreenState();
|
||||
}
|
||||
|
||||
class _RentListScreenState extends State<RentListScreen> {
|
||||
late final RentController _controller;
|
||||
final _searchController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = getIt<RentController>();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _loadData() async {
|
||||
await _controller.loadRents();
|
||||
}
|
||||
|
||||
Future<void> _refresh() async {
|
||||
await _controller.loadRents(refresh: true);
|
||||
}
|
||||
|
||||
void _showCreateDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RentFormDialog(
|
||||
onSubmit: (request) async {
|
||||
final success = await _controller.createRent(
|
||||
equipmentHistoryId: request.equipmentHistoryId,
|
||||
startedAt: request.startedAt,
|
||||
endedAt: request.endedAt,
|
||||
);
|
||||
if (success && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('임대 계약이 생성되었습니다')),
|
||||
);
|
||||
}
|
||||
return success;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onSearch(String query) {
|
||||
_controller.loadRents(search: query.isEmpty ? null : query);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: ChangeNotifierProvider.value(
|
||||
value: _controller,
|
||||
child: Consumer<RentController>(
|
||||
builder: (context, controller, child) {
|
||||
return Column(
|
||||
children: [
|
||||
// 헤더
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'임대 관리',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
const Spacer(),
|
||||
// 검색 필드
|
||||
SizedBox(
|
||||
width: 300,
|
||||
child: TextFormField(
|
||||
controller: _searchController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: '검색...',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onFieldSubmitted: _onSearch,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 새로고침 버튼
|
||||
IconButton(
|
||||
onPressed: _refresh,
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: '새로고침',
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton.icon(
|
||||
onPressed: _showCreateDialog,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('새 임대'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 콘텐츠
|
||||
Expanded(
|
||||
child: controller.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: controller.hasError
|
||||
? Center(child: Text('오류: ${controller.error}'))
|
||||
: controller.rents.isEmpty
|
||||
? const Center(child: Text('임대 계약이 없습니다'))
|
||||
: ListView.builder(
|
||||
itemCount: controller.rents.length,
|
||||
itemBuilder: (context, index) {
|
||||
final rent = controller.rents[index];
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
child: Text(
|
||||
'${rent.id ?? 0}',
|
||||
),
|
||||
),
|
||||
title: Text('임대 #${rent.id ?? 0}'),
|
||||
subtitle: Text(
|
||||
'${_formatDate(rent.startedAt)} ~ ${_formatDate(rent.endedAt)}',
|
||||
),
|
||||
trailing: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'${_calculateDays(rent.startedAt, rent.endedAt)}일',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
controller.getRentStatusDisplayName(controller.getRentStatus(rent)),
|
||||
style: TextStyle(
|
||||
color: _getStatusColor(controller.getRentStatus(rent)),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _getStatusColor(String status) {
|
||||
switch (status) {
|
||||
case '진행중':
|
||||
return Colors.blue;
|
||||
case '종료':
|
||||
return Colors.green;
|
||||
case '예약':
|
||||
return Colors.orange;
|
||||
default:
|
||||
return Colors.grey;
|
||||
}
|
||||
}
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
return '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
int _calculateDays(DateTime startDate, DateTime endDate) {
|
||||
return endDate.difference(startDate).inDays;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user