refactor: 회사 폼 UI 개선 및 코드 정리
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

- 담당자 연락처 필드를 드롭다운 + 입력 방식으로 분리
- 사용자 폼과 동일한 전화번호 UI 패턴 적용
- 미사용 위젯 파일 4개 정리 (branch_card, contact_info_* 등)
- 파일명 통일성 확보 (branch_edit_screen → branch_form, company_form_simplified → company_form)
- 네이밍 일관성 개선으로 유지보수성 향상
This commit is contained in:
JiWoong Sul
2025-08-18 17:57:16 +09:00
parent 93bceb8a6c
commit 6d745051b5
37 changed files with 2743 additions and 2446 deletions

View File

@@ -1,141 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:superport/models/address_model.dart';
import 'package:superport/models/company_model.dart';
import 'package:superport/screens/common/custom_widgets.dart';
import 'package:superport/screens/common/theme_shadcn.dart';
import 'package:superport/screens/common/widgets/address_input.dart';
import 'package:superport/screens/company/widgets/contact_info_widget.dart';
import 'package:superport/utils/validators.dart';
import 'package:superport/utils/phone_utils.dart';
class BranchCard extends StatefulWidget {
final GlobalKey cardKey;
final int index;
final Branch branch;
final TextEditingController nameController;
final TextEditingController contactNameController;
final TextEditingController contactPositionController;
final TextEditingController contactPhoneController;
final TextEditingController contactEmailController;
final FocusNode focusNode;
final List<String> positions;
final List<String> phonePrefixes;
final String selectedPhonePrefix;
final ValueChanged<String> onNameChanged;
final ValueChanged<Address> onAddressChanged;
final ValueChanged<String> onContactNameChanged;
final ValueChanged<String> onContactPositionChanged;
final ValueChanged<String> onContactPhoneChanged;
final ValueChanged<String> onContactEmailChanged;
final ValueChanged<String> onPhonePrefixChanged;
final VoidCallback onDelete;
const BranchCard({
Key? key,
required this.cardKey,
required this.index,
required this.branch,
required this.nameController,
required this.contactNameController,
required this.contactPositionController,
required this.contactPhoneController,
required this.contactEmailController,
required this.focusNode,
required this.positions,
required this.phonePrefixes,
required this.selectedPhonePrefix,
required this.onNameChanged,
required this.onAddressChanged,
required this.onContactNameChanged,
required this.onContactPositionChanged,
required this.onContactPhoneChanged,
required this.onContactEmailChanged,
required this.onPhonePrefixChanged,
required this.onDelete,
}) : super(key: key);
@override
_BranchCardState createState() => _BranchCardState();
}
class _BranchCardState extends State<BranchCard> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
// 화면의 빈 공간 터치 시 포커스 해제
FocusScope.of(context).unfocus();
},
child: Card(
key: widget.cardKey,
margin: const EdgeInsets.only(bottom: 16.0),
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'지점 #${widget.index + 1}',
style: ShadcnTheme.headingH6,
),
IconButton(
icon: const Icon(Icons.delete, color: Colors.red),
onPressed: widget.onDelete,
),
],
),
const SizedBox(height: 8),
FormFieldWrapper(
label: '지점명',
isRequired: true,
child: TextFormField(
controller: widget.nameController,
focusNode: widget.focusNode,
decoration: const InputDecoration(hintText: '지점명을 입력하세요'),
onChanged: widget.onNameChanged,
validator: FormValidator.required('지점명은 필수입니다'),
),
),
AddressInput(
initialZipCode: widget.branch.address.zipCode,
initialRegion: widget.branch.address.region,
initialDetailAddress: widget.branch.address.detailAddress,
onAddressChanged: (zipCode, region, detailAddress) {
final address = Address(
zipCode: zipCode,
region: region,
detailAddress: detailAddress,
);
widget.onAddressChanged(address);
},
),
// 담당자 정보 - ContactInfoWidget 사용
ContactInfoWidget(
title: '담당자 정보',
contactNameController: widget.contactNameController,
contactPositionController: widget.contactPositionController,
contactPhoneController: widget.contactPhoneController,
contactEmailController: widget.contactEmailController,
positions: widget.positions,
selectedPhonePrefix: widget.selectedPhonePrefix,
phonePrefixes: widget.phonePrefixes,
onPhonePrefixChanged: widget.onPhonePrefixChanged,
onContactNameChanged: widget.onContactNameChanged,
onContactPositionChanged: widget.onContactPositionChanged,
onContactPhoneChanged: widget.onContactPhoneChanged,
onContactEmailChanged: widget.onContactEmailChanged,
compactMode: false, // compactMode를 false로 변경하여 한 줄로 표시
),
],
),
),
),
);
}
}

