105 lines
No EOL
3.8 KiB
Dart
105 lines
No EOL
3.8 KiB
Dart
// Version: 3.0 - シンプル顧客マスタ画面(簡素版、サンプルデータ固定)
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class CustomerMasterScreen extends StatefulWidget {
|
|
const CustomerMasterScreen({super.key});
|
|
|
|
@override
|
|
State<CustomerMasterScreen> createState() => _CustomerMasterScreenState();
|
|
}
|
|
|
|
class _CustomerMasterScreenState extends State<CustomerMasterScreen> {
|
|
List<dynamic> _customers = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// サンプルデータ(簡素版)
|
|
_customers = [
|
|
{'customer_code': 'C001', 'name': 'サンプル顧客 A'},
|
|
{'customer_code': 'C002', 'name': 'サンプル顧客 B'},
|
|
];
|
|
}
|
|
|
|
Future<void> _addCustomer() async {
|
|
await showDialog<dynamic>(
|
|
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: 'C003')),
|
|
SizedBox(height: 8),
|
|
TextField(decoration: const InputDecoration(labelText: '名称', hintText: '新顧客名'), onChanged: (v) => setState(() {})),
|
|
SizedBox(height: 8),
|
|
TextField(decoration: const InputDecoration(labelText: '住所', hintText: '住所を入力')),
|
|
SizedBox(height: 8),
|
|
TextField(decoration: const InputDecoration(labelText: '電話番号', hintText: '03-1234-5678'), keyboardType: TextInputType.phone, onChanged: (v) => setState(() {})),
|
|
],
|
|
),
|
|
),
|
|
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('/M2. 顧客マスタ')),
|
|
body: _customers.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),
|
|
FloatingActionButton.extended(
|
|
icon: Icon(Icons.add, color: Theme.of(context).primaryColor),
|
|
label: const Text('新規登録'),
|
|
onPressed: _addCustomer,
|
|
),
|
|
],
|
|
),
|
|
) : ListView.builder(
|
|
padding: const EdgeInsets.all(8),
|
|
itemCount: _customers.length,
|
|
itemBuilder: (context, index) {
|
|
final customer = _customers[index];
|
|
return Card(
|
|
margin: EdgeInsets.zero,
|
|
clipBehavior: Clip.antiAlias,
|
|
child: ListTile(
|
|
leading: CircleAvatar(backgroundColor: Colors.green.shade100, child: Text(customer['customer_code'] ?? '-', style: const TextStyle(fontWeight: FontWeight.bold))),
|
|
title: Text(customer['name'] ?? '未入力'),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (customer['phone'] != null) Text('電話:${customer['phone']}', style: const TextStyle(fontSize: 12)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
icon: const Icon(Icons.add),
|
|
label: const Text('新規登録'),
|
|
onPressed: _addCustomer,
|
|
),
|
|
);
|
|
}
|
|
} |