프로젝트 최초 커밋
This commit is contained in:
71
lib/screens/license/widgets/license_table.dart
Normal file
71
lib/screens/license/widgets/license_table.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
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