// Version: 1.0.0 import 'package:flutter/material.dart'; /// 担当者マスタ画面(Material Design 標準テンプレート) class EmployeeMasterScreen extends StatelessWidget { const EmployeeMasterScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('担当者マスタ'), actions: [ IconButton( icon: const Icon(Icons.add), onPressed: () => _showAddDialog(context), ), ], ), body: ListView( padding: const EdgeInsets.all(8), children: [ // ヘッダー const Padding( padding: EdgeInsets.all(8.0), child: Text( '担当者名', style: TextStyle(fontWeight: FontWeight.bold), ), ), // カードリスト形式(標準 Material 部品) ListView.builder( shrinkWrap: true, padding: EdgeInsets.zero, itemCount: 5, // デモ用データ数 itemBuilder: (context, index) { return Card( margin: const EdgeInsets.symmetric(vertical: 4), child: ListTile( leading: CircleAvatar( backgroundColor: Colors.purple.shade100, child: Icon(Icons.person_add, color: Colors.purple), ), title: Text('担当者${index + 1}'), subtitle: Text('部署:営業/総務/経理/技術/管理'), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ IconButton( icon: const Icon(Icons.edit), onPressed: () => _showEditDialog(context, index), ), IconButton( icon: const Icon(Icons.delete), onPressed: () => _showDeleteDialog(context, index), ), ], ), ), ); }, ), ], ), ); } void _showAddDialog(BuildContext context) { showDialog( context: context, builder: (ctx) => AlertDialog( title: const Text('新規担当者登録'), content: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, children: [ TextField( decoration: const InputDecoration( labelText: '氏名', hintText: '花名 山田太郎', ), ), const SizedBox(height: 8), TextField( decoration: const InputDecoration( labelText: '部署', hintText: '営業/総務/経理/技術/管理', ), ), const SizedBox(height: 8), TextField( decoration: const InputDecoration( labelText: 'メールアドレス', hintText: 'example@company.com', ), keyboardType: TextInputType.emailAddress, ), const SizedBox(height: 8), TextField( decoration: const InputDecoration( labelText: '電話番号', hintText: '0123-456789', ), keyboardType: TextInputType.phone, ), const SizedBox(height: 8), DropdownButtonFormField( value: '営業', decoration: const InputDecoration(labelText: '担当エリア'), onChanged: (value) {}, items: [ DropdownMenuItem(value: '全店', child: Text('全店')), DropdownMenuItem(value: '北海道', child: Text('北海道')), DropdownMenuItem(value: '東北', child: Text('東北')), DropdownMenuItem(value: '関東', child: Text('関東')), DropdownMenuItem(value: '中部', child: Text('中部')), ], ), ], ), ), actions: [ TextButton( onPressed: () => Navigator.pop(ctx), child: const Text('キャンセル'), ), ElevatedButton( onPressed: () { Navigator.pop(ctx); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('担当者登録しました')), ); }, child: const Text('保存'), ), ], ), ); } void _showEditDialog(BuildContext context, int index) { // 編集ダイアログ(構造は新規と同様) } void _showDeleteDialog(BuildContext context, int index) { showDialog( context: context, builder: (ctx) => AlertDialog( title: const Text('担当者削除'), content: Text('担当者${index + 1}を削除しますか?'), actions: [ TextButton( onPressed: () => Navigator.pop(ctx), child: const Text('キャンセル'), ), ElevatedButton( onPressed: () { Navigator.pop(ctx); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('担当者削除しました')), ); }, style: ElevatedButton.styleFrom(backgroundColor: Colors.red), child: const Text('削除'), ), ], ), ); } }