181186 - Criar PDV Android para rodar em maquinas P.O.S.

This commit is contained in:
felipe.franca committed 2026-11-17 17:43:00 -03:00
commit c9983cbad5
204 files changed
+11453

No files matched your search

@@ -0,0 +1,164 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../app/app_services.dart';
import '../../../app/router/app_router.dart';
class MenuScreen extends StatefulWidget {
const MenuScreen({required this.services, super.key});
final AppServices services;
@override
State<MenuScreen> createState() => _MenuScreenState();
}
class _MenuScreenState extends State<MenuScreen> {
bool _loggingOut = false;
Future<void> _logout() async {
if (_loggingOut) return;
setState(() => _loggingOut = true);
await widget.services.authRepository.logout();
if (!mounted) return;
Navigator.of(context).pushNamedAndRemoveUntil(
AppRoutes.login,
(_) => false,
);
}
Future<void> _exit() => SystemNavigator.pop();
@override
Widget build(BuildContext context) {
final session = widget.services.authRepository.currentSession;
final companyId = session?.companyId;
final companyName = session?.companyName;
final companyDescription = [
if (companyId != null) companyId.toString(),
if (companyName != null && companyName.trim().isNotEmpty)
companyName.trim(),
].join(' - ');
final actions = [
_MenuAction(
label: 'Venda',
icon: Icons.point_of_sale_outlined,
onPressed: () => Navigator.of(context).pushNamed(AppRoutes.sale),
),
_MenuAction(
label: 'Histórico de vendas',
icon: Icons.receipt_long_outlined,
onPressed: () =>
Navigator.of(context).pushNamed(AppRoutes.salesHistory),
),
_MenuAction(
label: _loggingOut ? 'Saindo...' : 'Log out',
icon: Icons.logout,
onPressed: _loggingOut ? null : _logout,
),
_MenuAction(
label: 'Sair',
icon: Icons.power_settings_new,
onPressed: _exit,
),
];
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text('Menu do PDV'),
),
body: SafeArea(
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 760),
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
child: Card(
child: ListTile(
leading: const CircleAvatar(
child: Icon(Icons.person_outline),
),
title: Text(
session?.userName ?? 'Usuário',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(fontWeight: FontWeight.bold),
),
subtitle: Text(
companyDescription.isEmpty
? 'Empresa não informada'
: 'Empresa: $companyDescription',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
),
),
Expanded(
child: GridView.builder(
padding: const EdgeInsets.all(16),
itemCount: actions.length,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
childAspectRatio: 1,
),
itemBuilder: (context, index) {
final action = actions[index];
return Card(
clipBehavior: Clip.antiAlias,
child: InkWell(
key: Key('menu-${index + 1}'),
onTap: action.onPressed,
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(action.icon, size: 48),
const SizedBox(height: 12),
Text(
action.label,
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(fontWeight: FontWeight.w600),
),
],
),
),
),
);
},
),
),
],
),
),
),
),
);
}
}
class _MenuAction {
const _MenuAction({
required this.label,
required this.icon,
required this.onPressed,
});
final String label;
final IconData icon;
final VoidCallback? onPressed;
}