feat: Agente Ventas SIGMAC — app de rutas y pedidos de campo
App Flutter 2.11 para vendedores de ruta de Telcotronics. Incluye ruta del día con mapa custom, catálogo, pedidos CRUD, firma digital, scanner QR/barcode, selector de clientes escalable, notificaciones in-app y soporte multiplataforma (Android + Linux desktop). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import '../../theme/app_theme.dart';
|
||||
|
||||
class ScannerScreen extends StatefulWidget {
|
||||
final String titulo;
|
||||
const ScannerScreen({Key? key, this.titulo = 'Escanear código'}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ScannerScreen> createState() => _ScannerScreenState();
|
||||
}
|
||||
|
||||
class _ScannerScreenState extends State<ScannerScreen> {
|
||||
final _controller = MobileScannerController();
|
||||
bool _scanned = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onDetect(Barcode barcode, MobileScannerArguments? args) {
|
||||
if (_scanned || barcode.rawValue == null || barcode.rawValue!.isEmpty) return;
|
||||
_scanned = true;
|
||||
Navigator.pop(context, barcode.rawValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
title: Text(widget.titulo),
|
||||
actions: [
|
||||
ValueListenableBuilder<TorchState>(
|
||||
valueListenable: _controller.torchState,
|
||||
builder: (_, state, __) => IconButton(
|
||||
tooltip: state == TorchState.on ? 'Apagar linterna' : 'Encender linterna',
|
||||
icon: Icon(
|
||||
state == TorchState.on ? Icons.flash_on : Icons.flash_off,
|
||||
color: state == TorchState.on ? Colors.yellow : Colors.white,
|
||||
),
|
||||
onPressed: _controller.toggleTorch,
|
||||
),
|
||||
),
|
||||
ValueListenableBuilder<CameraFacing>(
|
||||
valueListenable: _controller.cameraFacingState,
|
||||
builder: (_, facing, __) => IconButton(
|
||||
tooltip: 'Cambiar cámara',
|
||||
icon: const Icon(Icons.cameraswitch, color: Colors.white),
|
||||
onPressed: _controller.switchCamera,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
MobileScanner(
|
||||
controller: _controller,
|
||||
fit: BoxFit.cover,
|
||||
onDetect: _onDetect,
|
||||
),
|
||||
CustomPaint(
|
||||
painter: _ScanOverlayPainter(),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 56,
|
||||
child: Column(
|
||||
children: const [
|
||||
Icon(Icons.qr_code_scanner, color: Colors.white38, size: 28),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
'Apunta al código QR o código de barras',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.white70, fontSize: 13),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ScanOverlayPainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final frameSize = size.width * 0.72;
|
||||
final left = (size.width - frameSize) / 2;
|
||||
final top = (size.height - frameSize) / 2 - 40;
|
||||
final frameRect = Rect.fromLTWH(left, top, frameSize, frameSize);
|
||||
|
||||
// Semi-transparent overlay with hole
|
||||
final overlayPaint = Paint()..color = Colors.black.withOpacity(0.55);
|
||||
final outer = Path()..addRect(Rect.fromLTWH(0, 0, size.width, size.height));
|
||||
final inner = Path()..addRRect(RRect.fromRectAndRadius(frameRect, const Radius.circular(10)));
|
||||
canvas.drawPath(Path.combine(PathOperation.difference, outer, inner), overlayPaint);
|
||||
|
||||
// Corner brackets
|
||||
final bracketPaint = Paint()
|
||||
..color = AppTheme.primaryColor
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 3.5
|
||||
..strokeCap = StrokeCap.round;
|
||||
|
||||
const cl = 22.0; // corner length
|
||||
final l = frameRect.left;
|
||||
final t = frameRect.top;
|
||||
final r = frameRect.right;
|
||||
final b = frameRect.bottom;
|
||||
|
||||
// Top-left
|
||||
canvas.drawLine(Offset(l, t + cl), Offset(l, t), bracketPaint);
|
||||
canvas.drawLine(Offset(l, t), Offset(l + cl, t), bracketPaint);
|
||||
// Top-right
|
||||
canvas.drawLine(Offset(r - cl, t), Offset(r, t), bracketPaint);
|
||||
canvas.drawLine(Offset(r, t), Offset(r, t + cl), bracketPaint);
|
||||
// Bottom-left
|
||||
canvas.drawLine(Offset(l, b - cl), Offset(l, b), bracketPaint);
|
||||
canvas.drawLine(Offset(l, b), Offset(l + cl, b), bracketPaint);
|
||||
// Bottom-right
|
||||
canvas.drawLine(Offset(r - cl, b), Offset(r, b), bracketPaint);
|
||||
canvas.drawLine(Offset(r, b), Offset(r, b - cl), bracketPaint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user