Main coves client
1import 'package:flutter/material.dart';
2
3/// Share icon widget (arrow out of box)
4///
5/// Arrow-out-of-box icon from Bluesky's design system.
6/// Uses the modified version with rounded corners for a friendlier look.
7class ShareIcon extends StatelessWidget {
8 const ShareIcon({this.size = 18, this.color, super.key});
9
10 final double size;
11 final Color? color;
12
13 @override
14 Widget build(BuildContext context) {
15 final effectiveColor =
16 color ?? Theme.of(context).iconTheme.color ?? Colors.grey;
17
18 return CustomPaint(
19 size: Size(size, size),
20 painter: _ShareIconPainter(color: effectiveColor),
21 );
22 }
23}
24
25/// Custom painter for share icon
26///
27/// SVG path data from Bluesky's ArrowOutOfBoxModified icon component
28class _ShareIconPainter extends CustomPainter {
29 _ShareIconPainter({required this.color});
30
31 final Color color;
32
33 @override
34 void paint(Canvas canvas, Size size) {
35 final paint =
36 Paint()
37 ..color = color
38 ..style = PaintingStyle.fill; // Always fill - paths are pre-stroked
39
40 // Scale factor to fit 24x24 viewBox into widget size
41 final scale = size.width / 24.0;
42 canvas.scale(scale);
43
44 // ArrowOutOfBoxModified_Stroke2_Corner2_Rounded path from Bluesky
45 // M20 13.75a1 1 0 0 1 1 1V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-3.25
46 // a1 1 0 1 1 2 0V18 a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.25
47 // a1 1 0 0 1 1-1ZM12 3a1 1 0 0 1 .707.293 l4.5 4.5
48 // a1 1 0 1 1-1.414 1.414L13 6.414v8.836a1 1 0 1 1-2 0V6.414
49 // L8.207 9.207a1 1 0 1 1-1.414-1.414l4.5-4.5A1 1 0 0 1 12 3Z
50
51 // Box bottom part
52 final path =
53 Path()
54 ..moveTo(20, 13.75)
55 ..cubicTo(20.552, 13.75, 21, 14.198, 21, 14.75)
56 ..lineTo(21, 18)
57 ..cubicTo(21, 19.657, 19.657, 21, 18, 21)
58 ..lineTo(6, 21)
59 ..cubicTo(4.343, 21, 3, 19.657, 3, 18)
60 ..lineTo(3, 14.75)
61 ..cubicTo(3, 14.198, 3.448, 13.75, 4, 13.75)
62 ..cubicTo(4.552, 13.75, 5, 14.198, 5, 14.75)
63 ..lineTo(5, 18)
64 ..cubicTo(5, 18.552, 5.448, 19, 6, 19)
65 ..lineTo(18, 19)
66 ..cubicTo(18.552, 19, 19, 18.552, 19, 18)
67 ..lineTo(19, 14.75)
68 ..cubicTo(19, 14.198, 19.448, 13.75, 20, 13.75)
69 ..close()
70 // Arrow
71 ..moveTo(12, 3)
72 ..cubicTo(12.265, 3, 12.52, 3.105, 12.707, 3.293)
73 ..lineTo(17.207, 7.793)
74 ..cubicTo(17.598, 8.184, 17.598, 8.817, 17.207, 9.207)
75 ..cubicTo(16.816, 9.598, 16.183, 9.598, 15.793, 9.207)
76 ..lineTo(13, 6.414)
77 ..lineTo(13, 15.25)
78 ..cubicTo(13, 15.802, 12.552, 16.25, 12, 16.25)
79 ..cubicTo(11.448, 16.25, 11, 15.802, 11, 15.25)
80 ..lineTo(11, 6.414)
81 ..lineTo(8.207, 9.207)
82 ..cubicTo(7.816, 9.598, 7.183, 9.598, 6.793, 9.207)
83 ..cubicTo(6.402, 8.816, 6.402, 8.183, 6.793, 7.793)
84 ..lineTo(11.293, 3.293)
85 ..cubicTo(11.48, 3.105, 11.735, 3, 12, 3)
86 ..close();
87
88 canvas.drawPath(path, paint);
89 }
90
91 @override
92 bool shouldRepaint(_ShareIconPainter oldDelegate) {
93 return oldDelegate.color != color;
94 }
95}