chore: 프로젝트 정리 및 문서 업데이트
- 창고 위치 폼 UI 개선 - 테스트 리포트 업데이트 - API 이슈 문서 추가 - 폼 레이아웃 템플릿 추가 - main.dart 정리 - 상수 업데이트 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
243
lib/screens/common/templates/form_layout_template.dart
Normal file
243
lib/screens/common/templates/form_layout_template.dart
Normal file
@@ -0,0 +1,243 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/components/shadcn_components.dart';
|
||||
|
||||
/// 폼 화면의 일관된 레이아웃을 제공하는 템플릿 위젯
|
||||
class FormLayoutTemplate extends StatelessWidget {
|
||||
final String title;
|
||||
final Widget child;
|
||||
final VoidCallback? onSave;
|
||||
final VoidCallback? onCancel;
|
||||
final String saveButtonText;
|
||||
final bool isLoading;
|
||||
final bool showBottomButtons;
|
||||
final Widget? customActions;
|
||||
|
||||
const FormLayoutTemplate({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.child,
|
||||
this.onSave,
|
||||
this.onCancel,
|
||||
this.saveButtonText = '저장',
|
||||
this.isLoading = false,
|
||||
this.showBottomButtons = true,
|
||||
this.customActions,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xFFF5F7FA),
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1F36),
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back_ios, color: Color(0xFF6B7280), size: 20),
|
||||
onPressed: onCancel ?? () => Navigator.of(context).pop(),
|
||||
),
|
||||
actions: customActions != null ? [customActions!] : null,
|
||||
bottom: PreferredSize(
|
||||
preferredSize: Size.fromHeight(1),
|
||||
child: Container(
|
||||
color: Color(0xFFE5E7EB),
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: child,
|
||||
bottomNavigationBar: showBottomButtons ? _buildBottomBar(context) : null,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomBar(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
top: BorderSide(color: Color(0xFFE5E7EB), width: 1),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
offset: Offset(0, -2),
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.fromLTRB(24, 16, 24, 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShadcnButton(
|
||||
text: '취소',
|
||||
onPressed: isLoading ? null : (onCancel ?? () => Navigator.of(context).pop()),
|
||||
variant: ShadcnButtonVariant.secondary,
|
||||
size: ShadcnButtonSize.large,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: ShadcnButton(
|
||||
text: saveButtonText,
|
||||
onPressed: isLoading ? null : onSave,
|
||||
variant: ShadcnButtonVariant.primary,
|
||||
size: ShadcnButtonSize.large,
|
||||
loading: isLoading,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 폼 필드를 감싸는 일관된 카드 레이아웃
|
||||
class FormSection extends StatelessWidget {
|
||||
final String? title;
|
||||
final String? subtitle;
|
||||
final List<Widget> children;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
const FormSection({
|
||||
Key? key,
|
||||
this.title,
|
||||
this.subtitle,
|
||||
required this.children,
|
||||
this.padding,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ShadcnCard(
|
||||
padding: padding ?? EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title != null) ...[
|
||||
Text(
|
||||
title!,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1F36),
|
||||
),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF6B7280),
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 20),
|
||||
Divider(color: Color(0xFFE5E7EB), height: 1),
|
||||
SizedBox(height: 20),
|
||||
],
|
||||
if (children.isNotEmpty)
|
||||
...children.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final child = entry.value;
|
||||
if (index < children.length - 1) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 16),
|
||||
child: child,
|
||||
);
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 일관된 폼 필드 스타일
|
||||
class FormFieldWrapper extends StatelessWidget {
|
||||
final String label;
|
||||
final String? hint;
|
||||
final bool required;
|
||||
final Widget child;
|
||||
|
||||
const FormFieldWrapper({
|
||||
Key? key,
|
||||
required this.label,
|
||||
this.hint,
|
||||
this.required = false,
|
||||
required this.child,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF374151),
|
||||
),
|
||||
),
|
||||
if (required)
|
||||
Text(
|
||||
' *',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFFEF4444),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (hint != null) ...[
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
hint!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF6B7280),
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 8),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// UI 상수 정의
|
||||
class UIConstants {
|
||||
static const double formPadding = 24.0;
|
||||
static const double buttonHeight = 48.0;
|
||||
static const double borderRadius = 8.0;
|
||||
static const double cardSpacing = 16.0;
|
||||
|
||||
// 테이블 컬럼 너비
|
||||
static const double columnWidthSmall = 100.0; // 구분, 유형
|
||||
static const double columnWidthMedium = 150.0; // 일반 필드
|
||||
static const double columnWidthLarge = 200.0; // 긴 텍스트
|
||||
|
||||
// 색상
|
||||
static const Color backgroundColor = Color(0xFFF5F7FA);
|
||||
static const Color cardBackground = Colors.white;
|
||||
static const Color borderColor = Color(0xFFE5E7EB);
|
||||
static const Color textPrimary = Color(0xFF1A1F36);
|
||||
static const Color textSecondary = Color(0xFF6B7280);
|
||||
static const Color textMuted = Color(0xFF9CA3AF);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:superport/models/address_model.dart';
|
||||
import 'package:superport/screens/common/widgets/address_input.dart';
|
||||
import 'package:superport/screens/common/widgets/remark_input.dart';
|
||||
import 'package:superport/screens/common/theme_tailwind.dart';
|
||||
import 'package:superport/screens/common/templates/form_layout_template.dart';
|
||||
import 'controllers/warehouse_location_form_controller.dart';
|
||||
|
||||
/// 입고지 추가/수정 폼 화면 (SRP 적용, 상태/로직 분리)
|
||||
@@ -37,30 +38,61 @@ class _WarehouseLocationFormScreenState
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// 저장 메소드
|
||||
Future<void> _onSave() async {
|
||||
setState(() {}); // 저장 중 상태 갱신
|
||||
final success = await _controller.save();
|
||||
setState(() {}); // 저장 완료 후 상태 갱신
|
||||
|
||||
if (success) {
|
||||
// 성공 메시지 표시
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(_controller.isEditMode ? '입고지가 수정되었습니다' : '입고지가 추가되었습니다'),
|
||||
backgroundColor: AppThemeTailwind.success,
|
||||
),
|
||||
);
|
||||
// 리스트 화면으로 돌아가기
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
} else {
|
||||
// 실패 메시지 표시
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(_controller.error ?? '저장에 실패했습니다'),
|
||||
backgroundColor: AppThemeTailwind.danger,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_controller.isEditMode ? '입고지 수정' : '입고지 추가'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Form(
|
||||
key: _controller.formKey,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 입고지명 입력
|
||||
TextFormField(
|
||||
return FormLayoutTemplate(
|
||||
title: _controller.isEditMode ? '입고지 수정' : '입고지 추가',
|
||||
onSave: _controller.isSaving ? null : _onSave,
|
||||
saveButtonText: '저장',
|
||||
isLoading: _controller.isSaving,
|
||||
child: Form(
|
||||
key: _controller.formKey,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(UIConstants.formPadding),
|
||||
child: FormSection(
|
||||
title: '입고지 정보',
|
||||
subtitle: '입고지의 기본 정보를 입력하세요',
|
||||
children: [
|
||||
// 입고지명 입력
|
||||
FormFieldWrapper(
|
||||
label: '입고지명',
|
||||
required: true,
|
||||
child: TextFormField(
|
||||
controller: _controller.nameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '입고지명',
|
||||
hintText: '입고지명을 입력하세요',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
@@ -69,9 +101,12 @@ class _WarehouseLocationFormScreenState
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// 주소 입력 (공통 위젯)
|
||||
AddressInput(
|
||||
),
|
||||
// 주소 입력 (공통 위젯)
|
||||
FormFieldWrapper(
|
||||
label: '주소',
|
||||
required: true,
|
||||
child: AddressInput(
|
||||
initialZipCode: _controller.address.zipCode,
|
||||
initialRegion: _controller.address.region,
|
||||
initialDetailAddress: _controller.address.detailAddress,
|
||||
@@ -88,74 +123,13 @@ class _WarehouseLocationFormScreenState
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// 비고 입력
|
||||
RemarkInput(controller: _controller.remarkController),
|
||||
const SizedBox(height: 80), // 하단 버튼 여백 확보
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 24),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed:
|
||||
_controller.isSaving
|
||||
? null
|
||||
: () async {
|
||||
setState(() {}); // 저장 중 상태 갱신
|
||||
final success = await _controller.save();
|
||||
setState(() {}); // 저장 완료 후 상태 갱신
|
||||
|
||||
if (success) {
|
||||
// 성공 메시지 표시
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(_controller.isEditMode ? '입고지가 수정되었습니다' : '입고지가 추가되었습니다'),
|
||||
backgroundColor: AppThemeTailwind.success,
|
||||
),
|
||||
);
|
||||
// 리스트 화면으로 돌아가기
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
} else {
|
||||
// 실패 메시지 표시
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(_controller.error ?? '저장에 실패했습니다'),
|
||||
backgroundColor: AppThemeTailwind.danger,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppThemeTailwind.primary,
|
||||
minimumSize: const Size.fromHeight(48),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child:
|
||||
_controller.isSaving
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Text(
|
||||
'저장',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
// 비고 입력
|
||||
FormFieldWrapper(
|
||||
label: '비고',
|
||||
child: RemarkInput(controller: _controller.remarkController),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user