@@ -1,6 +1,8 @@
|
|||||||
// ignore_for_file: public_member_api_docs
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:math' as math;
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:responsive_builder/responsive_builder.dart';
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
@@ -277,19 +279,84 @@ class _ChannelPageState extends State<ChannelPage> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: StreamMessageListView(
|
child: StreamMessageListView(
|
||||||
onMessageSwiped:
|
|
||||||
(CurrentPlatform.isAndroid || CurrentPlatform.isIos)
|
|
||||||
? reply
|
|
||||||
: null,
|
|
||||||
threadBuilder: (context, parent) {
|
threadBuilder: (context, parent) {
|
||||||
return ThreadPage(
|
return ThreadPage(
|
||||||
parent: parent!,
|
parent: parent!,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
messageBuilder:
|
messageBuilder: (
|
||||||
(context, details, messages, defaultWidget) {
|
context,
|
||||||
return defaultWidget.copyWith(
|
messageDetails,
|
||||||
onReplyTap: reply,
|
messages,
|
||||||
|
defaultWidget,
|
||||||
|
) {
|
||||||
|
// The threshold after which the message is considered
|
||||||
|
// swiped.
|
||||||
|
const threshold = 0.2;
|
||||||
|
|
||||||
|
final isMyMessage = messageDetails.isMyMessage;
|
||||||
|
|
||||||
|
// The direction in which the message can be swiped.
|
||||||
|
final swipeDirection = isMyMessage
|
||||||
|
? SwipeDirection.endToStart //
|
||||||
|
: SwipeDirection.startToEnd;
|
||||||
|
|
||||||
|
return Swipeable(
|
||||||
|
key: ValueKey(messageDetails.message.id),
|
||||||
|
direction: swipeDirection,
|
||||||
|
swipeThreshold: threshold,
|
||||||
|
onSwiped: (details) => reply(messageDetails.message),
|
||||||
|
backgroundBuilder: (context, details) {
|
||||||
|
// The alignment of the swipe action.
|
||||||
|
final alignment = isMyMessage
|
||||||
|
? Alignment.centerRight //
|
||||||
|
: Alignment.centerLeft;
|
||||||
|
|
||||||
|
// The progress of the swipe action.
|
||||||
|
final progress =
|
||||||
|
math.min(details.progress, threshold) / threshold;
|
||||||
|
|
||||||
|
// The offset for the reply icon.
|
||||||
|
var offset = Offset.lerp(
|
||||||
|
const Offset(-24, 0),
|
||||||
|
const Offset(12, 0),
|
||||||
|
progress,
|
||||||
|
)!;
|
||||||
|
|
||||||
|
// If the message is mine, we need to flip the offset.
|
||||||
|
if (isMyMessage) {
|
||||||
|
offset = Offset(-offset.dx, -offset.dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
final _streamTheme = StreamChatTheme.of(context);
|
||||||
|
|
||||||
|
return Align(
|
||||||
|
alignment: alignment,
|
||||||
|
child: Transform.translate(
|
||||||
|
offset: offset,
|
||||||
|
child: Opacity(
|
||||||
|
opacity: progress,
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: 30,
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: AnimatedCircleBorderPainter(
|
||||||
|
progress: progress,
|
||||||
|
color: _streamTheme.colorTheme.borders,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: StreamSvgIcon.reply(
|
||||||
|
size: lerpDouble(0, 18, progress),
|
||||||
|
color: _streamTheme
|
||||||
|
.colorTheme.accentPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: defaultWidget.copyWith(onReplyTap: reply),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import 'package:stream_chat_flutter/src/message_list_view/loading_indicator.dart
|
|||||||
import 'package:stream_chat_flutter/src/message_list_view/mlv_utils.dart';
|
import 'package:stream_chat_flutter/src/message_list_view/mlv_utils.dart';
|
||||||
import 'package:stream_chat_flutter/src/message_list_view/thread_separator.dart';
|
import 'package:stream_chat_flutter/src/message_list_view/thread_separator.dart';
|
||||||
import 'package:stream_chat_flutter/src/message_list_view/unread_messages_separator.dart';
|
import 'package:stream_chat_flutter/src/message_list_view/unread_messages_separator.dart';
|
||||||
import 'package:stream_chat_flutter/src/misc/animated_circle_border_painter.dart';
|
|
||||||
import 'package:stream_chat_flutter/src/misc/swipeable.dart';
|
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
/// Spacing Types (These are properties of a message to help inform the decision
|
/// Spacing Types (These are properties of a message to help inform the decision
|
||||||
|
|||||||
Reference in New Issue
Block a user