h-1.flutter.4/lib/screens/master/inventory_master_screen.dart

100 lines
No EOL
3.4 KiB
Dart

// Version: 1.6 - 在庫管理画面(簡易実装)
import 'package:flutter/material.dart';
/// 在庫管理画面
class InventoryMasterScreen extends StatefulWidget {
const InventoryMasterScreen({super.key});
@override
State<InventoryMasterScreen> createState() => _InventoryMasterScreenState();
}
class _InventoryMasterScreenState extends State<InventoryMasterScreen> {
String _productName = ''; // 商品名
int _stock = 0; // 在庫数
int _minStock = 10; // 再仕入れ水準
String? _supplierName; // 供給元
@override
void initState() {
super.initState();
// TODO: DatabaseHelper.instance.getInventory() を使用
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('在庫管理')),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 商品名入力
TextField(
decoration: const InputDecoration(hintText: '商品名', border: OutlineInputBorder()),
onChanged: (value) => setState(() => _productName = value),
),
const SizedBox(height: 16),
// 在庫数入力
TextField(
decoration: const InputDecoration(hintText: '在庫数', border: OutlineInputBorder()),
keyboardType: TextInputType.number,
onChanged: (value) => setState(() => _stock = int.tryParse(value) ?? 0),
),
const SizedBox(height: 16),
// 再仕入れ水準入力
TextField(
decoration: const InputDecoration(hintText: '再仕入れ水準', border: OutlineInputBorder()),
keyboardType: TextInputType.number,
onChanged: (value) => setState(() => _minStock = int.tryParse(value) ?? 10),
),
const SizedBox(height: 16),
// 供給元入力(簡易)
TextField(
decoration: const InputDecoration(hintText: '供給元', border: OutlineInputBorder()),
onChanged: (value) => setState(() => _supplierName = value.isNotEmpty ? value : null),
),
const SizedBox(height: 16),
// 在庫表示エリア(簡易)
Card(
child: ListTile(
contentPadding: EdgeInsets.zero,
title: const Text('現在の在庫'),
subtitle: Text('${_stock}', style: const TextStyle(fontSize: 18)),
trailing: _stock <= _minStock ? const Icon(Icons.warning, color: Colors.orange) : const SizedBox(),
),
),
const SizedBox(height: 16),
// 保存ボタン(簡易)
ElevatedButton(
onPressed: () {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('在庫データを更新しました')),
);
}
},
style: ElevatedButton.styleFrom(padding: const EdgeInsets.symmetric(vertical: 12)),
child: const Text('更新'),
),
],
),
),
),
);
}
}