// Version: 3.0 - シンプル仕入先マスタ画面(簡素版、サンプルデータ固定) import 'package:flutter/material.dart'; class SupplierMasterScreen extends StatefulWidget { const SupplierMasterScreen({super.key}); @override State createState() => _SupplierMasterScreenState(); } class _SupplierMasterScreenState extends State { List _suppliers = []; @override void initState() { super.initState(); // サンプルデータ(簡素版) _suppliers = [ {'supplier_code': 'S001', 'name': 'サンプル仕入先 A'}, {'supplier_code': 'S002', 'name': 'サンプル仕入先 B'}, ]; } Future _addSupplier() async { showDialog>( context: context, builder: (ctx) => AlertDialog( title: const Text('新規仕入先登録'), content: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ TextField(decoration: const InputDecoration(labelText: 'コード', hintText: 'S003')), SizedBox(height: 8), TextField(decoration: const InputDecoration(labelText: '名称', hintText: '新仕入先名')), SizedBox(height: 8), TextField(decoration: const InputDecoration(labelText: '住所', hintText: '住所を入力')), SizedBox(height: 8), TextField(decoration: const InputDecoration(labelText: '電話番号', hintText: '03-1234-5678'), keyboardType: TextInputType.phone), ], ), ), actions: [ TextButton(onPressed: () => Navigator.pop(ctx), child: const Text('キャンセル')), ElevatedButton( onPressed: () { Navigator.pop(ctx); }, child: const Text('登録'), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('/M1. 仕入先マスタ')), body: _suppliers.isEmpty ? Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.inbox_outlined, size: 64, color: Colors.grey[300]), SizedBox(height: 16), Text('仕入先データがありません', style: TextStyle(color: Colors.grey)), SizedBox(height: 16), ElevatedButton( onPressed: _addSupplier, child: const Text('新規登録'), ), ], ), ) : ListView.builder( padding: const EdgeInsets.all(8), itemCount: _suppliers.length, itemBuilder: (context, index) { final supplier = _suppliers[index]; return Card( margin: EdgeInsets.zero, clipBehavior: Clip.antiAlias, child: ListTile( leading: CircleAvatar( backgroundColor: Colors.orange.shade100, child: Text(supplier['supplier_code'] ?? '-', style: const TextStyle(fontWeight: FontWeight.bold)), ), title: Text(supplier['name'] ?? '未入力'), ), ); }, ), floatingActionButton: FloatingActionButton.extended( icon: const Icon(Icons.add), label: const Text('新規登録'), onPressed: _addSupplier, ), ); } }