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:
Pablinux
2026-06-14 09:18:18 -05:00
co-authored by Claude Sonnet 4.6
commit 4a4113ec59
162 changed files with 11871 additions and 0 deletions
+224
View File
@@ -0,0 +1,224 @@
import 'package:flutter/material.dart';
import '../models/parada_ruta.dart';
import '../theme/app_theme.dart';
class RouteMapPainter extends CustomPainter {
final List<ParadaRuta> paradas;
RouteMapPainter(this.paradas);
@override
void paint(Canvas canvas, Size size) {
_drawMapBackground(canvas, size);
_drawGrid(canvas, size);
_drawRoute(canvas, size);
_drawMarkers(canvas, size);
}
void _drawMapBackground(Canvas canvas, Size size) {
final bgPaint = Paint()..color = const Color(0xFFEEF2FF);
canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), bgPaint);
// blocks
final blockPaint = Paint()..color = const Color(0xFFDDD6FE).withOpacity(0.4);
final blocks = [
Rect.fromLTWH(size.width * 0.05, size.height * 0.08, size.width * 0.25, size.height * 0.15),
Rect.fromLTWH(size.width * 0.40, size.height * 0.05, size.width * 0.20, size.height * 0.18),
Rect.fromLTWH(size.width * 0.70, size.height * 0.10, size.width * 0.22, size.height * 0.12),
Rect.fromLTWH(size.width * 0.10, size.height * 0.35, size.width * 0.18, size.height * 0.20),
Rect.fromLTWH(size.width * 0.35, size.height * 0.30, size.width * 0.28, size.height * 0.22),
Rect.fromLTWH(size.width * 0.70, size.height * 0.30, size.width * 0.22, size.height * 0.25),
Rect.fromLTWH(size.width * 0.05, size.height * 0.62, size.width * 0.30, size.height * 0.18),
Rect.fromLTWH(size.width * 0.42, size.height * 0.60, size.width * 0.22, size.height * 0.20),
Rect.fromLTWH(size.width * 0.72, size.height * 0.62, size.width * 0.20, size.height * 0.18),
];
for (final r in blocks) {
canvas.drawRRect(
RRect.fromRectAndRadius(r, const Radius.circular(4)),
blockPaint,
);
}
// roads
final roadPaint = Paint()
..color = Colors.white
..strokeWidth = 8
..strokeCap = StrokeCap.round;
final roads = [
[Offset(0, size.height * 0.28), Offset(size.width, size.height * 0.28)],
[Offset(0, size.height * 0.57), Offset(size.width, size.height * 0.57)],
[Offset(size.width * 0.32, 0), Offset(size.width * 0.32, size.height)],
[Offset(size.width * 0.65, 0), Offset(size.width * 0.65, size.height)],
];
for (final road in roads) {
canvas.drawLine(road[0], road[1], roadPaint);
}
}
void _drawGrid(Canvas canvas, Size size) {
final gridPaint = Paint()
..color = Colors.white.withOpacity(0.6)
..strokeWidth = 1;
for (double x = 0; x < size.width; x += size.width / 8) {
canvas.drawLine(Offset(x, 0), Offset(x, size.height), gridPaint);
}
for (double y = 0; y < size.height; y += size.height / 6) {
canvas.drawLine(Offset(0, y), Offset(size.width, y), gridPaint);
}
}
List<Offset> _getPositions(Size size) {
// Fixed visual positions for the 6 stops
return [
Offset(size.width * 0.18, size.height * 0.20),
Offset(size.width * 0.50, size.height * 0.15),
Offset(size.width * 0.80, size.height * 0.22),
Offset(size.width * 0.75, size.height * 0.50),
Offset(size.width * 0.45, size.height * 0.72),
Offset(size.width * 0.15, size.height * 0.68),
];
}
void _drawRoute(Canvas canvas, Size size) {
if (paradas.isEmpty) return;
final positions = _getPositions(size);
final count = paradas.length < positions.length ? paradas.length : positions.length;
// dashed line for future stops
final donePaint = Paint()
..color = AppTheme.primaryColor.withOpacity(0.7)
..strokeWidth = 2.5
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke;
final pendingPaint = Paint()
..color = AppTheme.primaryColor.withOpacity(0.35)
..strokeWidth = 2
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke;
for (int i = 0; i < count - 1; i++) {
final isVisited = paradas[i].estado == EstadoParada.visitado &&
paradas[i + 1].estado == EstadoParada.visitado;
canvas.drawLine(positions[i], positions[i + 1],
isVisited ? donePaint : pendingPaint);
}
}
void _drawMarkers(Canvas canvas, Size size) {
if (paradas.isEmpty) return;
final positions = _getPositions(size);
final count = paradas.length < positions.length ? paradas.length : positions.length;
for (int i = 0; i < count; i++) {
final parada = paradas[i];
final pos = positions[i];
final isVisited = parada.estado == EstadoParada.visitado;
final isCurrent = parada.estado == EstadoParada.pendiente &&
(i == 0 || paradas[i - 1].estado == EstadoParada.visitado);
final color = isVisited
? AppTheme.successColor
: isCurrent
? AppTheme.accentColor
: AppTheme.primaryColor.withOpacity(0.5);
// shadow
final shadowPaint = Paint()
..color = Colors.black.withOpacity(0.15)
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 3);
canvas.drawCircle(pos + const Offset(0, 2), isCurrent ? 16 : 13, shadowPaint);
// outer ring for current
if (isCurrent) {
final ringPaint = Paint()
..color = AppTheme.accentColor.withOpacity(0.25)
..style = PaintingStyle.fill;
canvas.drawCircle(pos, 22, ringPaint);
}
// marker body
final markerPaint = Paint()..color = color;
canvas.drawCircle(pos, isCurrent ? 16 : 13, markerPaint);
// white inner
final innerPaint = Paint()..color = Colors.white;
canvas.drawCircle(pos, isCurrent ? 9 : 7, innerPaint);
// number
final textPainter = TextPainter(
text: TextSpan(
text: '${i + 1}',
style: TextStyle(
color: color,
fontSize: isCurrent ? 10 : 8,
fontWeight: FontWeight.bold,
),
),
textDirection: TextDirection.ltr,
)..layout();
textPainter.paint(
canvas,
pos - Offset(textPainter.width / 2, textPainter.height / 2),
);
// label chip
_drawLabel(canvas, pos, parada.cliente.nombre.split(' ').first, color, isCurrent);
}
// current position indicator (GPS dot)
if (count > 0) {
final currentIndex = paradas.indexWhere((p) => p.estado == EstadoParada.pendiente);
if (currentIndex >= 0 && currentIndex < positions.length) {
final gpsPos = positions[currentIndex] + const Offset(-24, -24);
final gpsPaint = Paint()..color = Colors.blue;
canvas.drawCircle(gpsPos, 7, gpsPaint);
final gpsBorderPaint = Paint()
..color = Colors.white
..style = PaintingStyle.stroke
..strokeWidth = 2;
canvas.drawCircle(gpsPos, 7, gpsBorderPaint);
final gpsPulsePaint = Paint()
..color = Colors.blue.withOpacity(0.25);
canvas.drawCircle(gpsPos, 12, gpsPulsePaint);
}
}
}
void _drawLabel(Canvas canvas, Offset pos, String text, Color color, bool isCurrent) {
final tp = TextPainter(
text: TextSpan(
text: text,
style: const TextStyle(
color: AppTheme.textPrimary,
fontSize: 9,
fontWeight: FontWeight.w600,
),
),
textDirection: TextDirection.ltr,
)..layout();
const padding = 4.0;
final chipW = tp.width + padding * 2;
const chipH = 16.0;
final chipOffset = Offset(pos.dx - chipW / 2, pos.dy + (isCurrent ? 20 : 17));
final chipBg = Paint()..color = Colors.white.withOpacity(0.9);
final chipBorder = Paint()
..color = color.withOpacity(0.5)
..style = PaintingStyle.stroke
..strokeWidth = 1;
final chipRect = RRect.fromRectAndRadius(
Rect.fromLTWH(chipOffset.dx, chipOffset.dy, chipW, chipH),
const Radius.circular(4),
);
canvas.drawRRect(chipRect, chipBg);
canvas.drawRRect(chipRect, chipBorder);
tp.paint(canvas, chipOffset + const Offset(padding, 3));
}
@override
bool shouldRepaint(RouteMapPainter oldDelegate) => true;
}