전역 구조 리팩터링 및 테스트 확장
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:superport_v2/core/constants/app_sections.dart';
|
||||
import 'package:superport_v2/widgets/app_layout.dart';
|
||||
import 'package:superport_v2/widgets/components/filter_bar.dart';
|
||||
import 'package:superport_v2/widgets/components/superport_dialog.dart';
|
||||
|
||||
import '../../../../../core/config/environment.dart';
|
||||
import '../../../../../widgets/spec_page.dart';
|
||||
@@ -151,7 +152,8 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
? false
|
||||
: (result.page * result.pageSize) < result.total;
|
||||
|
||||
final showReset = _searchController.text.isNotEmpty ||
|
||||
final showReset =
|
||||
_searchController.text.isNotEmpty ||
|
||||
_controller.parentFilter != null ||
|
||||
_controller.statusFilter != menu.MenuStatusFilter.all ||
|
||||
_controller.includeDeleted;
|
||||
@@ -167,12 +169,36 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
actions: [
|
||||
ShadButton(
|
||||
leading: const Icon(LucideIcons.plus, size: 16),
|
||||
onPressed:
|
||||
_controller.isSubmitting ? null : () => _openMenuForm(context),
|
||||
onPressed: _controller.isSubmitting
|
||||
? null
|
||||
: () => _openMenuForm(context),
|
||||
child: const Text('신규 등록'),
|
||||
),
|
||||
],
|
||||
toolbar: FilterBar(
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
onPressed: _controller.isLoading ? null : _applyFilters,
|
||||
child: const Text('검색 적용'),
|
||||
),
|
||||
if (showReset)
|
||||
ShadButton.ghost(
|
||||
onPressed: _controller.isLoading
|
||||
? null
|
||||
: () {
|
||||
_searchController.clear();
|
||||
_searchFocus.requestFocus();
|
||||
_controller.updateQuery('');
|
||||
_controller.updateParentFilter(null);
|
||||
_controller.updateStatusFilter(
|
||||
menu.MenuStatusFilter.all,
|
||||
);
|
||||
_controller.updateIncludeDeleted(false);
|
||||
_controller.fetch(page: 1);
|
||||
},
|
||||
child: const Text('초기화'),
|
||||
),
|
||||
],
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 260,
|
||||
@@ -195,18 +221,13 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return Text(
|
||||
_controller.isLoadingParents
|
||||
? '상위 로딩중...'
|
||||
: '상위 전체',
|
||||
_controller.isLoadingParents ? '상위 로딩중...' : '상위 전체',
|
||||
);
|
||||
}
|
||||
final target = _controller.parents.firstWhere(
|
||||
(menuItem) => menuItem.id == value,
|
||||
orElse: () => MenuItem(
|
||||
id: value,
|
||||
menuCode: '',
|
||||
menuName: '',
|
||||
),
|
||||
orElse: () =>
|
||||
MenuItem(id: value, menuCode: '', menuName: ''),
|
||||
);
|
||||
final label = target.menuName.isEmpty
|
||||
? '상위 전체'
|
||||
@@ -220,10 +241,7 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
_controller.fetch(page: 1);
|
||||
},
|
||||
options: [
|
||||
const ShadOption<int?>(
|
||||
value: null,
|
||||
child: Text('상위 전체'),
|
||||
),
|
||||
const ShadOption<int?>(value: null, child: Text('상위 전체')),
|
||||
..._controller.parents.map(
|
||||
(menuItem) => ShadOption<int?>(
|
||||
value: menuItem.id,
|
||||
@@ -269,27 +287,6 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
const Text('삭제 포함'),
|
||||
],
|
||||
),
|
||||
ShadButton.outline(
|
||||
onPressed: _controller.isLoading ? null : _applyFilters,
|
||||
child: const Text('검색 적용'),
|
||||
),
|
||||
if (showReset)
|
||||
ShadButton.ghost(
|
||||
onPressed: _controller.isLoading
|
||||
? null
|
||||
: () {
|
||||
_searchController.clear();
|
||||
_searchFocus.requestFocus();
|
||||
_controller.updateQuery('');
|
||||
_controller.updateParentFilter(null);
|
||||
_controller.updateStatusFilter(
|
||||
menu.MenuStatusFilter.all,
|
||||
);
|
||||
_controller.updateIncludeDeleted(false);
|
||||
_controller.fetch(page: 1);
|
||||
},
|
||||
child: const Text('초기화'),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ShadCard(
|
||||
@@ -334,27 +331,22 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
: menus.isEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'조건에 맞는 메뉴가 없습니다.',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
)
|
||||
: _MenuTable(
|
||||
menus: menus,
|
||||
dateFormat: _dateFormat,
|
||||
onEdit: _controller.isSubmitting
|
||||
? null
|
||||
: (menuItem) =>
|
||||
_openMenuForm(context, menu: menuItem),
|
||||
onDelete: _controller.isSubmitting
|
||||
? null
|
||||
: _confirmDelete,
|
||||
onRestore: _controller.isSubmitting
|
||||
? null
|
||||
: _restoreMenu,
|
||||
),
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'조건에 맞는 메뉴가 없습니다.',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
)
|
||||
: _MenuTable(
|
||||
menus: menus,
|
||||
dateFormat: _dateFormat,
|
||||
onEdit: _controller.isSubmitting
|
||||
? null
|
||||
: (menuItem) => _openMenuForm(context, menu: menuItem),
|
||||
onDelete: _controller.isSubmitting ? null : _confirmDelete,
|
||||
onRestore: _controller.isSubmitting ? null : _restoreMenu,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -410,302 +402,283 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
final nameError = ValueNotifier<String?>(null);
|
||||
final orderError = ValueNotifier<String?>(null);
|
||||
|
||||
await showDialog<bool>(
|
||||
await SuperportDialog.show<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
final theme = ShadTheme.of(dialogContext);
|
||||
final materialTheme = Theme.of(dialogContext);
|
||||
final navigator = Navigator.of(dialogContext);
|
||||
return Dialog(
|
||||
insetPadding: const EdgeInsets.all(24),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: ShadCard(
|
||||
title: Text(
|
||||
isEdit ? '메뉴 수정' : '메뉴 등록',
|
||||
style: theme.textTheme.h3,
|
||||
),
|
||||
description: Text(
|
||||
'메뉴 정보를 ${isEdit ? '수정' : '입력'}하세요.',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
footer: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (_, isSaving, __) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: isSaving ? null : () => navigator.pop(false),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ShadButton(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () async {
|
||||
final code = codeController.text.trim();
|
||||
final name = nameController.text.trim();
|
||||
final path = pathController.text.trim();
|
||||
final orderText = orderController.text.trim();
|
||||
final note = noteController.text.trim();
|
||||
dialog: SuperportDialog(
|
||||
title: isEdit ? '메뉴 수정' : '메뉴 등록',
|
||||
description: '메뉴 정보를 ${isEdit ? '수정' : '입력'}하세요.',
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
secondaryAction: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
return ShadButton.ghost(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('취소'),
|
||||
);
|
||||
},
|
||||
),
|
||||
primaryAction: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
return ShadButton(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () async {
|
||||
final code = codeController.text.trim();
|
||||
final name = nameController.text.trim();
|
||||
final path = pathController.text.trim();
|
||||
final orderText = orderController.text.trim();
|
||||
final note = noteController.text.trim();
|
||||
|
||||
codeError.value = code.isEmpty
|
||||
? '메뉴코드를 입력하세요.'
|
||||
: null;
|
||||
nameError.value = name.isEmpty
|
||||
? '메뉴명을 입력하세요.'
|
||||
: null;
|
||||
codeError.value = code.isEmpty ? '메뉴코드를 입력하세요.' : null;
|
||||
nameError.value = name.isEmpty ? '메뉴명을 입력하세요.' : null;
|
||||
|
||||
int? orderValue;
|
||||
if (orderText.isNotEmpty) {
|
||||
orderValue = int.tryParse(orderText);
|
||||
if (orderValue == null) {
|
||||
orderError.value = '표시순서는 숫자여야 합니다.';
|
||||
} else {
|
||||
orderError.value = null;
|
||||
}
|
||||
} else {
|
||||
orderError.value = null;
|
||||
}
|
||||
int? orderValue;
|
||||
if (orderText.isNotEmpty) {
|
||||
orderValue = int.tryParse(orderText);
|
||||
orderError.value = orderValue == null
|
||||
? '표시순서는 숫자여야 합니다.'
|
||||
: null;
|
||||
} else {
|
||||
orderError.value = null;
|
||||
}
|
||||
|
||||
if (codeError.value != null ||
|
||||
nameError.value != null ||
|
||||
orderError.value != null) {
|
||||
return;
|
||||
}
|
||||
if (codeError.value != null ||
|
||||
nameError.value != null ||
|
||||
orderError.value != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
saving.value = true;
|
||||
final input = MenuInput(
|
||||
menuCode: code,
|
||||
menuName: name,
|
||||
parentMenuId: parentNotifier.value,
|
||||
path: path.isEmpty ? null : path,
|
||||
displayOrder: orderValue,
|
||||
isActive: isActiveNotifier.value,
|
||||
note: note.isEmpty ? null : note,
|
||||
);
|
||||
final response = isEdit
|
||||
? await _controller.update(menuId!, input)
|
||||
: await _controller.create(input);
|
||||
saving.value = false;
|
||||
if (response != null) {
|
||||
if (!navigator.mounted) {
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
_showSnack(
|
||||
isEdit ? '메뉴를 수정했습니다.' : '메뉴를 등록했습니다.',
|
||||
);
|
||||
}
|
||||
navigator.pop(true);
|
||||
saving.value = true;
|
||||
final input = MenuInput(
|
||||
menuCode: code,
|
||||
menuName: name,
|
||||
parentMenuId: parentNotifier.value,
|
||||
path: path.isEmpty ? null : path,
|
||||
displayOrder: orderValue,
|
||||
isActive: isActiveNotifier.value,
|
||||
note: note.isEmpty ? null : note,
|
||||
);
|
||||
final navigator = Navigator.of(dialogContext);
|
||||
final response = isEdit
|
||||
? await _controller.update(menuId!, input)
|
||||
: await _controller.create(input);
|
||||
saving.value = false;
|
||||
if (response != null) {
|
||||
if (!navigator.mounted) {
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
_showSnack(isEdit ? '메뉴를 수정했습니다.' : '메뉴를 등록했습니다.');
|
||||
}
|
||||
navigator.pop(true);
|
||||
}
|
||||
},
|
||||
child: Text(isEdit ? '저장' : '등록'),
|
||||
);
|
||||
},
|
||||
),
|
||||
child: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
final theme = ShadTheme.of(dialogContext);
|
||||
final materialTheme = Theme.of(dialogContext);
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: codeError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '메뉴코드',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: codeController,
|
||||
readOnly: isEdit,
|
||||
onChanged: (_) {
|
||||
if (codeController.text.trim().isNotEmpty) {
|
||||
codeError.value = null;
|
||||
}
|
||||
},
|
||||
child: Text(isEdit ? '저장' : '등록'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: codeError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '메뉴코드',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: codeController,
|
||||
readOnly: isEdit,
|
||||
onChanged: (_) {
|
||||
if (codeController.text.trim().isNotEmpty) {
|
||||
codeError.value = null;
|
||||
}
|
||||
},
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: nameError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '메뉴명',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: nameController,
|
||||
onChanged: (_) {
|
||||
if (nameController.text.trim().isNotEmpty) {
|
||||
nameError.value = null;
|
||||
}
|
||||
},
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<int?>(
|
||||
valueListenable: parentNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '상위메뉴',
|
||||
child: ShadSelect<int?>(
|
||||
initialValue: value,
|
||||
placeholder: const Text('최상위'),
|
||||
selectedOptionBuilder: (context, selected) {
|
||||
if (selected == null) {
|
||||
return const Text('최상위');
|
||||
}
|
||||
final target = _controller.parents.firstWhere(
|
||||
(item) => item.id == selected,
|
||||
orElse: () => MenuItem(
|
||||
id: selected,
|
||||
menuCode: '',
|
||||
menuName: '',
|
||||
),
|
||||
);
|
||||
final label = target.menuName.isEmpty
|
||||
? '최상위'
|
||||
: target.menuName;
|
||||
return Text(label);
|
||||
},
|
||||
onChanged: saving.value
|
||||
? null
|
||||
: (next) => parentNotifier.value = next,
|
||||
options: [
|
||||
const ShadOption<int?>(
|
||||
value: null,
|
||||
child: Text('최상위'),
|
||||
),
|
||||
..._controller.parents
|
||||
.where((item) => item.id != menuId)
|
||||
.map(
|
||||
(menuItem) => ShadOption<int?>(
|
||||
value: menuItem.id,
|
||||
child: Text(menuItem.menuName),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '경로',
|
||||
child: ShadInput(controller: pathController),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: orderError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '표시순서',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: orderController,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: isActiveNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '사용여부',
|
||||
child: Row(
|
||||
children: [
|
||||
ShadSwitch(
|
||||
value: value,
|
||||
onChanged: saving.value
|
||||
? null
|
||||
: (next) => isActiveNotifier.value = next,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(value ? '사용' : '미사용'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '비고',
|
||||
child: ShadTextarea(controller: noteController),
|
||||
),
|
||||
if (isEdit) ...[
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'생성일시: ${_formatDateTime(existingMenu.createdAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'수정일시: ${_formatDateTime(existingMenu.updatedAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: nameError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '메뉴명',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: nameController,
|
||||
onChanged: (_) {
|
||||
if (nameController.text.trim().isNotEmpty) {
|
||||
nameError.value = null;
|
||||
}
|
||||
},
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<int?>(
|
||||
valueListenable: parentNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '상위메뉴',
|
||||
child: ShadSelect<int?>(
|
||||
initialValue: value,
|
||||
placeholder: const Text('최상위'),
|
||||
selectedOptionBuilder: (context, selected) {
|
||||
if (selected == null) {
|
||||
return const Text('최상위');
|
||||
}
|
||||
final target = _controller.parents.firstWhere(
|
||||
(item) => item.id == selected,
|
||||
orElse: () => MenuItem(
|
||||
id: selected,
|
||||
menuCode: '',
|
||||
menuName: '',
|
||||
),
|
||||
);
|
||||
final label = target.menuName.isEmpty
|
||||
? '최상위'
|
||||
: target.menuName;
|
||||
return Text(label);
|
||||
},
|
||||
onChanged: isSaving
|
||||
? null
|
||||
: (next) => parentNotifier.value = next,
|
||||
options: [
|
||||
const ShadOption<int?>(
|
||||
value: null,
|
||||
child: Text('최상위'),
|
||||
),
|
||||
..._controller.parents
|
||||
.where((item) => item.id != menuId)
|
||||
.map(
|
||||
(menuItem) => ShadOption<int?>(
|
||||
value: menuItem.id,
|
||||
child: Text(menuItem.menuName),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '경로',
|
||||
child: ShadInput(controller: pathController),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: orderError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '표시순서',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: orderController,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: isActiveNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '사용여부',
|
||||
child: Row(
|
||||
children: [
|
||||
ShadSwitch(
|
||||
value: value,
|
||||
onChanged: isSaving
|
||||
? null
|
||||
: (next) => isActiveNotifier.value = next,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(value ? '사용' : '미사용'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '비고',
|
||||
child: ShadTextarea(controller: noteController),
|
||||
),
|
||||
if (existingMenu != null) ...[
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'생성일시: ${_formatDateTime(existingMenu.createdAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'수정일시: ${_formatDateTime(existingMenu.updatedAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
codeController.dispose();
|
||||
@@ -722,24 +695,28 @@ class _MenuEnabledPageState extends State<_MenuEnabledPage> {
|
||||
}
|
||||
|
||||
Future<void> _confirmDelete(MenuItem menu) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
final confirmed = await SuperportDialog.show<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
title: const Text('메뉴 삭제'),
|
||||
content: Text('"${menu.menuName}" 메뉴를 삭제하시겠습니까?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
dialog: SuperportDialog(
|
||||
title: '메뉴 삭제',
|
||||
description: '"${menu.menuName}" 메뉴를 삭제하시겠습니까?',
|
||||
secondaryAction: Builder(
|
||||
builder: (dialogContext) {
|
||||
return ShadButton.ghost(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
TextButton(
|
||||
);
|
||||
},
|
||||
),
|
||||
primaryAction: Builder(
|
||||
builder: (dialogContext) {
|
||||
return ShadButton.destructive(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed == true && menu.id != null) {
|
||||
|
||||
Reference in New Issue
Block a user