156 lines
No EOL
4.9 KiB
Dart
156 lines
No EOL
4.9 KiB
Dart
// Version: 1.0.0
|
||
import 'package:flutter/material.dart';
|
||
|
||
/// 倉庫マスタ画面(Material Design 標準テンプレート)
|
||
class WarehouseMasterScreen extends StatelessWidget {
|
||
const WarehouseMasterScreen({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.orange.shade100,
|
||
child: Icon(Icons.storage, color: Colors.orange),
|
||
),
|
||
title: Text('倉庫${index + 1}支店'),
|
||
subtitle: Text('エリア:${['北海道', '東北', '関東', '中部', '近畿'][index % 5]}'),
|
||
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: '〒000-0000 北海道...',
|
||
),
|
||
),
|
||
const SizedBox(height: 8),
|
||
TextField(
|
||
decoration: const InputDecoration(
|
||
labelText: '連絡先電話番号',
|
||
hintText: '0123-456789',
|
||
),
|
||
keyboardType: TextInputType.phone,
|
||
),
|
||
],
|
||
),
|
||
),
|
||
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('削除'),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
} |