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,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;
|
||||
}
|
||||
Reference in New Issue
Block a user