181186 - Criar PDV Android para rodar em maquinas P.O.S.
This commit is contained in:
commit
c9983cbad5
204 files changed
+11453
No files matched your search
@@ -0,0 +1,189 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../app/app_services.dart';
|
||||
import '../../../app/router/app_router.dart';
|
||||
import '../../../domain/entities/sale_completion.dart';
|
||||
import '../../../core/widgets/app_button.dart';
|
||||
|
||||
class SaleCompleteScreen extends StatelessWidget {
|
||||
const SaleCompleteScreen({
|
||||
required this.services,
|
||||
required this.completion,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final AppServices services;
|
||||
final SaleCompletion completion;
|
||||
|
||||
void _startNextSale(BuildContext context) {
|
||||
services.cartRepository.clear();
|
||||
Navigator.of(context).popUntil(
|
||||
(route) => route.settings.name == AppRoutes.sale,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Venda finalizada'),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 520),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check_circle,
|
||||
size: 88,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'NFC-e gerada',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
_DocumentRow(
|
||||
label: 'Pedido',
|
||||
value: completion.orderNumber,
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_DocumentRow(
|
||||
label: 'Número NFC-e',
|
||||
value: completion.invoiceNumber,
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_DocumentRow(
|
||||
label: 'Série',
|
||||
value: completion.invoiceSeries,
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_DocumentRow(
|
||||
label: 'Estado da NFC-e',
|
||||
value: _invoiceStateLabel(
|
||||
completion.invoiceState,
|
||||
completion.invoiceContingency,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (completion.invoiceMessage.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Card(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
completion.invoiceMessage,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
AppButton(
|
||||
label: 'Imprimir NFC-e',
|
||||
icon: Icons.print_outlined,
|
||||
onPressed: () => _showPrintNotConfigured(context),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
AppButton(
|
||||
label: 'Nova venda',
|
||||
icon: Icons.storefront_outlined,
|
||||
onPressed: () => _startNextSale(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showPrintNotConfigured(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Impressão indisponível'),
|
||||
content: const Text(
|
||||
'A API/SDK da impressora do POS ainda não foi configurada.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Fechar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _invoiceStateLabel(String state, bool contingency) {
|
||||
if (contingency) return 'Emitida em Contingência';
|
||||
switch (state) {
|
||||
case '1':
|
||||
return 'Rascunho';
|
||||
case '2':
|
||||
return 'Validada';
|
||||
case '2E':
|
||||
return 'Validada com erro';
|
||||
case '3':
|
||||
return 'Faturada/autorizada';
|
||||
case 'C':
|
||||
return 'Cancelada';
|
||||
case 'D':
|
||||
return 'Denegada';
|
||||
case 'EP':
|
||||
return 'Em processamento';
|
||||
case 'I':
|
||||
return 'Inutilizada';
|
||||
case 'P':
|
||||
return 'Pendente';
|
||||
default:
|
||||
return state.isEmpty ? 'Não informado' : state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _DocumentRow extends StatelessWidget {
|
||||
const _DocumentRow({required this.label, required this.value});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(label),
|
||||
const SizedBox(width: 16),
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
textAlign: TextAlign.end,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user