This commit is contained in:
Deven Joshi
2021-05-05 16:38:05 +05:30
parent 645d21503a
commit d55b937364
2 changed files with 33 additions and 21 deletions
@@ -3,10 +3,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// Used to show the sending status of the message /// Used to show the sending status of the message
class SendingIndicator extends StatelessWidget { class SendingIndicator extends StatelessWidget {
final Message message; /// Constructor for creating a [SendingIndicator] widget
final bool isMessageRead;
final double? size;
const SendingIndicator({ const SendingIndicator({
Key? key, Key? key,
required this.message, required this.message,
@@ -14,6 +11,15 @@ class SendingIndicator extends StatelessWidget {
this.size = 12, this.size = 12,
}) : super(key: key); }) : super(key: key);
/// Message for sending indicator
final Message message;
/// Flag if message is read
final bool isMessageRead;
/// Size for message
final double? size;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (isMessageRead) { if (isMessageRead) {
@@ -35,6 +41,6 @@ class SendingIndicator extends StatelessWidget {
size: size, size: size,
); );
} }
return SizedBox(); return const SizedBox();
} }
} }
@@ -31,18 +31,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
/// ///
/// Use [StreamChat.of] to get the current [StreamChatState] instance. /// Use [StreamChat.of] to get the current [StreamChatState] instance.
class StreamChat extends StatefulWidget { class StreamChat extends StatefulWidget {
final StreamChatClient client; /// Constructor for creating a [StreamChat] widget
final Widget? child;
final StreamChatThemeData? streamChatThemeData;
/// The amount of time that will pass before disconnecting the client in the background
final Duration backgroundKeepAlive;
/// Handler called whenever the [client] receives a new [Event] while the app
/// is in background. Can be used to display various notifications depending
/// upon the [Event.type]
final EventHandler? onBackgroundEventReceived;
const StreamChat({ const StreamChat({
Key? key, Key? key,
required this.client, required this.client,
@@ -50,9 +39,25 @@ class StreamChat extends StatefulWidget {
this.streamChatThemeData, this.streamChatThemeData,
this.onBackgroundEventReceived, this.onBackgroundEventReceived,
this.backgroundKeepAlive = const Duration(minutes: 1), this.backgroundKeepAlive = const Duration(minutes: 1),
}) : super( }) : super(key: key);
key: key,
); /// Client to do chat ops with
final StreamChatClient client;
/// Child which inherits details
final Widget? child;
/// Theme to pass on
final StreamChatThemeData? streamChatThemeData;
/// The amount of time that will pass before disconnecting the client
/// in the background
final Duration backgroundKeepAlive;
/// Handler called whenever the [client] receives a new [Event] while the app
/// is in background. Can be used to display various notifications depending
/// upon the [Event.type]
final EventHandler? onBackgroundEventReceived;
@override @override
StreamChatState createState() => StreamChatState(); StreamChatState createState() => StreamChatState();
@@ -74,6 +79,7 @@ class StreamChat extends StatefulWidget {
/// The current state of the StreamChat widget /// The current state of the StreamChat widget
class StreamChatState extends State<StreamChat> { class StreamChatState extends State<StreamChat> {
/// Gets client from widget
StreamChatClient get client => widget.client; StreamChatClient get client => widget.client;
@override @override
@@ -96,7 +102,7 @@ class StreamChatState extends State<StreamChat> {
client: client, client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived, onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive, backgroundKeepAlive: widget.backgroundKeepAlive,
child: widget.child ?? Offstage(), child: widget.child ?? const Offstage(),
), ),
); );
}, },