Merge pull request #459 from GetStream/feat/connectivity

feat: connectivity
This commit is contained in:
Salvatore Giordano
2021-05-28 09:43:43 +02:00
committed by GitHub
10 changed files with 277 additions and 27 deletions
@@ -4,7 +4,6 @@ import 'package:stream_chat_persistence/stream_chat_persistence.dart';
final chatPersistentClient = StreamChatPersistenceClient(
logLevel: Level.INFO,
connectionMode: ConnectionMode.background,
);
void main() async {
@@ -39,6 +39,7 @@ class StreamChat extends StatefulWidget {
this.streamChatThemeData,
this.onBackgroundEventReceived,
this.backgroundKeepAlive = const Duration(minutes: 1),
this.connectivityStream,
}) : super(key: key);
/// Client to do chat ops with
@@ -59,6 +60,11 @@ class StreamChat extends StatefulWidget {
/// upon the [Event.type]
final EventHandler? onBackgroundEventReceived;
/// Stream of connectivity result
/// Visible for testing
@visibleForTesting
final Stream<ConnectivityResult>? connectivityStream;
@override
StreamChatState createState() => StreamChatState();
@@ -102,6 +108,7 @@ class StreamChatState extends State<StreamChat> {
client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive,
connectivityStream: widget.connectivityStream,
child: widget.child ?? const Offstage(),
),
);
@@ -79,6 +79,7 @@ void main() {
),
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
),
surfaceSize: const Size.square(200),
@@ -131,6 +132,7 @@ void main() {
),
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
),
surfaceSize: const Size.square(200),
@@ -187,6 +189,7 @@ void main() {
),
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
),
surfaceSize: const Size.square(200),
@@ -60,6 +60,7 @@ void main() {
maskColor: theme.ownMessageTheme.reactionsMaskColor!,
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
surfaceSize: const Size(100, 100),
);
@@ -96,6 +97,7 @@ void main() {
maskColor: theme.ownMessageTheme.reactionsMaskColor!,
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
surfaceSize: const Size(100, 100),
);
@@ -118,6 +120,7 @@ void main() {
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
child: Container(
color: Colors.black,
child: ReactionBubble(
@@ -162,6 +165,7 @@ void main() {
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
child: Container(
color: Colors.black,
child: ReactionBubble(
@@ -204,6 +208,7 @@ void main() {
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
child: SizedBox(
child: ReactionBubble(
@@ -100,6 +100,7 @@ void main() {
),
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
),
surfaceSize: const Size.square(200),
@@ -151,6 +152,7 @@ void main() {
),
),
),
connectivityStream: Stream.value(ConnectivityResult.mobile),
),
),
surfaceSize: const Size.square(200),