feat: 회사 관리 기능 개선 및 지점 평면화 DTO 추가
- CompanyBranchFlatDto 모델 추가로 지점 데이터 처리 개선 - 회사 서비스에 브랜치 평면화 기능 추가 - 회사 폼 컨트롤러 기능 확장 - 회사 리스트 화면 UI 개선 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import 'package:superport/services/mock_data_service.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
import 'package:superport/screens/company/controllers/branch_form_controller.dart';
|
||||
import 'package:superport/core/config/environment.dart' as env;
|
||||
|
||||
/// 회사 유형 선택 위젯 (체크박스)
|
||||
class CompanyTypeSelector extends StatelessWidget {
|
||||
@@ -107,10 +108,36 @@ class _CompanyFormScreenState extends State<CompanyFormScreen> {
|
||||
companyId = args['companyId'];
|
||||
branchId = args['branchId'];
|
||||
}
|
||||
|
||||
// API 모드 확인
|
||||
final useApi = env.Environment.useApi;
|
||||
debugPrint('📌 회사 폼 초기화 - API 모드: $useApi, companyId: $companyId');
|
||||
|
||||
_controller = CompanyFormController(
|
||||
dataService: MockDataService(),
|
||||
dataService: useApi ? null : MockDataService(),
|
||||
companyId: companyId,
|
||||
useApi: useApi,
|
||||
);
|
||||
|
||||
// 일반 회사 수정 모드일 때 데이터 로드
|
||||
if (!isBranch && companyId != null) {
|
||||
debugPrint('📌 회사 데이터 로드 시작...');
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_controller.loadCompanyData().then((_) {
|
||||
debugPrint('📌 회사 데이터 로드 완료, UI 갱신');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
debugPrint('📌 setState 호출됨');
|
||||
debugPrint('📌 nameController.text: "${_controller.nameController.text}"');
|
||||
debugPrint('📌 contactNameController.text: "${_controller.contactNameController.text}"');
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
debugPrint('❌ 회사 데이터 로드 실패: $error');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 지점 수정 모드일 때 branchId로 branch 정보 세팅
|
||||
if (isBranch && branchId != null) {
|
||||
final company = MockDataService().getCompanyById(companyId!);
|
||||
@@ -471,7 +498,7 @@ class _CompanyFormScreenState extends State<CompanyFormScreen> {
|
||||
),
|
||||
),
|
||||
],
|
||||
// 저장 버튼
|
||||
// 저장 버튼 추가
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0, bottom: 16.0),
|
||||
child: ElevatedButton(
|
||||
@@ -488,6 +515,7 @@ class _CompanyFormScreenState extends State<CompanyFormScreen> {
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -6,7 +6,8 @@ import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
import 'package:superport/screens/common/components/shadcn_components.dart';
|
||||
import 'package:superport/screens/common/widgets/pagination.dart';
|
||||
import 'package:superport/screens/common/widgets/unified_search_bar.dart';
|
||||
import 'package:superport/screens/common/widgets/standard_data_table.dart' as std_table;
|
||||
import 'package:superport/screens/common/widgets/standard_data_table.dart'
|
||||
as std_table;
|
||||
import 'package:superport/screens/common/widgets/standard_action_bar.dart';
|
||||
import 'package:superport/screens/common/widgets/standard_states.dart';
|
||||
import 'package:superport/screens/common/layouts/base_list_screen.dart';
|
||||
@@ -123,44 +124,58 @@ class _CompanyListRedesignState extends State<CompanyListRedesign> {
|
||||
|
||||
/// 회사 유형 배지 생성
|
||||
Widget _buildCompanyTypeChips(List<CompanyType> types) {
|
||||
return Wrap(
|
||||
spacing: ShadcnTheme.spacing1,
|
||||
children:
|
||||
types.map((type) {
|
||||
Color bgColor;
|
||||
Color borderColor;
|
||||
Color textColor;
|
||||
|
||||
switch(type) {
|
||||
case CompanyType.customer:
|
||||
bgColor = ShadcnTheme.green.withValues(alpha: 0.9);
|
||||
textColor = Colors.white;
|
||||
break;
|
||||
case CompanyType.partner:
|
||||
bgColor = ShadcnTheme.purple.withValues(alpha: 0.9);
|
||||
textColor = Colors.white;
|
||||
break;
|
||||
default:
|
||||
bgColor = ShadcnTheme.muted.withValues(alpha: 0.9);
|
||||
textColor = ShadcnTheme.foreground;
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
companyTypeToString(type),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: textColor,
|
||||
// 유형이 없으면 기본값 표시
|
||||
if (types.isEmpty) {
|
||||
return Text(
|
||||
'-',
|
||||
style: ShadcnTheme.bodySmall.copyWith(color: ShadcnTheme.muted),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Wrap(
|
||||
spacing: 4,
|
||||
runSpacing: 2,
|
||||
children: types.map((type) {
|
||||
Color bgColor;
|
||||
Color textColor;
|
||||
|
||||
switch (type) {
|
||||
case CompanyType.customer:
|
||||
bgColor = ShadcnTheme.green.withValues(alpha: 0.9);
|
||||
textColor = Colors.white;
|
||||
break;
|
||||
case CompanyType.partner:
|
||||
bgColor = ShadcnTheme.purple.withValues(alpha: 0.9);
|
||||
textColor = Colors.white;
|
||||
break;
|
||||
default:
|
||||
bgColor = ShadcnTheme.muted.withValues(alpha: 0.9);
|
||||
textColor = ShadcnTheme.foreground;
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
child: Text(
|
||||
companyTypeToString(type),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -169,9 +184,10 @@ class _CompanyListRedesignState extends State<CompanyListRedesign> {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: isBranch
|
||||
? ShadcnTheme.blue.withValues(alpha: 0.9)
|
||||
: ShadcnTheme.primary.withValues(alpha: 0.9),
|
||||
color:
|
||||
isBranch
|
||||
? ShadcnTheme.blue.withValues(alpha: 0.9)
|
||||
: ShadcnTheme.primary.withValues(alpha: 0.9),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
@@ -232,37 +248,51 @@ class _CompanyListRedesignState extends State<CompanyListRedesign> {
|
||||
}
|
||||
|
||||
final int totalCount = displayCompanies.length;
|
||||
|
||||
|
||||
// 페이지네이션을 위한 데이터 처리
|
||||
final int startIndex = (_currentPage - 1) * _pageSize;
|
||||
final int endIndex = startIndex + _pageSize;
|
||||
final List<Map<String, dynamic>> pagedCompanies = displayCompanies.sublist(
|
||||
startIndex,
|
||||
endIndex > displayCompanies.length ? displayCompanies.length : endIndex,
|
||||
);
|
||||
|
||||
// startIndex가 displayCompanies.length보다 크거나 같으면 첫 페이지로 리셋
|
||||
if (startIndex >= displayCompanies.length && displayCompanies.isNotEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_currentPage = 1;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
final List<Map<String, dynamic>> pagedCompanies = displayCompanies.isEmpty
|
||||
? []
|
||||
: displayCompanies.sublist(
|
||||
startIndex.clamp(0, displayCompanies.length - 1),
|
||||
endIndex.clamp(0, displayCompanies.length),
|
||||
);
|
||||
|
||||
// 로딩 상태
|
||||
if (controller.isLoading && controller.companies.isEmpty) {
|
||||
return const StandardLoadingState(
|
||||
message: '회사 데이터를 불러오는 중...',
|
||||
);
|
||||
return const StandardLoadingState(message: '회사 데이터를 불러오는 중...');
|
||||
}
|
||||
|
||||
return BaseListScreen(
|
||||
isLoading: false,
|
||||
error: controller.error,
|
||||
onRefresh: controller.refresh,
|
||||
emptyMessage: controller.searchKeyword.isNotEmpty
|
||||
? '검색 결과가 없습니다'
|
||||
: '등록된 회사가 없습니다',
|
||||
emptyMessage:
|
||||
controller.searchKeyword.isNotEmpty
|
||||
? '검색 결과가 없습니다'
|
||||
: '등록된 회사가 없습니다',
|
||||
emptyIcon: Icons.business_outlined,
|
||||
|
||||
|
||||
// 검색바
|
||||
searchBar: UnifiedSearchBar(
|
||||
controller: _searchController,
|
||||
placeholder: '회사명, 담당자명, 연락처로 검색',
|
||||
onChanged: _onSearchChanged, // 실시간 검색 (디바운싱)
|
||||
onSearch: () => _controller.updateSearchKeyword(_searchController.text), // 즉시 검색
|
||||
onChanged: _onSearchChanged, // 실시간 검색 (디바운싱)
|
||||
onSearch:
|
||||
() => _controller.updateSearchKeyword(
|
||||
_searchController.text,
|
||||
), // 즉시 검색
|
||||
onClear: () {
|
||||
_searchController.clear();
|
||||
_onSearchChanged('');
|
||||
@@ -272,155 +302,169 @@ class _CompanyListRedesignState extends State<CompanyListRedesign> {
|
||||
onPressed: _navigateToAddScreen,
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// 액션바
|
||||
actionBar: StandardActionBar(
|
||||
leftActions: [],
|
||||
totalCount: totalCount,
|
||||
onRefresh: controller.refresh,
|
||||
statusMessage: controller.searchKeyword.isNotEmpty
|
||||
? '"${controller.searchKeyword}" 검색 결과'
|
||||
: null,
|
||||
statusMessage:
|
||||
controller.searchKeyword.isNotEmpty
|
||||
? '"${controller.searchKeyword}" 검색 결과'
|
||||
: null,
|
||||
),
|
||||
|
||||
// 에러 메시지
|
||||
filterSection: controller.error != null
|
||||
? StandardInfoMessage(
|
||||
message: controller.error!,
|
||||
icon: Icons.error_outline,
|
||||
color: ShadcnTheme.destructive,
|
||||
onClose: controller.clearError,
|
||||
)
|
||||
: null,
|
||||
filterSection:
|
||||
controller.error != null
|
||||
? StandardInfoMessage(
|
||||
message: controller.error!,
|
||||
icon: Icons.error_outline,
|
||||
color: ShadcnTheme.destructive,
|
||||
onClose: controller.clearError,
|
||||
)
|
||||
: null,
|
||||
|
||||
// 데이터 테이블
|
||||
dataTable: displayCompanies.isEmpty
|
||||
? StandardEmptyState(
|
||||
title: controller.searchKeyword.isNotEmpty
|
||||
? '검색 결과가 없습니다'
|
||||
: '등록된 회사가 없습니다',
|
||||
icon: Icons.business_outlined,
|
||||
action: controller.searchKeyword.isEmpty
|
||||
? StandardActionButtons.addButton(
|
||||
text: '첫 회사 추가하기',
|
||||
onPressed: _navigateToAddScreen,
|
||||
)
|
||||
: null,
|
||||
)
|
||||
: std_table.StandardDataTable(
|
||||
columns: [
|
||||
std_table.DataColumn(label: '번호', flex: 1),
|
||||
std_table.DataColumn(label: '회사명', flex: 3),
|
||||
std_table.DataColumn(label: '구분', flex: 2),
|
||||
std_table.DataColumn(label: '유형', flex: 2),
|
||||
std_table.DataColumn(label: '연락처', flex: 2),
|
||||
std_table.DataColumn(label: '관리', flex: 2),
|
||||
],
|
||||
rows: [
|
||||
...pagedCompanies.asMap().entries.map((entry) {
|
||||
final int index = startIndex + entry.key;
|
||||
final companyData = entry.value;
|
||||
final bool isBranch = companyData['isBranch'] as bool;
|
||||
final Company company =
|
||||
isBranch
|
||||
? _convertBranchToCompany(companyData['branch'] as Branch)
|
||||
: companyData['company'] as Company;
|
||||
final String? mainCompanyName =
|
||||
companyData['mainCompanyName'] as String?;
|
||||
dataTable:
|
||||
displayCompanies.isEmpty
|
||||
? StandardEmptyState(
|
||||
title:
|
||||
controller.searchKeyword.isNotEmpty
|
||||
? '검색 결과가 없습니다'
|
||||
: '등록된 회사가 없습니다',
|
||||
icon: Icons.business_outlined,
|
||||
action:
|
||||
controller.searchKeyword.isEmpty
|
||||
? StandardActionButtons.addButton(
|
||||
text: '첫 회사 추가하기',
|
||||
onPressed: _navigateToAddScreen,
|
||||
)
|
||||
: null,
|
||||
)
|
||||
: std_table.StandardDataTable(
|
||||
columns: [
|
||||
std_table.DataColumn(label: '번호', flex: 1),
|
||||
std_table.DataColumn(label: '회사명', flex: 3),
|
||||
std_table.DataColumn(label: '구분', flex: 1),
|
||||
std_table.DataColumn(label: '유형', flex: 2),
|
||||
std_table.DataColumn(label: '연락처', flex: 2),
|
||||
std_table.DataColumn(label: '관리', flex: 2),
|
||||
],
|
||||
rows: [
|
||||
...pagedCompanies.asMap().entries.map((entry) {
|
||||
final int index = startIndex + entry.key;
|
||||
final companyData = entry.value;
|
||||
final bool isBranch = companyData['isBranch'] as bool;
|
||||
final Company company =
|
||||
isBranch
|
||||
? _convertBranchToCompany(
|
||||
companyData['branch'] as Branch,
|
||||
)
|
||||
: companyData['company'] as Company;
|
||||
final String? mainCompanyName =
|
||||
companyData['mainCompanyName'] as String?;
|
||||
|
||||
return std_table.StandardDataRow(
|
||||
index: index,
|
||||
columns: [
|
||||
std_table.DataColumn(label: '번호', flex: 1),
|
||||
std_table.DataColumn(label: '회사명', flex: 3),
|
||||
std_table.DataColumn(label: '구분', flex: 2),
|
||||
std_table.DataColumn(label: '유형', flex: 2),
|
||||
std_table.DataColumn(label: '연락처', flex: 2),
|
||||
std_table.DataColumn(label: '관리', flex: 2),
|
||||
],
|
||||
cells: [
|
||||
// 번호
|
||||
Text(
|
||||
'${index + 1}',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
// 회사명
|
||||
_buildCompanyNameText(
|
||||
company,
|
||||
isBranch,
|
||||
mainCompanyName: mainCompanyName,
|
||||
),
|
||||
// 구분
|
||||
_buildCompanyTypeLabel(isBranch),
|
||||
// 유형
|
||||
_buildCompanyTypeChips(
|
||||
company.companyTypes,
|
||||
),
|
||||
// 연락처
|
||||
Text(
|
||||
company.contactPhone ?? '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
// 관리
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (!isBranch &&
|
||||
company.branches != null &&
|
||||
company.branches!.isNotEmpty) ...[
|
||||
ShadcnButton(
|
||||
text: '지점',
|
||||
onPressed:
|
||||
() => _showBranchDialog(company),
|
||||
variant:
|
||||
ShadcnButtonVariant.ghost,
|
||||
size: ShadcnButtonSize.small,
|
||||
),
|
||||
const SizedBox(
|
||||
width: ShadcnTheme.spacing1,
|
||||
return std_table.StandardDataRow(
|
||||
index: index,
|
||||
columns: [
|
||||
std_table.DataColumn(label: '번호', flex: 1),
|
||||
std_table.DataColumn(label: '회사명', flex: 3),
|
||||
std_table.DataColumn(label: '구분', flex: 1),
|
||||
std_table.DataColumn(label: '유형', flex: 2),
|
||||
std_table.DataColumn(label: '연락처', flex: 2),
|
||||
std_table.DataColumn(label: '관리', flex: 2),
|
||||
],
|
||||
cells: [
|
||||
// 번호
|
||||
Text(
|
||||
'${index + 1}',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
// 회사명
|
||||
_buildCompanyNameText(
|
||||
company,
|
||||
isBranch,
|
||||
mainCompanyName: mainCompanyName,
|
||||
),
|
||||
// 구분
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _buildCompanyTypeLabel(isBranch),
|
||||
),
|
||||
// 유형
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _buildCompanyTypeChips(company.companyTypes),
|
||||
),
|
||||
// 연락처
|
||||
Text(
|
||||
company.contactPhone ?? '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
// 관리
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (!isBranch &&
|
||||
company.branches != null &&
|
||||
company.branches!.isNotEmpty) ...[
|
||||
ShadcnButton(
|
||||
text: '지점',
|
||||
onPressed:
|
||||
() => _showBranchDialog(company),
|
||||
variant: ShadcnButtonVariant.ghost,
|
||||
size: ShadcnButtonSize.small,
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
],
|
||||
std_table.StandardActionButtons(
|
||||
onEdit:
|
||||
company.id != null
|
||||
? () {
|
||||
if (isBranch) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/company/edit',
|
||||
arguments: {
|
||||
'companyId':
|
||||
companyData['companyId'],
|
||||
'isBranch': true,
|
||||
'mainCompanyName':
|
||||
mainCompanyName,
|
||||
'branchId': company.id,
|
||||
},
|
||||
).then((result) {
|
||||
if (result == true)
|
||||
controller.refresh();
|
||||
});
|
||||
} else {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/company/edit',
|
||||
arguments: {
|
||||
'companyId': company.id,
|
||||
'isBranch': false,
|
||||
},
|
||||
).then((result) {
|
||||
if (result == true)
|
||||
controller.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
: null,
|
||||
onDelete:
|
||||
(!isBranch && company.id != null)
|
||||
? () => _deleteCompany(company.id!)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
std_table.StandardActionButtons(
|
||||
onEdit: company.id != null
|
||||
? () {
|
||||
if (isBranch) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/company/edit',
|
||||
arguments: {
|
||||
'companyId': companyData['companyId'],
|
||||
'isBranch': true,
|
||||
'mainCompanyName': mainCompanyName,
|
||||
'branchId': company.id,
|
||||
},
|
||||
).then((result) {
|
||||
if (result == true) controller.refresh();
|
||||
});
|
||||
} else {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/company/edit',
|
||||
arguments: {
|
||||
'companyId': company.id,
|
||||
'isBranch': false,
|
||||
},
|
||||
).then((result) {
|
||||
if (result == true) controller.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
: null,
|
||||
onDelete: (!isBranch && company.id != null)
|
||||
? () => _deleteCompany(company.id!)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
// 페이지네이션 (항상 표시)
|
||||
pagination: Pagination(
|
||||
@@ -438,4 +482,4 @@ class _CompanyListRedesignState extends State<CompanyListRedesign> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -66,23 +66,48 @@ class CompanyListController extends ChangeNotifier {
|
||||
|
||||
try {
|
||||
if (_useApi) {
|
||||
// API 호출
|
||||
print('[CompanyListController] Using API to fetch companies');
|
||||
final apiCompanies = await _companyService.getCompanies(
|
||||
page: _currentPage,
|
||||
perPage: _perPage,
|
||||
search: searchKeyword.isNotEmpty ? searchKeyword : null,
|
||||
isActive: _isActiveFilter,
|
||||
);
|
||||
print('[CompanyListController] API returned ${apiCompanies.length} companies');
|
||||
// API 호출 - 지점 정보 포함
|
||||
print('[CompanyListController] Using API to fetch companies with branches');
|
||||
|
||||
if (isRefresh) {
|
||||
companies = apiCompanies;
|
||||
} else {
|
||||
companies.addAll(apiCompanies);
|
||||
// 지점 정보를 포함한 전체 회사 목록 가져오기
|
||||
final apiCompaniesWithBranches = await _companyService.getCompaniesWithBranchesFlat();
|
||||
print('[CompanyListController] API returned ${apiCompaniesWithBranches.length} companies with branches');
|
||||
|
||||
// 지점 수 출력
|
||||
for (final company in apiCompaniesWithBranches) {
|
||||
if (company.branches?.isNotEmpty ?? false) {
|
||||
print('[CompanyListController] ${company.name} has ${company.branches?.length ?? 0} branches');
|
||||
}
|
||||
}
|
||||
|
||||
_hasMore = apiCompanies.length == _perPage;
|
||||
// 검색어 필터 적용 (서버에서 필터링이 안 되므로 클라이언트에서 처리)
|
||||
List<Company> filteredApiCompanies = apiCompaniesWithBranches;
|
||||
if (searchKeyword.isNotEmpty) {
|
||||
final keyword = searchKeyword.toLowerCase();
|
||||
filteredApiCompanies = apiCompaniesWithBranches.where((company) {
|
||||
return company.name.toLowerCase().contains(keyword) ||
|
||||
(company.contactName?.toLowerCase().contains(keyword) ?? false) ||
|
||||
(company.contactPhone?.toLowerCase().contains(keyword) ?? false);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// 활성 상태 필터 적용 (현재 API에서 지원하지 않으므로 주석 처리)
|
||||
// if (_isActiveFilter != null) {
|
||||
// filteredApiCompanies = filteredApiCompanies.where((c) => c.isActive == _isActiveFilter).toList();
|
||||
// }
|
||||
|
||||
// 페이지네이션 처리 (클라이언트 사이드)
|
||||
final startIndex = (_currentPage - 1) * _perPage;
|
||||
final endIndex = startIndex + _perPage;
|
||||
final paginatedCompanies = filteredApiCompanies.skip(startIndex).take(_perPage).toList();
|
||||
|
||||
if (isRefresh) {
|
||||
companies = paginatedCompanies;
|
||||
} else {
|
||||
companies.addAll(paginatedCompanies);
|
||||
}
|
||||
|
||||
_hasMore = endIndex < filteredApiCompanies.length;
|
||||
if (_hasMore) _currentPage++;
|
||||
} else {
|
||||
// Mock 데이터 사용
|
||||
|
||||
Reference in New Issue
Block a user