계정 정보 다이얼로그 추가 및 전체 목록 페치 개선
This commit is contained in:
@@ -125,9 +125,10 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
final error = _controller.errorMessage;
|
||||
if (error != null && error != _lastError && mounted) {
|
||||
_lastError = error;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(error)));
|
||||
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||
if (messenger != null) {
|
||||
messenger.showSnackBar(SnackBar(content: Text(error)));
|
||||
}
|
||||
_controller.clearError();
|
||||
}
|
||||
}
|
||||
@@ -174,7 +175,7 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
final currentPage = result?.page ?? 1;
|
||||
final totalPages = result == null || result.pageSize == 0
|
||||
? 1
|
||||
: (result.total / result.pageSize).ceil().clamp(1, 9999);
|
||||
: (result.total / result.pageSize).ceil().clamp(1, 9999) as int;
|
||||
final hasNext = result == null
|
||||
? false
|
||||
: (result.page * result.pageSize) < result.total;
|
||||
@@ -301,6 +302,14 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: _controller.isLoading || currentPage <= 1
|
||||
? null
|
||||
: () => _goToPage(1),
|
||||
child: const Text('처음'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: _controller.isLoading || currentPage <= 1
|
||||
@@ -316,6 +325,15 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
: () => _goToPage(currentPage + 1),
|
||||
child: const Text('다음'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed:
|
||||
_controller.isLoading || currentPage >= totalPages
|
||||
? null
|
||||
: () => _goToPage(totalPages),
|
||||
child: const Text('마지막'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -357,8 +375,18 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
}
|
||||
|
||||
void _goToPage(int page) {
|
||||
final result = _controller.result;
|
||||
final int totalPages;
|
||||
if (result == null || result.pageSize == 0) {
|
||||
totalPages = 1;
|
||||
} else {
|
||||
final calculated = (result.total / result.pageSize).ceil();
|
||||
totalPages = calculated < 1 ? 1 : calculated;
|
||||
}
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
} else if (page > totalPages) {
|
||||
page = totalPages;
|
||||
}
|
||||
_updateRoute(page: page);
|
||||
}
|
||||
@@ -647,7 +675,10 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
isActive: isActiveNotifier.value,
|
||||
note: note.isEmpty ? null : note,
|
||||
);
|
||||
final navigator = Navigator.of(context);
|
||||
final navigator = Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
);
|
||||
final response = isEdit
|
||||
? await _controller.update(customerId!, input)
|
||||
: await _controller.create(input);
|
||||
@@ -672,7 +703,8 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
return ShadButton.ghost(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () => Navigator.of(context).pop(false),
|
||||
: () =>
|
||||
Navigator.of(context, rootNavigator: true).pop(false),
|
||||
child: const Text('취소'),
|
||||
);
|
||||
},
|
||||
@@ -984,11 +1016,13 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
description: '"${customer.customerName}" 고객사를 삭제하시겠습니까?',
|
||||
actions: [
|
||||
ShadButton.ghost(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: true).pop(false),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
ShadButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: true).pop(true),
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
@@ -1012,10 +1046,14 @@ class _CustomerEnabledPageState extends State<_CustomerEnabledPage> {
|
||||
}
|
||||
|
||||
void _showSnack(String message) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(message)));
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||
if (messenger == null) {
|
||||
return;
|
||||
}
|
||||
messenger.showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
|
||||
String _formatDateTime(DateTime? value) {
|
||||
|
||||
Reference in New Issue
Block a user