View File

@@ -1,112 +0,0 @@
import 'package:flutter/material.dart';
import '../controllers/branch_form_controller.dart';
import 'package:superport/models/address_model.dart';
import 'package:superport/screens/company/widgets/contact_info_form.dart';
import 'package:superport/screens/common/widgets/address_input.dart';
import 'package:superport/screens/common/widgets/remark_input.dart';
/// 지점 입력 폼 위젯
///
/// BranchFormController를 받아서 입력 필드, 드롭다운, 포커스, 전화번호 등 UI/상태를 관리한다.
class BranchFormWidget extends StatelessWidget {
final BranchFormController controller;
final int index;
final void Function()? onRemove;
final void Function(Address)? onAddressChanged;
const BranchFormWidget({
Key? key,
required this.controller,
required this.index,
this.onRemove,
this.onAddressChanged,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Card(
key: controller.cardKey,
margin: const EdgeInsets.symmetric(vertical: 8),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: TextFormField(
controller: controller.nameController,
focusNode: controller.focusNode,
decoration: const InputDecoration(labelText: '지점명'),
onChanged: (value) => controller.updateField('name', value),
),
),
if (onRemove != null)
IconButton(
icon: const Icon(Icons.delete, color: Colors.red),
onPressed: onRemove,
),
],
),
const SizedBox(height: 8),
// 주소 입력: 회사와 동일한 AddressInput 위젯 사용
AddressInput(
initialZipCode: controller.branch.address.zipCode,
initialRegion: controller.branch.address.region,
initialDetailAddress: controller.branch.address.detailAddress,
isRequired: false,
onAddressChanged: (zipCode, region, detailAddress) {
controller.updateAddress(
Address(
zipCode: zipCode,
region: region,
detailAddress: detailAddress,
),
);
if (onAddressChanged != null) {
onAddressChanged!(
Address(
zipCode: zipCode,
region: region,
detailAddress: detailAddress,
),
);
}
},
),
const SizedBox(height: 8),
// 담당자 정보 입력: ContactInfoForm 위젯으로 대체 (회사 담당자와 동일 UI)
ContactInfoForm(
contactNameController: controller.contactNameController,
contactPositionController: controller.contactPositionController,
contactPhoneController: controller.contactPhoneController,
contactEmailController: controller.contactEmailController,
positions: controller.positions,
selectedPhonePrefix: controller.selectedPhonePrefix,
phonePrefixes: controller.phonePrefixes,
onPhonePrefixChanged: (value) {
controller.updatePhonePrefix(value);
},
onNameSaved: (value) {
controller.updateField('contactName', value ?? '');
},
onPositionSaved: (value) {
controller.updateField('contactPosition', value ?? '');
},
onPhoneSaved: (value) {
controller.updateField('contactPhone', value ?? '');
},
onEmailSaved: (value) {
controller.updateField('contactEmail', value ?? '');
},
),
const SizedBox(height: 8),
// 비고 입력란
RemarkInput(controller: controller.remarkController),
],
),
),
);
}
}

View File

