refactor: 코드베이스 정리 및 에러 처리 개선
- API 클라이언트 및 인증 인터셉터 에러 처리 강화 - 의존성 주입 실패 시에도 앱 실행 가능하도록 개선 - 사용하지 않는 레거시 UI 컴포넌트 및 화면 제거 - pubspec.yaml 의존성 업데이트 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/models/warehouse_location_model.dart';
|
||||
import 'package:superport/models/address_model.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
|
||||
/// 입고지 폼 상태 및 저장/수정 로직을 담당하는 컨트롤러
|
||||
class WarehouseLocationFormController {
|
||||
/// 폼 키
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
/// 입고지명 입력 컨트롤러
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
|
||||
/// 비고 입력 컨트롤러
|
||||
final TextEditingController remarkController = TextEditingController();
|
||||
|
||||
/// 주소 정보
|
||||
Address address = const Address();
|
||||
|
||||
/// 저장 중 여부
|
||||
bool isSaving = false;
|
||||
|
||||
/// 수정 모드 여부
|
||||
bool isEditMode = false;
|
||||
|
||||
/// 입고지 id (수정 모드)
|
||||
int? id;
|
||||
|
||||
/// 기존 데이터 세팅 (수정 모드)
|
||||
void initialize(int? locationId) {
|
||||
id = locationId;
|
||||
if (id != null) {
|
||||
final location = MockDataService().getWarehouseLocationById(id!);
|
||||
if (location != null) {
|
||||
isEditMode = true;
|
||||
nameController.text = location.name;
|
||||
address = location.address;
|
||||
remarkController.text = location.remark ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 주소 변경 처리
|
||||
void updateAddress(Address newAddress) {
|
||||
address = newAddress;
|
||||
}
|
||||
|
||||
/// 저장 처리 (추가/수정)
|
||||
Future<bool> save(BuildContext context) async {
|
||||
if (!formKey.currentState!.validate()) return false;
|
||||
isSaving = true;
|
||||
if (isEditMode) {
|
||||
// 수정
|
||||
MockDataService().updateWarehouseLocation(
|
||||
WarehouseLocation(
|
||||
id: id!,
|
||||
name: nameController.text.trim(),
|
||||
address: address,
|
||||
remark: remarkController.text.trim(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 추가
|
||||
MockDataService().addWarehouseLocation(
|
||||
WarehouseLocation(
|
||||
id: 0,
|
||||
name: nameController.text.trim(),
|
||||
address: address,
|
||||
remark: remarkController.text.trim(),
|
||||
),
|
||||
);
|
||||
}
|
||||
isSaving = false;
|
||||
Navigator.pop(context, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// 취소 처리
|
||||
void cancel(BuildContext context) {
|
||||
Navigator.pop(context, false);
|
||||
}
|
||||
|
||||
/// 컨트롤러 해제
|
||||
void dispose() {
|
||||
nameController.dispose();
|
||||
remarkController.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/models/warehouse_location_model.dart';
|
||||
import 'controllers/warehouse_location_list_controller.dart';
|
||||
import 'package:superport/screens/common/widgets/address_input.dart';
|
||||
import 'package:superport/utils/constants.dart';
|
||||
import 'package:superport/screens/common/main_layout.dart';
|
||||
import 'package:superport/screens/common/widgets/pagination.dart';
|
||||
import 'package:superport/screens/common/custom_widgets.dart';
|
||||
import 'package:superport/screens/common/theme_tailwind.dart';
|
||||
|
||||
/// 입고지 관리 리스트 화면 (SRP 적용, UI만 담당)
|
||||
class WarehouseLocationListScreen extends StatefulWidget {
|
||||
const WarehouseLocationListScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<WarehouseLocationListScreen> createState() =>
|
||||
_WarehouseLocationListScreenState();
|
||||
}
|
||||
|
||||
class _WarehouseLocationListScreenState
|
||||
extends State<WarehouseLocationListScreen> {
|
||||
/// 리스트 컨트롤러 (상태 및 CRUD 위임)
|
||||
final WarehouseLocationListController _controller =
|
||||
WarehouseLocationListController();
|
||||
int _currentPage = 1;
|
||||
final int _pageSize = 10;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller.loadWarehouseLocations();
|
||||
}
|
||||
|
||||
/// 리스트 새로고침
|
||||
void _reload() {
|
||||
setState(() {
|
||||
_controller.loadWarehouseLocations();
|
||||
});
|
||||
}
|
||||
|
||||
/// 입고지 추가 폼으로 이동
|
||||
void _navigateToAdd() async {
|
||||
final result = await Navigator.pushNamed(
|
||||
context,
|
||||
Routes.warehouseLocationAdd,
|
||||
);
|
||||
if (result == true) {
|
||||
_reload();
|
||||
}
|
||||
}
|
||||
|
||||
/// 입고지 수정 폼으로 이동
|
||||
void _navigateToEdit(WarehouseLocation location) async {
|
||||
final result = await Navigator.pushNamed(
|
||||
context,
|
||||
Routes.warehouseLocationEdit,
|
||||
arguments: location.id,
|
||||
);
|
||||
if (result == true) {
|
||||
_reload();
|
||||
}
|
||||
}
|
||||
|
||||
/// 삭제 다이얼로그 (별도 위젯으로 분리 가능)
|
||||
void _showDeleteDialog(int id) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => AlertDialog(
|
||||
title: const Text('입고지 삭제'),
|
||||
content: const Text('정말로 삭제하시겠습니까?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_controller.deleteWarehouseLocation(id);
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 대시보드 폭에 맞게 조정
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final maxContentWidth = screenWidth > 1200 ? 1200.0 : screenWidth - 32;
|
||||
|
||||
final int totalCount = _controller.warehouseLocations.length;
|
||||
final int startIndex = (_currentPage - 1) * _pageSize;
|
||||
final int endIndex =
|
||||
(startIndex + _pageSize) > totalCount
|
||||
? totalCount
|
||||
: (startIndex + _pageSize);
|
||||
final List<WarehouseLocation> pagedLocations = _controller
|
||||
.warehouseLocations
|
||||
.sublist(startIndex, endIndex);
|
||||
|
||||
return MainLayout(
|
||||
title: '입고지 관리',
|
||||
currentRoute: Routes.warehouseLocation,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: _reload,
|
||||
color: Colors.grey,
|
||||
),
|
||||
],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
PageTitle(
|
||||
title: '입고지 목록',
|
||||
width: maxContentWidth - 32,
|
||||
rightWidget: ElevatedButton.icon(
|
||||
onPressed: _navigateToAdd,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('입고지 추가'),
|
||||
style: AppThemeTailwind.primaryButtonStyle,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: DataTableCard(
|
||||
width: maxContentWidth - 32,
|
||||
child:
|
||||
pagedLocations.isEmpty
|
||||
? const Center(child: Text('등록된 입고지가 없습니다.'))
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Container(
|
||||
width: maxContentWidth - 32,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: maxContentWidth - 64,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: DataTable(
|
||||
columns: const [
|
||||
DataColumn(label: Text('번호')),
|
||||
DataColumn(label: Text('입고지명')),
|
||||
DataColumn(label: Text('주소')),
|
||||
DataColumn(label: Text('관리')),
|
||||
],
|
||||
rows: List.generate(pagedLocations.length, (i) {
|
||||
final location = pagedLocations[i];
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text('${startIndex + i + 1}')),
|
||||
DataCell(Text(location.name)),
|
||||
DataCell(
|
||||
AddressInput.readonly(
|
||||
address: location.address,
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.edit,
|
||||
color: AppThemeTailwind.primary,
|
||||
),
|
||||
tooltip: '수정',
|
||||
onPressed:
|
||||
() =>
|
||||
_navigateToEdit(location),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
color: AppThemeTailwind.danger,
|
||||
),
|
||||
tooltip: '삭제',
|
||||
onPressed:
|
||||
() => _showDeleteDialog(
|
||||
location.id,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Pagination(
|
||||
currentPage: _currentPage,
|
||||
totalCount: totalCount,
|
||||
pageSize: _pageSize,
|
||||
onPageChanged: (page) {
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user