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,174 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/models/license_model.dart';
|
||||
import 'package:superport/screens/common/theme_tailwind.dart';
|
||||
import 'package:superport/screens/common/main_layout.dart';
|
||||
import 'package:superport/screens/common/custom_widgets.dart';
|
||||
import 'package:superport/services/mock_data_service.dart';
|
||||
import 'package:superport/utils/constants.dart';
|
||||
import 'package:superport/screens/license/controllers/license_list_controller.dart';
|
||||
import 'package:superport/screens/license/widgets/license_table.dart';
|
||||
import 'package:superport/screens/common/widgets/pagination.dart';
|
||||
|
||||
// 유지보수 목록 화면 (UI만 담당, 상태/로직/테이블 분리)
|
||||
class MaintenanceListScreen extends StatefulWidget {
|
||||
const MaintenanceListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<MaintenanceListScreen> createState() => _MaintenanceListScreenState();
|
||||
}
|
||||
|
||||
// 유지보수 목록 화면의 상태 클래스
|
||||
class _MaintenanceListScreenState extends State<MaintenanceListScreen> {
|
||||
late final LicenseListController _controller;
|
||||
// 페이지네이션 상태 추가
|
||||
int _currentPage = 1;
|
||||
final int _pageSize = 10;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = LicenseListController(dataService: MockDataService());
|
||||
_controller.loadData();
|
||||
}
|
||||
|
||||
void _reload() {
|
||||
setState(() {
|
||||
_controller.loadData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToAddScreen() async {
|
||||
final result = await Navigator.pushNamed(context, '/license/add');
|
||||
if (result == true) {
|
||||
_reload();
|
||||
}
|
||||
}
|
||||
|
||||
void _navigateToEditScreen(int id) async {
|
||||
final result = await Navigator.pushNamed(
|
||||
context,
|
||||
'/license/edit',
|
||||
arguments: id,
|
||||
);
|
||||
if (result == true) {
|
||||
_reload();
|
||||
}
|
||||
}
|
||||
|
||||
void _deleteLicense(int id) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => AlertDialog(
|
||||
title: const Text('삭제 확인'),
|
||||
content: const Text('이 라이센스 정보를 삭제하시겠습니까?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_controller.deleteLicense(id);
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 회사명 반환 함수 (재사용성 위해 분리)
|
||||
String _getCompanyName(int companyId) {
|
||||
return MockDataService().getCompanyById(companyId)?.name ?? '-';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 대시보드 폭에 맞게 조정
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final maxContentWidth = screenWidth > 1200 ? 1200.0 : screenWidth - 32;
|
||||
|
||||
// 페이지네이션 데이터 슬라이싱
|
||||
final int totalCount = _controller.licenses.length;
|
||||
final int startIndex = (_currentPage - 1) * _pageSize;
|
||||
final int endIndex =
|
||||
(startIndex + _pageSize) > totalCount
|
||||
? totalCount
|
||||
: (startIndex + _pageSize);
|
||||
final pagedLicenses = _controller.licenses.sublist(startIndex, endIndex);
|
||||
|
||||
return MainLayout(
|
||||
title: '유지보수 관리',
|
||||
currentRoute: Routes.license,
|
||||
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: _navigateToAddScreen,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('추가'),
|
||||
style: AppThemeTailwind.primaryButtonStyle,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: DataTableCard(
|
||||
width: maxContentWidth - 32,
|
||||
child:
|
||||
pagedLicenses.isEmpty
|
||||
? const Center(child: Text('등록된 라이센스 정보가 없습니다.'))
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: maxContentWidth - 64,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: LicenseTable(
|
||||
licenses: pagedLicenses,
|
||||
getCompanyName: _getCompanyName,
|
||||
onEdit: _navigateToEditScreen,
|
||||
onDelete: _deleteLicense,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 페이지네이션 위젯 추가
|
||||
if (totalCount > _pageSize)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Pagination(
|
||||
totalCount: totalCount,
|
||||
currentPage: _currentPage,
|
||||
pageSize: _pageSize,
|
||||
onPageChanged: (page) {
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/models/license_model.dart';
|
||||
import 'package:superport/screens/common/theme_tailwind.dart';
|
||||
|
||||
// 라이센스 목록 테이블 위젯 (SRP, 재사용성)
|
||||
class LicenseTable extends StatelessWidget {
|
||||
final List<License> licenses;
|
||||
final String Function(int companyId) getCompanyName;
|
||||
final void Function(int id) onEdit;
|
||||
final void Function(int id) onDelete;
|
||||
|
||||
const LicenseTable({
|
||||
super.key,
|
||||
required this.licenses,
|
||||
required this.getCompanyName,
|
||||
required this.onEdit,
|
||||
required this.onDelete,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DataTable(
|
||||
columns: const [
|
||||
DataColumn(label: Text('번호')),
|
||||
DataColumn(label: Text('유지보수명')),
|
||||
DataColumn(label: Text('기간')),
|
||||
DataColumn(label: Text('방문주기')),
|
||||
DataColumn(label: Text('점검형태')),
|
||||
DataColumn(label: Text('관리')),
|
||||
],
|
||||
rows:
|
||||
licenses.map((license) {
|
||||
// name에서 기간, 방문주기, 점검형태 파싱 (예: '12개월,격월,방문')
|
||||
final parts = license.name.split(',');
|
||||
final period = parts.isNotEmpty ? parts[0] : '-';
|
||||
final visit = parts.length > 1 ? parts[1] : '-';
|
||||
final inspection = parts.length > 2 ? parts[2] : '-';
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text('${license.id}')),
|
||||
DataCell(Text(license.name)),
|
||||
DataCell(Text(period)),
|
||||
DataCell(Text(visit)),
|
||||
DataCell(Text(inspection)),
|
||||
DataCell(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.edit,
|
||||
color: AppThemeTailwind.primary,
|
||||
),
|
||||
onPressed: () => onEdit(license.id!),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
color: AppThemeTailwind.danger,
|
||||
),
|
||||
onPressed: () => onDelete(license.id!),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user