@@ -1,58 +0,0 @@
import 'package:flutter/material.dart';
import 'package:superport/screens/company/widgets/contact_info_widget.dart';
/// 담당자 정보 폼
///
/// 회사 등록 및 수정 화면에서 사용되는 담당자 정보 입력 폼
/// 내부적으로 공통 ContactInfoWidget을 사용하여 코드 재사용성 확보
class ContactInfoForm extends StatelessWidget {
final TextEditingController contactNameController;
final TextEditingController contactPositionController;
final TextEditingController contactPhoneController;
final TextEditingController contactEmailController;
final List<String> positions;
final String selectedPhonePrefix;
final List<String> phonePrefixes;
final ValueChanged<String> onPhonePrefixChanged;
final ValueChanged<String?> onNameSaved;
final ValueChanged<String?> onPositionSaved;
final ValueChanged<String?> onPhoneSaved;
final ValueChanged<String?> onEmailSaved;
const ContactInfoForm({
Key? key,
required this.contactNameController,
required this.contactPositionController,
required this.contactPhoneController,
required this.contactEmailController,
required this.positions,
required this.selectedPhonePrefix,
required this.phonePrefixes,
required this.onPhonePrefixChanged,
required this.onNameSaved,
required this.onPositionSaved,
required this.onPhoneSaved,
required this.onEmailSaved,
}) : super(key: key);
@override
Widget build(BuildContext context) {
// ContactInfoWidget을 사용하여 담당자 정보 UI 구성
return ContactInfoWidget(
contactNameController: contactNameController,
contactPositionController: contactPositionController,
contactPhoneController: contactPhoneController,
contactEmailController: contactEmailController,
positions: positions,
selectedPhonePrefix: selectedPhonePrefix,
phonePrefixes: phonePrefixes,
onPhonePrefixChanged: onPhonePrefixChanged,
// 각 콜백 함수를 ContactInfoWidget의 onChanged 콜백과 연결
onContactNameChanged: (value) => onNameSaved?.call(value),
onContactPositionChanged: (value) => onPositionSaved?.call(value),
onContactPhoneChanged: (value) => onPhoneSaved?.call(value),
onContactEmailChanged: (value) => onEmailSaved?.call(value),
);
}
}

View File

