lint changes rb
This commit is contained in:
@@ -8,7 +8,9 @@ import 'package:stream_chat_flutter/src/reaction_icon.dart';
|
|||||||
import 'package:stream_chat_flutter/src/stream_svg_icon.dart';
|
import 'package:stream_chat_flutter/src/stream_svg_icon.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
|
/// Creates reaction bubble widget for displaying over messages
|
||||||
class ReactionBubble extends StatelessWidget {
|
class ReactionBubble extends StatelessWidget {
|
||||||
|
/// Constructor for creating a [ReactionBubble]
|
||||||
const ReactionBubble({
|
const ReactionBubble({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.reactions,
|
required this.reactions,
|
||||||
@@ -21,13 +23,28 @@ class ReactionBubble extends StatelessWidget {
|
|||||||
this.tailCirclesSpacing = 0,
|
this.tailCirclesSpacing = 0,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
/// Reactions to show
|
||||||
final List<Reaction> reactions;
|
final List<Reaction> reactions;
|
||||||
|
|
||||||
|
/// Border color of bubble
|
||||||
final Color borderColor;
|
final Color borderColor;
|
||||||
|
|
||||||
|
/// Background color of bubble
|
||||||
final Color backgroundColor;
|
final Color backgroundColor;
|
||||||
|
|
||||||
|
/// Mask color
|
||||||
final Color maskColor;
|
final Color maskColor;
|
||||||
|
|
||||||
|
/// Reverse for other side
|
||||||
final bool reverse;
|
final bool reverse;
|
||||||
|
|
||||||
|
/// Reverse tail for other side
|
||||||
final bool flipTail;
|
final bool flipTail;
|
||||||
|
|
||||||
|
/// Flag for highlighting own reactions
|
||||||
final bool highlightOwnReactions;
|
final bool highlightOwnReactions;
|
||||||
|
|
||||||
|
/// Spacing for tail circles
|
||||||
final double tailCirclesSpacing;
|
final double tailCirclesSpacing;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -47,7 +64,7 @@ class ReactionBubble extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(2),
|
padding: const EdgeInsets.all(2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: maskColor,
|
color: maskColor,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
@@ -59,35 +76,32 @@ class ReactionBubble extends StatelessWidget {
|
|||||||
color: borderColor,
|
color: borderColor,
|
||||||
),
|
),
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(14)),
|
borderRadius: const BorderRadius.all(Radius.circular(14)),
|
||||||
),
|
),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) => Flex(
|
||||||
return Flex(
|
direction: Axis.horizontal,
|
||||||
direction: Axis.horizontal,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
children: [
|
if (constraints.maxWidth < double.infinity)
|
||||||
if (constraints.maxWidth < double.infinity)
|
...reactions
|
||||||
...reactions
|
.take((constraints.maxWidth) ~/ 24)
|
||||||
.take((constraints.maxWidth) ~/ 24)
|
.map((reaction) => _buildReaction(
|
||||||
.map((reaction) {
|
reactionIcons,
|
||||||
return _buildReaction(
|
reaction,
|
||||||
reactionIcons,
|
context,
|
||||||
reaction,
|
))
|
||||||
context,
|
.toList(),
|
||||||
);
|
if (constraints.maxWidth == double.infinity)
|
||||||
}).toList(),
|
...reactions
|
||||||
if (constraints.maxWidth == double.infinity)
|
.map((reaction) => _buildReaction(
|
||||||
...reactions.map((reaction) {
|
reactionIcons,
|
||||||
return _buildReaction(
|
reaction,
|
||||||
reactionIcons,
|
context,
|
||||||
reaction,
|
))
|
||||||
context,
|
.toList(),
|
||||||
);
|
],
|
||||||
}).toList(),
|
),
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -160,12 +174,9 @@ class ReactionBubble extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Painter widget for a reaction bubble
|
||||||
class ReactionBubblePainter extends CustomPainter {
|
class ReactionBubblePainter extends CustomPainter {
|
||||||
final Color color;
|
/// Constructor for creating a [ReactionBubblePainter]
|
||||||
final Color borderColor;
|
|
||||||
final Color maskColor;
|
|
||||||
final double tailCirclesSpace;
|
|
||||||
|
|
||||||
ReactionBubblePainter(
|
ReactionBubblePainter(
|
||||||
this.color,
|
this.color,
|
||||||
this.borderColor,
|
this.borderColor,
|
||||||
@@ -173,6 +184,18 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
this.tailCirclesSpace = 0,
|
this.tailCirclesSpace = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Color of bubble
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
/// Border color of bubble
|
||||||
|
final Color borderColor;
|
||||||
|
|
||||||
|
/// Mask color
|
||||||
|
final Color maskColor;
|
||||||
|
|
||||||
|
/// Tail circle space
|
||||||
|
final double tailCirclesSpace;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
_drawOvalMask(size, canvas);
|
_drawOvalMask(size, canvas);
|
||||||
@@ -193,13 +216,14 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
..color = maskColor
|
..color = maskColor
|
||||||
..style = PaintingStyle.fill;
|
..style = PaintingStyle.fill;
|
||||||
|
|
||||||
final path = Path();
|
final path = Path()
|
||||||
path.addOval(
|
..addOval(
|
||||||
Rect.fromCircle(
|
Rect.fromCircle(
|
||||||
center: Offset(4, 3) + Offset(tailCirclesSpace, tailCirclesSpace),
|
center:
|
||||||
radius: 4,
|
const Offset(4, 3) + Offset(tailCirclesSpace, tailCirclesSpace),
|
||||||
),
|
radius: 4,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,13 +233,14 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
..strokeWidth = 1
|
..strokeWidth = 1
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
|
|
||||||
final path = Path();
|
final path = Path()
|
||||||
path.addOval(
|
..addOval(
|
||||||
Rect.fromCircle(
|
Rect.fromCircle(
|
||||||
center: Offset(4, 3) + Offset(tailCirclesSpace, tailCirclesSpace),
|
center:
|
||||||
radius: 2,
|
const Offset(4, 3) + Offset(tailCirclesSpace, tailCirclesSpace),
|
||||||
),
|
radius: 2,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,11 +249,11 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
..color = color
|
..color = color
|
||||||
..strokeWidth = 1;
|
..strokeWidth = 1;
|
||||||
|
|
||||||
final path = Path();
|
final path = Path()
|
||||||
path.addOval(Rect.fromCircle(
|
..addOval(Rect.fromCircle(
|
||||||
center: Offset(4, 3) + Offset(tailCirclesSpace, tailCirclesSpace),
|
center: const Offset(4, 3) + Offset(tailCirclesSpace, tailCirclesSpace),
|
||||||
radius: 2,
|
radius: 2,
|
||||||
));
|
));
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,15 +266,15 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
const dy = -2.2;
|
const dy = -2.2;
|
||||||
const startAngle = 1.1;
|
const startAngle = 1.1;
|
||||||
const sweepAngle = 1.2;
|
const sweepAngle = 1.2;
|
||||||
final path = Path();
|
final path = Path()
|
||||||
path.addArc(
|
..addArc(
|
||||||
Rect.fromCircle(
|
Rect.fromCircle(
|
||||||
center: Offset(1, dy),
|
center: const Offset(1, dy),
|
||||||
radius: 4,
|
radius: 4,
|
||||||
),
|
),
|
||||||
-pi * startAngle,
|
-pi * startAngle,
|
||||||
-pi / sweepAngle,
|
-pi / sweepAngle,
|
||||||
);
|
);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,15 +286,15 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
const dy = -2.2;
|
const dy = -2.2;
|
||||||
const startAngle = 1;
|
const startAngle = 1;
|
||||||
const sweepAngle = 1.3;
|
const sweepAngle = 1.3;
|
||||||
final path = Path();
|
final path = Path()
|
||||||
path.addArc(
|
..addArc(
|
||||||
Rect.fromCircle(
|
Rect.fromCircle(
|
||||||
center: Offset(1, dy),
|
center: const Offset(1, dy),
|
||||||
radius: 4,
|
radius: 4,
|
||||||
),
|
),
|
||||||
-pi * startAngle,
|
-pi * startAngle,
|
||||||
-pi * sweepAngle,
|
-pi * sweepAngle,
|
||||||
);
|
);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,20 +307,18 @@ class ReactionBubblePainter extends CustomPainter {
|
|||||||
const dy = -2.2;
|
const dy = -2.2;
|
||||||
const startAngle = 1.1;
|
const startAngle = 1.1;
|
||||||
const sweepAngle = 1.2;
|
const sweepAngle = 1.2;
|
||||||
final path = Path();
|
final path = Path()
|
||||||
path.addArc(
|
..addArc(
|
||||||
Rect.fromCircle(
|
Rect.fromCircle(
|
||||||
center: Offset(1, dy),
|
center: const Offset(1, dy),
|
||||||
radius: 6,
|
radius: 6,
|
||||||
),
|
),
|
||||||
-pi * startAngle,
|
-pi * startAngle,
|
||||||
-pi / sweepAngle,
|
-pi / sweepAngle,
|
||||||
);
|
);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
bool shouldRepaint(CustomPainter oldDelegate) => true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user