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,155 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/notificacion.dart';
|
||||
|
||||
class NotificationBanner extends StatefulWidget {
|
||||
final Notificacion notificacion;
|
||||
final VoidCallback onDismiss;
|
||||
|
||||
const NotificationBanner({
|
||||
Key? key,
|
||||
required this.notificacion,
|
||||
required this.onDismiss,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<NotificationBanner> createState() => _NotificationBannerState();
|
||||
}
|
||||
|
||||
class _NotificationBannerState extends State<NotificationBanner>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _ctrl;
|
||||
late Animation<Offset> _slide;
|
||||
late Animation<double> _fade;
|
||||
bool _dismissing = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_ctrl = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 320),
|
||||
);
|
||||
_slide = Tween<Offset>(
|
||||
begin: const Offset(0, -1.2),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(parent: _ctrl, curve: Curves.easeOutBack));
|
||||
_fade = CurvedAnimation(parent: _ctrl, curve: Curves.easeOut);
|
||||
|
||||
_ctrl.forward();
|
||||
Future.delayed(const Duration(milliseconds: 3800), _startDismiss);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_ctrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _startDismiss() async {
|
||||
if (_dismissing || !mounted) return;
|
||||
_dismissing = true;
|
||||
_ctrl.reverse();
|
||||
await Future.delayed(const Duration(milliseconds: 320));
|
||||
widget.onDismiss();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final notif = widget.notificacion;
|
||||
final color = notif.tipo.color;
|
||||
|
||||
return Positioned(
|
||||
top: MediaQuery.of(context).padding.top + 10,
|
||||
left: 14,
|
||||
right: 14,
|
||||
child: SlideTransition(
|
||||
position: _slide,
|
||||
child: FadeTransition(
|
||||
opacity: _fade,
|
||||
child: Material(
|
||||
elevation: 8,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
shadowColor: color.withOpacity(0.3),
|
||||
child: GestureDetector(
|
||||
onTap: _startDismiss,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border(
|
||||
left: BorderSide(color: color, width: 4),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 12, 8, 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(notif.tipo.icono, color: color, size: 18),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
notif.titulo,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF0F172A),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'Ahora',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.grey.shade500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
notif.cuerpo,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF475569),
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: _startDismiss,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 4),
|
||||
child: Icon(Icons.close, size: 16, color: Colors.grey.shade400),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class SignaturePad extends StatefulWidget {
|
||||
final void Function(List<List<Offset>> strokes) onChanged;
|
||||
|
||||
const SignaturePad({Key? key, required this.onChanged}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SignaturePad> createState() => SignaturePadState();
|
||||
}
|
||||
|
||||
class SignaturePadState extends State<SignaturePad> {
|
||||
final List<List<Offset>> _strokes = [];
|
||||
List<Offset> _current = [];
|
||||
|
||||
bool get isEmpty => _strokes.isEmpty;
|
||||
|
||||
void clear() {
|
||||
setState(() {
|
||||
_strokes.clear();
|
||||
_current = [];
|
||||
});
|
||||
widget.onChanged([]);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onPanStart: (details) {
|
||||
setState(() {
|
||||
_current = [details.localPosition];
|
||||
});
|
||||
},
|
||||
onPanUpdate: (details) {
|
||||
setState(() {
|
||||
_current = [..._current, details.localPosition];
|
||||
});
|
||||
},
|
||||
onPanEnd: (_) {
|
||||
if (_current.isNotEmpty) {
|
||||
setState(() {
|
||||
_strokes.add(List.from(_current));
|
||||
_current = [];
|
||||
});
|
||||
widget.onChanged(List.from(_strokes));
|
||||
}
|
||||
},
|
||||
child: CustomPaint(
|
||||
painter: _SignaturePainter(strokes: _strokes, current: _current),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: const Color(0xFFCBD5E1), width: 1.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SignaturePainter extends CustomPainter {
|
||||
final List<List<Offset>> strokes;
|
||||
final List<Offset> current;
|
||||
|
||||
_SignaturePainter({required this.strokes, required this.current});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()
|
||||
..color = AppTheme.primaryColor
|
||||
..strokeWidth = 2.5
|
||||
..strokeCap = StrokeCap.round
|
||||
..strokeJoin = StrokeJoin.round
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
for (final stroke in strokes) {
|
||||
_drawStroke(canvas, stroke, paint);
|
||||
}
|
||||
if (current.isNotEmpty) {
|
||||
_drawStroke(canvas, current, paint);
|
||||
}
|
||||
}
|
||||
|
||||
void _drawStroke(Canvas canvas, List<Offset> points, Paint paint) {
|
||||
if (points.length < 2) return;
|
||||
final path = Path()..moveTo(points[0].dx, points[0].dy);
|
||||
for (int i = 1; i < points.length - 1; i++) {
|
||||
final mid = Offset(
|
||||
(points[i].dx + points[i + 1].dx) / 2,
|
||||
(points[i].dy + points[i + 1].dy) / 2,
|
||||
);
|
||||
path.quadraticBezierTo(points[i].dx, points[i].dy, mid.dx, mid.dy);
|
||||
}
|
||||
path.lineTo(points.last.dx, points.last.dy);
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_SignaturePainter old) => true;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class StatCard extends StatelessWidget {
|
||||
final String titulo;
|
||||
final String valor;
|
||||
final String subtitulo;
|
||||
final IconData icono;
|
||||
final Color color;
|
||||
|
||||
const StatCard({
|
||||
Key? key,
|
||||
required this.titulo,
|
||||
required this.valor,
|
||||
required this.subtitulo,
|
||||
required this.icono,
|
||||
required this.color,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.cardColor,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: color.withOpacity(0.15),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
titulo,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.12),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icono, color: color, size: 18),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
valor,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitulo,
|
||||
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user