계정 정보 다이얼로그 추가 및 전체 목록 페치 개선

This commit is contained in:
JiWoong Sul
2025-10-22 01:05:47 +09:00
parent 6b58effc83
commit f4dc83d441
44 changed files with 1636 additions and 362 deletions

View File

@@ -85,7 +85,7 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
final FocusNode _searchFocusNode = FocusNode();
final DateFormat _dateFormat = DateFormat('yyyy-MM-dd HH:mm');
String? _lastError;
bool _routeApplied = false;
String? _lastRouteSignature;
@override
void initState() {
@@ -97,9 +97,14 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (!_routeApplied) {
_routeApplied = true;
_applyRouteParameters();
_syncWithRoute(widget.routeUri);
}
@override
void didUpdateWidget(covariant _VendorEnabledPage oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.routeUri != widget.routeUri) {
_syncWithRoute(widget.routeUri);
}
}
@@ -143,7 +148,7 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
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;
@@ -244,6 +249,14 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
),
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
@@ -259,6 +272,14 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
: () => _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('마지막'),
),
],
),
],
@@ -308,8 +329,17 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
}
}
void _applyRouteParameters() {
final params = widget.routeUri.queryParameters;
void _syncWithRoute(Uri routeUri) {
final signature = routeUri.toString();
if (_lastRouteSignature == signature) {
return;
}
_lastRouteSignature = signature;
_applyRouteParameters(routeUri);
}
void _applyRouteParameters(Uri routeUri) {
final params = routeUri.queryParameters;
final query = params['q'] ?? '';
final status = _statusFromParam(params['status']);
final pageSizeParam = int.tryParse(params['page_size'] ?? '');
@@ -327,8 +357,14 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
}
void _goToPage(int page) {
final result = _controller.result;
final totalPages = result == null || result.pageSize == 0
? 1
: (result.total / result.pageSize).ceil().clamp(1, 9999) as int;
if (page < 1) {
page = 1;
} else if (page > totalPages) {
page = totalPages;
}
_updateRoute(page: page);
}
@@ -448,7 +484,10 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
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(vendorId!, input)
: await _controller.create(input);
@@ -471,7 +510,8 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
return ShadButton.ghost(
onPressed: isSaving
? null
: () => Navigator.of(context).pop(false),
: () =>
Navigator.of(context, rootNavigator: true).pop(false),
child: const Text('취소'),
);
},
@@ -613,11 +653,13 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
description: '"${vendor.vendorName}" 벤더를 삭제하시겠습니까?',
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('삭제'),
),
],
@@ -641,10 +683,15 @@ class _VendorEnabledPageState extends State<_VendorEnabledPage> {
}
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) {