주요 변경사항: - CLAUDE.md: 프로젝트 규칙 v2.0으로 업데이트, 아키텍처 명확화 - 불필요한 문서 제거: NEXT_TASKS.md, TEST_PROGRESS.md, test_results 파일들 - 테스트 시스템 개선: 실제 API 테스트 스위트 추가 (15개 새 테스트 파일) - License 관리: DTO 모델 개선, API 응답 처리 최적화 - 에러 처리: Interceptor 로직 강화, 상세 로깅 추가 - Company/User/Warehouse 테스트: 자동화 테스트 안정성 향상 - Phone Utils: 전화번호 포맷팅 로직 개선 - Overview Controller: 대시보드 데이터 로딩 최적화 - Analysis Options: Flutter 린트 규칙 추가 테스트 개선: - company_real_api_test.dart: 실제 API 회사 관리 테스트 - equipment_in/out_real_api_test.dart: 장비 입출고 API 테스트 - license_real_api_test.dart: 라이선스 관리 API 테스트 - user_real_api_test.dart: 사용자 관리 API 테스트 - warehouse_location_real_api_test.dart: 창고 위치 API 테스트 - filter_sort_test.dart: 필터링/정렬 기능 테스트 - pagination_test.dart: 페이지네이션 테스트 - interactive_search_test.dart: 검색 기능 테스트 - overview_dashboard_test.dart: 대시보드 통합 테스트 코드 품질: - 모든 서비스에 에러 처리 강화 - DTO 모델 null safety 개선 - 테스트 커버리지 확대 - 불필요한 로그 파일 제거로 리포지토리 정리 Co-Authored-By: Claude <noreply@anthropic.com>
872 lines
30 KiB
Dart
872 lines
30 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:superport/models/license_model.dart';
|
|
import 'package:superport/screens/common/theme_shadcn.dart';
|
|
import 'package:superport/screens/common/components/shadcn_components.dart';
|
|
import 'package:superport/screens/license/controllers/license_list_controller.dart';
|
|
import 'package:superport/utils/constants.dart';
|
|
import 'package:superport/services/mock_data_service.dart';
|
|
import 'package:superport/core/config/environment.dart' as env;
|
|
import 'package:intl/intl.dart';
|
|
|
|
/// shadcn/ui 스타일로 재설계된 유지보수 라이선스 관리 화면
|
|
class LicenseListRedesign extends StatefulWidget {
|
|
const LicenseListRedesign({super.key});
|
|
|
|
@override
|
|
State<LicenseListRedesign> createState() => _LicenseListRedesignState();
|
|
}
|
|
|
|
class _LicenseListRedesignState extends State<LicenseListRedesign> {
|
|
late final LicenseListController _controller;
|
|
final MockDataService _dataService = MockDataService();
|
|
final TextEditingController _searchController = TextEditingController();
|
|
final ScrollController _horizontalScrollController = ScrollController();
|
|
final ScrollController _verticalScrollController = ScrollController();
|
|
|
|
// 날짜 포맷터
|
|
final DateFormat _dateFormat = DateFormat('yyyy-MM-dd');
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
// API 모드 확인 및 로깅
|
|
debugPrint('\n========== 라이센스 화면 초기화 ==========');
|
|
debugPrint('📌 USE_API 설정값: ${env.Environment.useApi}');
|
|
debugPrint('📌 API Base URL: ${env.Environment.apiBaseUrl}');
|
|
|
|
// 실제 API 사용 여부에 따라 컨트롤러 초기화
|
|
final useApi = env.Environment.useApi;
|
|
_controller = LicenseListController(
|
|
useApi: useApi,
|
|
mockDataService: useApi ? null : _dataService,
|
|
);
|
|
|
|
debugPrint('📌 Controller 모드: ${useApi ? "Real API" : "Mock Data"}');
|
|
debugPrint('==========================================\n');
|
|
|
|
_controller.addListener(_handleControllerUpdate);
|
|
|
|
// 초기 데이터 로드
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
_controller.loadData();
|
|
});
|
|
|
|
// 무한 스크롤 리스너 추가
|
|
_verticalScrollController.addListener(_onScroll);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// 리스너 제거
|
|
_verticalScrollController.removeListener(_onScroll);
|
|
_controller.removeListener(_handleControllerUpdate);
|
|
|
|
// 컨트롤러 dispose
|
|
_searchController.dispose();
|
|
_horizontalScrollController.dispose();
|
|
_verticalScrollController.dispose();
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
/// 스크롤 이벤트 처리 (무한 스크롤)
|
|
void _onScroll() {
|
|
if (!_verticalScrollController.hasClients) return;
|
|
|
|
if (_verticalScrollController.position.pixels >=
|
|
_verticalScrollController.position.maxScrollExtent * 0.8) {
|
|
// 스크롤이 80% 이상 내려갔을 때 다음 페이지 로드
|
|
if (!_controller.isLoading && _controller.hasMore) {
|
|
_controller.loadNextPage();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 검색 실행
|
|
void _onSearch() {
|
|
_controller.search(_searchController.text);
|
|
}
|
|
|
|
/// 라이선스 추가 폼으로 이동
|
|
void _navigateToAdd() async {
|
|
final result = await Navigator.pushNamed(context, Routes.licenseAdd);
|
|
if (result == true && mounted) {
|
|
_controller.refresh();
|
|
}
|
|
}
|
|
|
|
/// 라이선스 수정 폼으로 이동
|
|
void _navigateToEdit(int licenseId) async {
|
|
final result = await Navigator.pushNamed(
|
|
context,
|
|
Routes.licenseEdit,
|
|
arguments: licenseId,
|
|
);
|
|
if (result == true && mounted) {
|
|
_controller.refresh();
|
|
}
|
|
}
|
|
|
|
/// 라이선스 삭제 다이얼로그
|
|
void _showDeleteDialog(int licenseId) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('라이선스 삭제'),
|
|
content: const Text('정말로 삭제하시겠습니까?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('취소'),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
_controller.deleteLicense(licenseId).then((_) {
|
|
if (mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('라이선스가 삭제되었습니다.')),
|
|
);
|
|
}
|
|
});
|
|
},
|
|
child: const Text('삭제', style: TextStyle(color: Colors.red)),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 선택된 라이선스 일괄 삭제
|
|
void _showBulkDeleteDialog() {
|
|
final selectedCount = _controller.selectedCount;
|
|
if (selectedCount == 0) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('삭제할 라이선스를 선택해주세요.')),
|
|
);
|
|
return;
|
|
}
|
|
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text('$selectedCount개 라이선스 삭제'),
|
|
content: Text('선택한 $selectedCount개의 라이선스를 삭제하시겠습니까?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('취소'),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
_controller.deleteSelectedLicenses().then((_) {
|
|
if (mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text('$selectedCount개 라이선스가 삭제되었습니다.')),
|
|
);
|
|
}
|
|
});
|
|
},
|
|
child: const Text('삭제', style: TextStyle(color: Colors.red)),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 엑셀 내보내기 안내
|
|
void _showExportInfo() {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text('엑셀 내보내기 기능은 준비 중입니다.'),
|
|
duration: Duration(seconds: 2),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 엑셀 가져오기 안내
|
|
void _showImportInfo() {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text('엑셀 가져오기 기능은 준비 중입니다.'),
|
|
duration: Duration(seconds: 2),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 만료일까지 남은 일수에 따른 색상
|
|
Color _getDaysRemainingColor(int? days) {
|
|
if (days == null) return ShadcnTheme.mutedForeground;
|
|
if (days <= 0) return ShadcnTheme.destructive;
|
|
if (days <= 7) return Colors.red;
|
|
if (days <= 30) return Colors.orange;
|
|
return ShadcnTheme.foreground;
|
|
}
|
|
|
|
/// 만료일까지 남은 일수 텍스트
|
|
String _getDaysRemainingText(int? days) {
|
|
if (days == null) return '-';
|
|
if (days <= 0) return '만료됨';
|
|
if (days == 1) return '1일';
|
|
return '$days일';
|
|
}
|
|
|
|
/// 컨트롤러 업데이트 핸들러
|
|
void _handleControllerUpdate() {
|
|
if (mounted) {
|
|
setState(() {});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider<LicenseListController>.value(
|
|
value: _controller,
|
|
child: Consumer<LicenseListController>(
|
|
builder: (context, controller, child) {
|
|
return Container(
|
|
color: ShadcnTheme.background,
|
|
child: Column(
|
|
children: [
|
|
// 상단 통계 카드
|
|
_buildStatisticsCards(),
|
|
|
|
// 필터 및 액션 바
|
|
_buildFilterBar(),
|
|
|
|
// 라이선스 테이블
|
|
Expanded(
|
|
child: controller.isLoading && controller.licenses.isEmpty
|
|
? _buildLoadingState()
|
|
: controller.error != null
|
|
? _buildErrorState()
|
|
: _buildLicenseTable(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 상단 통계 카드 섹션
|
|
Widget _buildStatisticsCards() {
|
|
return Container(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: _buildStatCard(
|
|
'전체 라이선스',
|
|
'${_controller.statistics['total'] ?? 0}',
|
|
Icons.description,
|
|
ShadcnTheme.primary,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: _buildStatCard(
|
|
'활성 라이선스',
|
|
'${_controller.statistics['active'] ?? 0}',
|
|
Icons.check_circle,
|
|
ShadcnTheme.success,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: _buildStatCard(
|
|
'30일 내 만료',
|
|
'${_controller.statistics['expiringSoon'] ?? 0}',
|
|
Icons.warning,
|
|
Colors.orange,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: _buildStatCard(
|
|
'만료됨',
|
|
'${_controller.statistics['expired'] ?? 0}',
|
|
Icons.cancel,
|
|
ShadcnTheme.destructive,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 통계 카드 위젯
|
|
Widget _buildStatCard(String title, String value, IconData icon, Color color) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: ShadcnTheme.card,
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
border: Border.all(color: ShadcnTheme.border),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(icon, size: 20, color: color),
|
|
const SizedBox(width: 8),
|
|
Text(title, style: ShadcnTheme.bodySmall),
|
|
],
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
value,
|
|
style: ShadcnTheme.headingH3.copyWith(color: color),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 필터 바
|
|
Widget _buildFilterBar() {
|
|
return Container(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
children: [
|
|
// 검색 및 필터 섹션
|
|
Row(
|
|
children: [
|
|
// 검색 입력
|
|
Expanded(
|
|
flex: 2,
|
|
child: ShadcnInput(
|
|
controller: _searchController,
|
|
placeholder: '제품명, 라이선스 키, 벤더명, 회사명 검색...',
|
|
prefixIcon: const Icon(Icons.search),
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
|
|
// 검색 버튼
|
|
ShadcnButton(
|
|
text: '검색',
|
|
onPressed: _onSearch,
|
|
variant: ShadcnButtonVariant.primary,
|
|
textColor: Colors.white,
|
|
icon: const Icon(Icons.search, size: 16),
|
|
),
|
|
const SizedBox(width: 16),
|
|
|
|
// 상태 필터 드롭다운
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: ShadcnTheme.border),
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
),
|
|
child: DropdownButton<LicenseStatusFilter>(
|
|
value: _controller.statusFilter,
|
|
onChanged: (value) {
|
|
if (value != null) {
|
|
_controller.changeStatusFilter(value);
|
|
}
|
|
},
|
|
underline: const SizedBox.shrink(),
|
|
items: const [
|
|
DropdownMenuItem(
|
|
value: LicenseStatusFilter.all,
|
|
child: Text('전체'),
|
|
),
|
|
DropdownMenuItem(
|
|
value: LicenseStatusFilter.active,
|
|
child: Text('활성'),
|
|
),
|
|
DropdownMenuItem(
|
|
value: LicenseStatusFilter.inactive,
|
|
child: Text('비활성'),
|
|
),
|
|
DropdownMenuItem(
|
|
value: LicenseStatusFilter.expiringSoon,
|
|
child: Text('만료예정'),
|
|
),
|
|
DropdownMenuItem(
|
|
value: LicenseStatusFilter.expired,
|
|
child: Text('만료됨'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// 액션 버튼들 및 상태 표시
|
|
Row(
|
|
children: [
|
|
// 액션 버튼들
|
|
ShadcnButton(
|
|
text: '라이선스 추가',
|
|
onPressed: _navigateToAdd,
|
|
variant: ShadcnButtonVariant.primary,
|
|
textColor: Colors.white,
|
|
icon: const Icon(Icons.add, size: 16),
|
|
),
|
|
const SizedBox(width: 8),
|
|
|
|
ShadcnButton(
|
|
text: '삭제',
|
|
onPressed: _controller.selectedCount > 0 ? _showBulkDeleteDialog : null,
|
|
variant: _controller.selectedCount > 0
|
|
? ShadcnButtonVariant.destructive
|
|
: ShadcnButtonVariant.secondary,
|
|
icon: const Icon(Icons.delete, size: 16),
|
|
),
|
|
const SizedBox(width: 8),
|
|
|
|
ShadcnButton(
|
|
text: '엑셀 내보내기',
|
|
onPressed: _showExportInfo,
|
|
variant: ShadcnButtonVariant.secondary,
|
|
icon: const Icon(Icons.download, size: 16),
|
|
),
|
|
const SizedBox(width: 8),
|
|
|
|
ShadcnButton(
|
|
text: '엑셀 가져오기',
|
|
onPressed: _showImportInfo,
|
|
variant: ShadcnButtonVariant.secondary,
|
|
icon: const Icon(Icons.upload, size: 16),
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
// 선택 및 총 개수 표시
|
|
if (_controller.selectedCount > 0)
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
vertical: 8,
|
|
horizontal: 16,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusSm),
|
|
),
|
|
child: Text(
|
|
'${_controller.selectedCount}개 선택됨',
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
if (_controller.selectedCount > 0) const SizedBox(width: 12),
|
|
|
|
Text(
|
|
'총 ${_controller.licenses.length}개',
|
|
style: ShadcnTheme.bodyMuted,
|
|
),
|
|
const SizedBox(width: 12),
|
|
|
|
// 새로고침 버튼
|
|
IconButton(
|
|
icon: const Icon(Icons.refresh),
|
|
onPressed: () => _controller.refresh(),
|
|
tooltip: '새로고침',
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 로딩 상태
|
|
Widget _buildLoadingState() {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
CircularProgressIndicator(color: ShadcnTheme.primary),
|
|
const SizedBox(height: 16),
|
|
Text('라이선스 데이터를 불러오는 중...', style: ShadcnTheme.bodyMuted),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 에러 상태
|
|
Widget _buildErrorState() {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(Icons.error_outline, size: 48, color: ShadcnTheme.destructive),
|
|
const SizedBox(height: 16),
|
|
Text('데이터를 불러오는 중 오류가 발생했습니다.', style: ShadcnTheme.bodyMuted),
|
|
const SizedBox(height: 8),
|
|
Text(_controller.error ?? '', style: ShadcnTheme.bodySmall),
|
|
const SizedBox(height: 16),
|
|
ShadcnButton(
|
|
text: '다시 시도',
|
|
onPressed: () => _controller.refresh(),
|
|
variant: ShadcnButtonVariant.primary,
|
|
textColor: Colors.white,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 라이선스 테이블
|
|
Widget _buildLicenseTable() {
|
|
final licenses = _controller.licenses;
|
|
|
|
if (licenses.isEmpty) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.description_outlined,
|
|
size: 48,
|
|
color: ShadcnTheme.mutedForeground,
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text('등록된 라이선스가 없습니다.', style: ShadcnTheme.bodyMuted),
|
|
const SizedBox(height: 16),
|
|
ShadcnButton(
|
|
text: '라이선스 추가',
|
|
onPressed: _navigateToAdd,
|
|
variant: ShadcnButtonVariant.primary,
|
|
textColor: Colors.white,
|
|
icon: const Icon(Icons.add, size: 16),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(24),
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
controller: _horizontalScrollController,
|
|
child: Container(
|
|
constraints: BoxConstraints(
|
|
minWidth: MediaQuery.of(context).size.width - 48,
|
|
),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: ShadcnTheme.border),
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
// 테이블 헤더
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: ShadcnTheme.spacing4,
|
|
vertical: ShadcnTheme.spacing3,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
|
border: Border(
|
|
bottom: BorderSide(color: ShadcnTheme.border),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// 체크박스
|
|
SizedBox(
|
|
width: 40,
|
|
child: Checkbox(
|
|
value: _controller.isAllSelected,
|
|
onChanged: (value) => _controller.selectAll(value),
|
|
tristate: false,
|
|
),
|
|
),
|
|
// 번호
|
|
const SizedBox(
|
|
width: 60,
|
|
child: Text('번호', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 제품명
|
|
const SizedBox(
|
|
width: 200,
|
|
child: Text('제품명', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 라이선스 키
|
|
const SizedBox(
|
|
width: 150,
|
|
child: Text('라이선스 키', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 벤더
|
|
const SizedBox(
|
|
width: 120,
|
|
child: Text('벤더', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 회사명
|
|
const SizedBox(
|
|
width: 150,
|
|
child: Text('회사명', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 할당 사용자
|
|
const SizedBox(
|
|
width: 100,
|
|
child: Text('할당 사용자', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 상태
|
|
const SizedBox(
|
|
width: 80,
|
|
child: Text('상태', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 구매일
|
|
const SizedBox(
|
|
width: 100,
|
|
child: Text('구매일', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 만료일
|
|
const SizedBox(
|
|
width: 100,
|
|
child: Text('만료일', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 남은 일수
|
|
const SizedBox(
|
|
width: 80,
|
|
child: Text('남은 일수', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
// 관리
|
|
const SizedBox(
|
|
width: 100,
|
|
child: Text('관리', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// 테이블 데이터
|
|
SizedBox(
|
|
height: 400,
|
|
width: 1360, // 모든 컬럼 너비의 합
|
|
child: ListView.builder(
|
|
controller: _verticalScrollController,
|
|
itemCount: licenses.length,
|
|
itemBuilder: (context, index) {
|
|
final license = licenses[index];
|
|
final daysRemaining = _controller.getDaysUntilExpiry(license);
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: ShadcnTheme.spacing4,
|
|
vertical: ShadcnTheme.spacing3,
|
|
),
|
|
decoration: BoxDecoration(
|
|
border: Border(
|
|
bottom: BorderSide(color: ShadcnTheme.border),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// 체크박스
|
|
SizedBox(
|
|
width: 40,
|
|
child: Checkbox(
|
|
value: license.id != null && _controller.selectedLicenseIds.contains(license.id),
|
|
onChanged: license.id != null
|
|
? (value) => _controller.selectLicense(license.id, value)
|
|
: null,
|
|
tristate: false,
|
|
),
|
|
),
|
|
// 번호
|
|
SizedBox(
|
|
width: 60,
|
|
child: Text('${index + 1}', style: ShadcnTheme.bodySmall),
|
|
),
|
|
// 제품명
|
|
SizedBox(
|
|
width: 200,
|
|
child: Text(
|
|
license.productName ?? '-',
|
|
style: ShadcnTheme.bodyMedium,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
// 라이선스 키
|
|
SizedBox(
|
|
width: 150,
|
|
child: Text(
|
|
license.licenseKey,
|
|
style: ShadcnTheme.bodySmall,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
// 벤더
|
|
SizedBox(
|
|
width: 120,
|
|
child: Text(
|
|
license.vendor ?? '-',
|
|
style: ShadcnTheme.bodySmall,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
// 회사명
|
|
SizedBox(
|
|
width: 150,
|
|
child: Text(
|
|
license.companyName ?? '-',
|
|
style: ShadcnTheme.bodySmall,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
// 할당 사용자
|
|
SizedBox(
|
|
width: 100,
|
|
child: Text(
|
|
license.assignedUserName ?? '-',
|
|
style: ShadcnTheme.bodySmall,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
// 상태
|
|
SizedBox(
|
|
width: 80,
|
|
child: _buildStatusBadge(license, daysRemaining),
|
|
),
|
|
// 구매일
|
|
SizedBox(
|
|
width: 100,
|
|
child: Text(
|
|
license.purchaseDate != null
|
|
? _dateFormat.format(license.purchaseDate!)
|
|
: '-',
|
|
style: ShadcnTheme.bodySmall,
|
|
),
|
|
),
|
|
// 만료일
|
|
SizedBox(
|
|
width: 100,
|
|
child: Text(
|
|
license.expiryDate != null
|
|
? _dateFormat.format(license.expiryDate!)
|
|
: '-',
|
|
style: ShadcnTheme.bodySmall,
|
|
),
|
|
),
|
|
// 남은 일수
|
|
SizedBox(
|
|
width: 80,
|
|
child: Text(
|
|
_getDaysRemainingText(daysRemaining),
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: _getDaysRemainingColor(daysRemaining),
|
|
fontWeight: daysRemaining != null && daysRemaining <= 30
|
|
? FontWeight.bold
|
|
: FontWeight.normal,
|
|
),
|
|
),
|
|
),
|
|
// 관리
|
|
SizedBox(
|
|
width: 100,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
IconButton(
|
|
constraints: const BoxConstraints(
|
|
minWidth: 32,
|
|
minHeight: 32,
|
|
),
|
|
padding: EdgeInsets.zero,
|
|
icon: Icon(
|
|
Icons.edit,
|
|
size: 16,
|
|
color: ShadcnTheme.primary,
|
|
),
|
|
onPressed: license.id != null
|
|
? () => _navigateToEdit(license.id!)
|
|
: null,
|
|
tooltip: '수정',
|
|
),
|
|
IconButton(
|
|
constraints: const BoxConstraints(
|
|
minWidth: 32,
|
|
minHeight: 32,
|
|
),
|
|
padding: EdgeInsets.zero,
|
|
icon: Icon(
|
|
Icons.delete,
|
|
size: 16,
|
|
color: ShadcnTheme.destructive,
|
|
),
|
|
onPressed: license.id != null
|
|
? () => _showDeleteDialog(license.id!)
|
|
: null,
|
|
tooltip: '삭제',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
|
|
// 더 보기 버튼
|
|
if (_controller.hasMore)
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Center(
|
|
child: _controller.isLoading
|
|
? const CircularProgressIndicator()
|
|
: ShadcnButton(
|
|
text: '더 보기',
|
|
onPressed: () => _controller.loadNextPage(),
|
|
variant: ShadcnButtonVariant.secondary,
|
|
icon: const Icon(Icons.expand_more, size: 16),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 라이선스 상태 표시 배지
|
|
Widget _buildStatusBadge(License license, int? daysRemaining) {
|
|
// 만료 상태 확인
|
|
if (daysRemaining != null && daysRemaining <= 0) {
|
|
return ShadcnBadge(
|
|
text: '만료',
|
|
variant: ShadcnBadgeVariant.destructive,
|
|
size: ShadcnBadgeSize.small,
|
|
);
|
|
}
|
|
|
|
// 만료 임박
|
|
if (daysRemaining != null && daysRemaining <= 30) {
|
|
return ShadcnBadge(
|
|
text: '만료예정',
|
|
variant: ShadcnBadgeVariant.warning,
|
|
size: ShadcnBadgeSize.small,
|
|
);
|
|
}
|
|
|
|
// 활성/비활성
|
|
if (license.isActive) {
|
|
return ShadcnBadge(
|
|
text: '활성',
|
|
variant: ShadcnBadgeVariant.success,
|
|
size: ShadcnBadgeSize.small,
|
|
);
|
|
} else {
|
|
return ShadcnBadge(
|
|
text: '비활성',
|
|
variant: ShadcnBadgeVariant.secondary,
|
|
size: ShadcnBadgeSize.small,
|
|
);
|
|
}
|
|
}
|
|
} |