161 lines
No EOL
5 KiB
Dart
161 lines
No EOL
5 KiB
Dart
// Version: 1.0.0
|
||
import 'package:flutter/material.dart';
|
||
|
||
/// 得意先マスタ画面(Material Design 標準テンプレート)
|
||
class CustomerMasterScreen extends StatelessWidget {
|
||
const CustomerMasterScreen({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.teal.shade100,
|
||
child: Icon(Icons.person, color: Colors.teal),
|
||
),
|
||
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: '代表者名',
|
||
),
|
||
),
|
||
const SizedBox(height: 8),
|
||
TextField(
|
||
decoration: const InputDecoration(
|
||
labelText: '住所',
|
||
hintText: '〒000-0000 北海道...',
|
||
),
|
||
),
|
||
const SizedBox(height: 8),
|
||
TextField(
|
||
decoration: const InputDecoration(
|
||
labelText: '電話番号',
|
||
hintText: '0123-456789',
|
||
),
|
||
keyboardType: TextInputType.phone,
|
||
),
|
||
const SizedBox(height: 8),
|
||
TextField(
|
||
decoration: const InputDecoration(
|
||
labelText: '担当者名',
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
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('削除'),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
} |