@@ -1,722 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:developer' as developer;
import 'package:superport/screens/common/custom_widgets.dart';
import 'package:superport/utils/validators.dart';
import 'package:superport/utils/phone_utils.dart';
import 'dart:math' as math;
/// 담당자 정보 위젯
///
/// 회사 및 지점의 담당자 정보를 입력받는 공통 위젯
/// SRP(단일 책임 원칙)에 따라 담당자 정보 입력 로직을 분리
class ContactInfoWidget extends StatefulWidget {
/// 위젯 제목
final String title;
/// 담당자 이름 컨트롤러
final TextEditingController contactNameController;
/// 담당자 직책 컨트롤러
final TextEditingController contactPositionController;
/// 담당자 전화번호 컨트롤러
final TextEditingController contactPhoneController;
/// 담당자 이메일 컨트롤러
final TextEditingController contactEmailController;
/// 직책 목록
final List<String> positions;
/// 선택된 전화번호 접두사
final String selectedPhonePrefix;
/// 전화번호 접두사 목록
final List<String> phonePrefixes;
/// 직책 컴팩트 모드 (Row 또는 Column 레이아웃 결정)
final bool compactMode;
/// 전화번호 접두사 변경 콜백
final ValueChanged<String> onPhonePrefixChanged;
/// 담당자 이름 변경 콜백
final ValueChanged<String> onContactNameChanged;
/// 담당자 직책 변경 콜백
final ValueChanged<String> onContactPositionChanged;
/// 담당자 전화번호 변경 콜백
final ValueChanged<String> onContactPhoneChanged;
/// 담당자 이메일 변경 콜백
final ValueChanged<String> onContactEmailChanged;
const ContactInfoWidget({
Key? key,
this.title = '담당자 정보',
required this.contactNameController,
required this.contactPositionController,
required this.contactPhoneController,
required this.contactEmailController,
required this.positions,
required this.selectedPhonePrefix,
required this.phonePrefixes,
required this.onPhonePrefixChanged,
required this.onContactNameChanged,
required this.onContactPositionChanged,
required this.onContactPhoneChanged,
required this.onContactEmailChanged,
this.compactMode = false,
}) : super(key: key);
@override
State<ContactInfoWidget> createState() => _ContactInfoWidgetState();
}
class _ContactInfoWidgetState extends State<ContactInfoWidget> {
bool _showPositionDropdown = false;
bool _showPhonePrefixDropdown = false;
final LayerLink _positionLayerLink = LayerLink();
final LayerLink _phonePrefixLayerLink = LayerLink();
OverlayEntry? _positionOverlayEntry;
OverlayEntry? _phonePrefixOverlayEntry;
final FocusNode _positionFocusNode = FocusNode();
final FocusNode _phonePrefixFocusNode = FocusNode();
@override
void initState() {
super.initState();
developer.log('ContactInfoWidget 초기화 완료', name: 'ContactInfoWidget');
_positionFocusNode.addListener(() {
if (_positionFocusNode.hasFocus) {
developer.log('직책 필드 포커스 얻음', name: 'ContactInfoWidget');
} else {
developer.log('직책 필드 포커스 잃음', name: 'ContactInfoWidget');
}
});
_phonePrefixFocusNode.addListener(() {
if (_phonePrefixFocusNode.hasFocus) {
developer.log('전화번호 접두사 필드 포커스 얻음', name: 'ContactInfoWidget');
} else {
developer.log('전화번호 접두사 필드 포커스 잃음', name: 'ContactInfoWidget');
}
});
}
@override
void dispose() {
_removeAllOverlays();
_positionFocusNode.dispose();
_phonePrefixFocusNode.dispose();
super.dispose();
}
void _togglePositionDropdown() {
developer.log(
'직책 드롭다운 토글: $_showPositionDropdown -> ${!_showPositionDropdown}',
name: 'ContactInfoWidget',
);
setState(() {
if (_showPositionDropdown) {
_removePositionOverlay();
} else {
_showPositionDropdown = true;
_showPhonePrefixDropdown = false;
_removePhonePrefixOverlay();
_showPositionOverlay();
}
});
}
void _togglePhonePrefixDropdown() {
developer.log(
'전화번호 접두사 드롭다운 토글: $_showPhonePrefixDropdown -> ${!_showPhonePrefixDropdown}',
name: 'ContactInfoWidget',
);
setState(() {
if (_showPhonePrefixDropdown) {
_removePhonePrefixOverlay();
} else {
_showPhonePrefixDropdown = true;
_showPositionDropdown = false;
_removePositionOverlay();
_showPhonePrefixOverlay();
}
});
}
void _removePositionOverlay() {
_positionOverlayEntry?.remove();
_positionOverlayEntry = null;
_showPositionDropdown = false;
}
void _removePhonePrefixOverlay() {
_phonePrefixOverlayEntry?.remove();
_phonePrefixOverlayEntry = null;
_showPhonePrefixDropdown = false;
}
void _removeAllOverlays() {
_removePositionOverlay();
_removePhonePrefixOverlay();
}
void _closeAllDropdowns() {
if (_showPositionDropdown || _showPhonePrefixDropdown) {
developer.log('모든 드롭다운 닫기', name: 'ContactInfoWidget');
setState(() {
_removeAllOverlays();
});
}
}
void _showPositionOverlay() {
final RenderBox renderBox = context.findRenderObject() as RenderBox;
final size = renderBox.size;
final offset = renderBox.localToGlobal(Offset.zero);
final availableHeight =
MediaQuery.of(context).size.height - offset.dy - 100;
final maxHeight = math.min(300.0, availableHeight);
_positionOverlayEntry = OverlayEntry(
builder:
(context) => Positioned(
width: 200,
child: CompositedTransformFollower(
link: _positionLayerLink,
showWhenUnlinked: false,
offset: const Offset(0, 45),
child: Material(
elevation: 4,
borderRadius: BorderRadius.circular(4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
),
],
),
constraints: BoxConstraints(maxHeight: maxHeight),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
...widget.positions.map(
(position) => InkWell(
onTap: () {
developer.log(
'직책 선택됨: $position',
name: 'ContactInfoWidget',
);
setState(() {
widget.contactPositionController.text =
position;
widget.onContactPositionChanged(position);
_removePositionOverlay();
});
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
width: double.infinity,
child: Text(position),
),
),
),
InkWell(
onTap: () {
developer.log(
'직책 기타(직접 입력) 선택됨',
name: 'ContactInfoWidget',
);
_removePositionOverlay();
widget.contactPositionController.clear();
widget.onContactPositionChanged('');
_positionFocusNode.requestFocus();
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
width: double.infinity,
child: const Text('기타 (직접 입력)'),
),
),
],
),
),
),
),
),
),
);
Overlay.of(context).insert(_positionOverlayEntry!);
}
void _showPhonePrefixOverlay() {
final RenderBox renderBox = context.findRenderObject() as RenderBox;
final size = renderBox.size;
final offset = renderBox.localToGlobal(Offset.zero);
final availableHeight =
MediaQuery.of(context).size.height - offset.dy - 100;
final maxHeight = math.min(300.0, availableHeight);
_phonePrefixOverlayEntry = OverlayEntry(
builder:
(context) => Positioned(
width: 200,
child: CompositedTransformFollower(
link: _phonePrefixLayerLink,
showWhenUnlinked: false,
offset: const Offset(0, 45),
child: Material(
elevation: 4,
borderRadius: BorderRadius.circular(4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
),
],
),
constraints: BoxConstraints(maxHeight: maxHeight),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
...widget.phonePrefixes.map(
(prefix) => InkWell(
onTap: () {
developer.log(
'전화번호 접두사 선택됨: $prefix',
name: 'ContactInfoWidget',
);
widget.onPhonePrefixChanged(prefix);
setState(() {
_removePhonePrefixOverlay();
});
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
width: double.infinity,
child: Text(prefix),
),
),
),
InkWell(
onTap: () {
developer.log(
'전화번호 접두사 직접 입력 선택됨',
name: 'ContactInfoWidget',
);
_removePhonePrefixOverlay();
_phonePrefixFocusNode.requestFocus();
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
width: double.infinity,
child: const Text('기타 (직접 입력)'),
),
),
],
),
),
),
),
),
),
);
Overlay.of(context).insert(_phonePrefixOverlayEntry!);
}
@override
Widget build(BuildContext context) {
developer.log(
'ContactInfoWidget 빌드 시작: 직책 드롭다운=$_showPositionDropdown, 전화번호 접두사 드롭다운=$_showPhonePrefixDropdown',
name: 'ContactInfoWidget',
);
// 컴팩트 모드에 따라 다른 레이아웃 생성
return FormFieldWrapper(
label: widget.title,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children:
widget.compactMode ? _buildCompactLayout() : _buildDefaultLayout(),
),
);
}
// 기본 레이아웃 (한 줄에 모든 필드 표시)
List<Widget> _buildDefaultLayout() {
return [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 담당자 이름
Expanded(
flex: 3,
child: TextFormField(
controller: widget.contactNameController,
decoration: const InputDecoration(
hintText: '이름',
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
),
onTap: () {
developer.log('이름 필드 터치됨', name: 'ContactInfoWidget');
_closeAllDropdowns();
},
onChanged: widget.onContactNameChanged,
),
),
const SizedBox(width: 8),
// 담당자 직책
Expanded(
flex: 2,
child: CompositedTransformTarget(
link: _positionLayerLink,
child: Stack(
children: [
TextFormField(
controller: widget.contactPositionController,
focusNode: _positionFocusNode,
decoration: InputDecoration(
hintText: '직책',
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
suffixIcon: IconButton(
icon: const Icon(Icons.arrow_drop_down, size: 20),
padding: EdgeInsets.zero,
onPressed: () {
developer.log(
'직책 드롭다운 버튼 클릭됨',
name: 'ContactInfoWidget',
);
_togglePositionDropdown();
},
),
),
onTap: () {
// 필드를 터치했을 때는 드롭다운을 열지 않고 직접 입력 모드로 진입
_closeAllDropdowns();
},
onChanged: widget.onContactPositionChanged,
),
],
),
),
),
const SizedBox(width: 8),
// 전화번호 접두사
Expanded(
flex: 2,
child: CompositedTransformTarget(
link: _phonePrefixLayerLink,
child: Stack(
children: [
TextFormField(
controller: TextEditingController(
text: widget.selectedPhonePrefix,
),
focusNode: _phonePrefixFocusNode,
decoration: InputDecoration(
hintText: '국가번호',
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
suffixIcon: IconButton(
icon: const Icon(Icons.arrow_drop_down, size: 20),
padding: EdgeInsets.zero,
onPressed: () {
developer.log(
'전화번호 접두사 드롭다운 버튼 클릭됨',
name: 'ContactInfoWidget',
);
_togglePhonePrefixDropdown();
},
),
),
onTap: () {
// 필드를 터치했을 때는 드롭다운을 열지 않고 직접 입력 모드로 진입
_closeAllDropdowns();
},
onChanged: (value) {
if (value.isNotEmpty) {
widget.onPhonePrefixChanged(value);
}
},
),
],
),
),
),
const SizedBox(width: 8),
// 담당자 전화번호
Expanded(
flex: 3,
child: TextFormField(
controller: widget.contactPhoneController,
decoration: const InputDecoration(
hintText: '전화번호',
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
),
keyboardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
// 접두사에 따른 동적 포맷팅
TextInputFormatter.withFunction((oldValue, newValue) {
final formatted = PhoneUtils.formatPhoneNumberByPrefix(
widget.selectedPhonePrefix,
newValue.text,
);
return TextEditingValue(
text: formatted,
selection: TextSelection.collapsed(offset: formatted.length),
);
}),
],
onTap: () {
developer.log('전화번호 필드 터치됨', name: 'ContactInfoWidget');
_closeAllDropdowns();
},
validator: validatePhoneNumber,
onChanged: widget.onContactPhoneChanged,
),
),
const SizedBox(width: 8),
// 담당자 이메일
Expanded(
flex: 6,
child: TextFormField(
controller: widget.contactEmailController,
decoration: const InputDecoration(
hintText: '이메일',
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
),
keyboardType: TextInputType.emailAddress,
onTap: () {
developer.log('이메일 필드 터치됨', name: 'ContactInfoWidget');
_closeAllDropdowns();
},
validator: FormValidator.email(),
onChanged: widget.onContactEmailChanged,
),
),
],
),
];
}
// 컴팩트 레이아웃 (여러 줄에 필드 표시)
List<Widget> _buildCompactLayout() {
return [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 담당자 이름
Expanded(
child: TextFormField(
controller: widget.contactNameController,
decoration: const InputDecoration(
hintText: '담당자 이름',
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
),
onTap: () {
developer.log('이름 필드 터치됨', name: 'ContactInfoWidget');
_closeAllDropdowns();
},
onChanged: widget.onContactNameChanged,
),
),
const SizedBox(width: 16),
// 담당자 직책
Expanded(
child: CompositedTransformTarget(
link: _positionLayerLink,
child: InkWell(
onTap: _togglePositionDropdown,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 15,
),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade400),
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
widget.contactPositionController.text.isEmpty
? '직책 선택'
: widget.contactPositionController.text,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color:
widget.contactPositionController.text.isEmpty
? Colors.grey.shade600
: Colors.black,
),
),
),
const Icon(Icons.arrow_drop_down),
],
),
),
),
),
),
],
),
const SizedBox(height: 16),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 전화번호 (접두사 + 번호)
Expanded(
child: Row(
children: [
// 전화번호 접두사
CompositedTransformTarget(
link: _phonePrefixLayerLink,
child: InkWell(
onTap: _togglePhonePrefixDropdown,
child: Container(
width: 70,
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 14,
),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade400),
borderRadius: const BorderRadius.horizontal(
left: Radius.circular(4),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.selectedPhonePrefix,
style: const TextStyle(fontSize: 14),
),
const Icon(Icons.arrow_drop_down, size: 18),
],
),
),
),
),
// 전화번호
Expanded(
child: TextFormField(
controller: widget.contactPhoneController,
decoration: const InputDecoration(
hintText: '전화번호',
border: OutlineInputBorder(
borderRadius: BorderRadius.horizontal(
left: Radius.zero,
right: Radius.circular(4),
),
),
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
),
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
// 접두사에 따른 동적 포맷팅
TextInputFormatter.withFunction((oldValue, newValue) {
final formatted = PhoneUtils.formatPhoneNumberByPrefix(
widget.selectedPhonePrefix,
newValue.text,
);
return TextEditingValue(
text: formatted,
selection: TextSelection.collapsed(offset: formatted.length),
);
}),
],
keyboardType: TextInputType.phone,
onTap: _closeAllDropdowns,
onChanged: widget.onContactPhoneChanged,
validator: validatePhoneNumber,
),
),
],
),
),
const SizedBox(width: 16),
// 이메일
Expanded(
child: TextFormField(
controller: widget.contactEmailController,
decoration: const InputDecoration(
hintText: '이메일 주소',
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
),
keyboardType: TextInputType.emailAddress,
onTap: _closeAllDropdowns,
onChanged: widget.onContactEmailChanged,
validator: FormValidator.email(),
),
),
],
),
];
}
}