lint changes reactions

This commit is contained in:
Deven Joshi
2021-05-05 16:32:32 +05:30
parent d1705c26a3
commit 645d21503a
2 changed files with 99 additions and 97 deletions
@@ -1,9 +1,14 @@
/// Reaction icon data
class ReactionIcon { class ReactionIcon {
final String type; /// Constructor for creating [ReactionIcon]
final String assetName;
ReactionIcon({ ReactionIcon({
required this.type, required this.type,
required this.assetName, required this.assetName,
}); });
/// Type of reaction
final String type;
/// Asset to display for reaction
final String assetName;
} }
@@ -3,23 +3,24 @@ import 'dart:math';
import 'package:ezanimation/ezanimation.dart'; import 'package:ezanimation/ezanimation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.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/src/extension.dart';
import '../stream_chat_flutter.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'extension.dart';
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/reaction_picker.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/reaction_picker.png)
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/reaction_picker_paint.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/reaction_picker_paint.png)
/// ///
/// It shows a reaction picker /// It shows a reaction picker
/// ///
/// Usually you don't use this widget as it's one of the default widgets used by [MessageWidget.onMessageActions]. /// Usually you don't use this widget as it's one of the default widgets used
/// by [MessageWidget.onMessageActions].
class ReactionPicker extends StatefulWidget { class ReactionPicker extends StatefulWidget {
/// Constructor for creating a [ReactionPicker] widget
const ReactionPicker({ const ReactionPicker({
Key? key, Key? key,
required this.message, required this.message,
}) : super(key: key); }) : super(key: key);
/// Message to attach the reaction to
final Message message; final Message message;
@override @override
@@ -39,7 +40,7 @@ class _ReactionPickerState extends State<ReactionPicker>
animations.add( animations.add(
EzAnimation.tween( EzAnimation.tween(
Tween(begin: 0.0, end: 1.0), Tween(begin: 0.0, end: 1.0),
Duration(milliseconds: 500), const Duration(milliseconds: 500),
curve: Curves.easeInOutBack, curve: Curves.easeInOutBack,
), ),
); );
@@ -51,9 +52,8 @@ class _ReactionPickerState extends State<ReactionPicker>
return TweenAnimationBuilder<double>( return TweenAnimationBuilder<double>(
tween: Tween(begin: 0, end: 1), tween: Tween(begin: 0, end: 1),
curve: Curves.easeInOutBack, curve: Curves.easeInOutBack,
duration: Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
builder: (context, val, wid) { builder: (context, val, wid) => Transform.scale(
return Transform.scale(
scale: val, scale: val,
child: Material( child: Material(
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
@@ -77,7 +77,7 @@ class _ReactionPickerState extends State<ReactionPicker>
final index = reactionIcons.indexOf(reactionIcon); final index = reactionIcons.indexOf(reactionIcon);
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
height: 24, height: 24,
width: 24, width: 24,
), ),
@@ -86,7 +86,7 @@ class _ReactionPickerState extends State<ReactionPicker>
shape: ContinuousRectangleBorder( shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
), ),
constraints: BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
height: 24, height: 24,
width: 24, width: 24,
), ),
@@ -94,8 +94,8 @@ class _ReactionPickerState extends State<ReactionPicker>
if (ownReactionIndex != -1) { if (ownReactionIndex != -1) {
removeReaction( removeReaction(
context, context,
widget widget.message
.message.ownReactions![ownReactionIndex], .ownReactions![ownReactionIndex],
); );
} else { } else {
sendReaction( sendReaction(
@@ -106,8 +106,7 @@ class _ReactionPickerState extends State<ReactionPicker>
}, },
child: AnimatedBuilder( child: AnimatedBuilder(
animation: animations[index], animation: animations[index],
builder: (context, val) { builder: (context, val) => Transform.scale(
return Transform.scale(
scale: animations[index].value, scale: animations[index].value,
child: StreamSvgIcon( child: StreamSvgIcon(
assetName: reactionIcon.assetName, assetName: reactionIcon.assetName,
@@ -128,31 +127,29 @@ class _ReactionPickerState extends State<ReactionPicker>
.color! .color!
.withOpacity(.5), .withOpacity(.5),
), ),
); )),
}),
), ),
); );
}) })
.insertBetween(SizedBox( .insertBetween(const SizedBox(
width: 16, width: 16,
)) ))
.toList(), .toList(),
), ),
), ),
), ),
); ));
});
} }
void triggerAnimations() async { void triggerAnimations() async {
for (var a in animations) { for (final a in animations) {
a.start(); a.start();
await Future.delayed(Duration(milliseconds: 100)); await Future.delayed(const Duration(milliseconds: 100));
} }
} }
void pop() async { void pop() async {
for (var a in animations) { for (final a in animations) {
a.stop(); a.stop();
} }
Navigator.of(context).pop(); Navigator.of(context).pop();
@@ -176,7 +173,7 @@ class _ReactionPickerState extends State<ReactionPicker>
@override @override
void dispose() { void dispose() {
for (var a in animations) { for (final a in animations) {
a.dispose(); a.dispose();
} }
super.dispose(); super.dispose();