168 lines
No EOL
5.3 KiB
Dart
168 lines
No EOL
5.3 KiB
Dart
// Version: 1.0.0
|
||
import 'package:flutter/material.dart';
|
||
|
||
/// 仕入先マスタ画面(Material Design 標準テンプレート)
|
||
class SupplierMasterScreen extends StatelessWidget {
|
||
const SupplierMasterScreen({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.brown.shade100,
|
||
child: Icon(Icons.shopping_bag, color: Colors.brown),
|
||
),
|
||
title: Text('サプライヤー${index + 1}'),
|
||
subtitle: Text('契約先:2025-12-31 以降'),
|
||
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: '担当者名',
|
||
),
|
||
),
|
||
const SizedBox(height: 8),
|
||
TextField(
|
||
decoration: const InputDecoration(
|
||
labelText: '取引条件',
|
||
hintText: '例:1/30 支払期限',
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
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('削除'),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
} |