Files
superport/lib/screens/common/templates/form_layout_template.dart
JiWoong Sul 655d473413
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled
web: migrate health notifications to js_interop; add browser hook
- Replace dart:js with package:js in health_check_service_web.dart\n- Implement showHealthCheckNotification in web/index.html\n- Pin js dependency to ^0.6.7 for flutter_secure_storage_web compatibility

auth: harden AuthInterceptor + tests

- Allow overrideAuthRepository injection for testing\n- Normalize imports to package: paths\n- Add unit test covering token attach, 401→refresh→retry, and failure path\n- Add integration test skeleton gated by env vars

ui/data: map User.companyName to list column

- Add companyName to domain User\n- Map UserDto.company?.name\n- Render companyName in user_list

cleanup: remove legacy equipment table + unused code; minor warnings

- Remove _buildFlexibleTable and unused helpers\n- Remove unused zipcode details and cache retry constant\n- Fix null-aware and non-null assertions\n- Address child-last warnings in administrator dialog

docs: update AGENTS.md session context
2025-09-08 17:39:00 +09:00

245 lines
7.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:superport/screens/common/components/shadcn_components.dart';
import 'package:superport/screens/common/theme_shadcn.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({
super.key,
required this.title,
required this.child,
this.onSave,
this.onCancel,
this.saveButtonText = '저장',
this.isLoading = false,
this.showBottomButtons = true,
this.customActions,
});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ShadcnTheme.background, // Phase 10: 통일된 배경색
appBar: AppBar(
title: Text(
title,
style: ShadcnTheme.headingH3.copyWith( // Phase 10: 표준 헤딩 스타일
fontWeight: FontWeight.w600,
color: ShadcnTheme.foreground,
),
),
backgroundColor: ShadcnTheme.card, // Phase 10: 카드 배경색
elevation: 0,
leading: IconButton(
icon: Icon(
Icons.arrow_back_ios,
color: ShadcnTheme.mutedForeground, // Phase 10: 뮤트된 전경색
size: 20,
),
onPressed: onCancel ?? () => Navigator.of(context).pop(),
),
actions: customActions != null ? [customActions!] : null,
bottom: PreferredSize(
preferredSize: Size.fromHeight(1),
child: Container(
color: ShadcnTheme.border, // Phase 10: 통일된 테두리 색상
height: 1,
),
),
),
body: child,
bottomNavigationBar: showBottomButtons ? _buildBottomBar(context) : null,
);
}
Widget _buildBottomBar(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: ShadcnTheme.card, // Phase 10: 카드 배경색
border: Border(
top: BorderSide(color: ShadcnTheme.border, width: 1), // Phase 10: 통일된 테두리
),
boxShadow: [
BoxShadow(
color: ShadcnTheme.foreground.withValues(alpha: 0.05), // Phase 10: 그림자 색상
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({
super.key,
this.title,
this.subtitle,
required this.children,
this.padding,
});
@override
Widget build(BuildContext context) {
return ShadcnCard(
padding: padding ?? EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null) ...[
Text(
title!,
style: ShadcnTheme.bodyLarge.copyWith( // Phase 10: 표준 바디 라지
fontWeight: FontWeight.w600,
color: ShadcnTheme.foreground, // Phase 10: 전경색
),
),
if (subtitle != null) ...[
SizedBox(height: 4),
Text(
subtitle!,
style: ShadcnTheme.bodyMedium.copyWith( // Phase 10: 표준 바디 미디엄
color: ShadcnTheme.mutedForeground, // Phase 10: 뮤트된 전경색
),
),
],
SizedBox(height: 20),
Divider(color: ShadcnTheme.border, height: 1), // Phase 10: 테두리 색상
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;
}
}),
],
),
);
}
}
/// 일관된 폼 필드 스타일
class FormFieldWrapper extends StatelessWidget {
final String label;
final String? hint;
final bool required;
final Widget child;
const FormFieldWrapper({
super.key,
required this.label,
this.hint,
this.required = false,
required this.child,
});
@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);
}