h-1.flutter.4/lib/screens/home_screen.dart

84 lines
No EOL
3.1 KiB
Dart

// home_screen.dart - ダッシュボード(メインメニュー)
import 'package:flutter/material.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
static const List<_MenuItem> _menuItems = <_MenuItem>[
_MenuItem(title: '見積入力', route: '/estimate'),
_MenuItem(title: '在庫管理', route: '/inventory'),
_MenuItem(title: '商品マスタ', route: '/master/product'),
_MenuItem(title: '得意先マスタ', route: '/master/customer'),
_MenuItem(title: '仕入先マスタ', route: '/master/supplier'),
_MenuItem(title: '倉庫マスタ', route: '/master/warehouse'),
_MenuItem(title: '担当マスタ', route: '/master/employee'),
];
static const Map<String, IconData> _menuIconMap = <String, IconData>{
'/estimate': Icons.description_outlined,
'/inventory': Icons.inventory_2_outlined,
'/master/product': Icons.shopping_cart_outlined,
'/master/customer': Icons.people_outlined,
'/master/supplier': Icons.business_outlined,
'/master/warehouse': Icons.storage_outlined,
'/master/employee': Icons.person_outlined,
};
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('/ホーム:メインメニュー'),),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const Text('ダッシュボード', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
// メニューボタン群
..._menuItems.map((item) => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: ListTile(
leading: Icon(_menuIconMap[item.route]),
title: Text(item.title),
subtitle: const Text('タスクをここから開始します'),
onTap: () => Navigator.pushNamed(context, item.route),
),
),),
const SizedBox(height: 32),
const Text('/S. 売上入力(レジ)', style: TextStyle(fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
children: <Widget>[
Icon(Icons.add_shopping_cart, size: 64, color: Colors.orange),
const SizedBox(height: 16),
ElevatedButton.icon(
icon: const Icon(Icons.point_of_sale),
label: const Text('売上入力画面へ'),
onPressed: () => Navigator.pushNamed(context, '/sales'),
),
],
),
),
),
],
),
),
);
}
}
class _MenuItem {
final String title;
final String route;
const _MenuItem({required this.title, required this.route});
}