| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import 'dart:io' show Platform;
- import 'package:chicken_farm/stores/menu_store.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'package:go_router/go_router.dart';
- class MenuButtons extends ConsumerWidget {
- const MenuButtons({super.key});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final visibleMenuItems = MenuStore.getVisibleMenuItems(ref);
- final screenWidth = MediaQuery.of(context).size.width;
- double buttonWidth = screenWidth * 0.8;
- buttonWidth = Platform.isAndroid
- ? buttonWidth
- : buttonWidth > 350
- ? 350
- : buttonWidth;
- return SingleChildScrollView(
- child: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- for (var i = 0; i < visibleMenuItems.length; i++) ...[
- SizedBox(
- width: buttonWidth,
- height: 50,
- child: ElevatedButton.icon(
- onPressed: () {
- Future.delayed(const Duration(milliseconds: 100), () {
- if (context.mounted) {
- context.pushNamed(visibleMenuItems[i].routeName);
- }
- });
- },
- icon: visibleMenuItems[i].icon != null
- ? Icon(visibleMenuItems[i].icon)
- : const SizedBox.shrink(),
- label: Text(visibleMenuItems[i].name),
- ),
- ),
- if (i < visibleMenuItems.length - 1) ...[
- const SizedBox(height: 20.00),
- if (!Platform.isAndroid) ...[const SizedBox(height: 10.00)],
- ],
- ],
- ],
- ),
- ),
- );
- }
- }
|