From 9fd7a6a7f81275ef4d7a0fae1901516d6f18f873 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 12:15:25 +0100 Subject: [PATCH 1/5] update channel info fro groups --- lib/src/channel_info.dart | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/lib/src/channel_info.dart b/lib/src/channel_info.dart index 2aa1b2cd..402dd73f 100644 --- a/lib/src/channel_info.dart +++ b/lib/src/channel_info.dart @@ -17,8 +17,34 @@ class ChannelInfo extends StatelessWidget { @override Widget build(BuildContext context) { final client = StreamChat.of(context).client; + return StreamBuilder>( + stream: channel.state.membersStream, + initialData: channel.state.members, + builder: (context, snapshot) { + return ValueListenableBuilder( + valueListenable: client.wsConnectionStatus, + builder: (context, status, child) { + switch (status) { + case ConnectionStatus.connected: + return _buildConnectedTitleState(context, snapshot.data); + case ConnectionStatus.connecting: + return _buildConnectingTitleState(context); + case ConnectionStatus.disconnected: + return _buildDisconnectedTitleState(context, client); + default: + return Offstage(); + } + }, + ); + }, + ); + } + + Widget _buildConnectedTitleState(BuildContext context, List members) { + var alternativeWidget; + if (channel.memberCount != null && channel.memberCount > 2) { - return Text( + alternativeWidget = Text( '${channel.memberCount} Members, ${channel.state.watcherCount} Online', style: StreamChatTheme.of(context) .channelTheme @@ -26,52 +52,26 @@ class ChannelInfo extends StatelessWidget { .lastMessageAt, ); } else { - return StreamBuilder>( - stream: channel.state.membersStream, - initialData: channel.state.members, - builder: (context, snapshot) { - return ValueListenableBuilder( - valueListenable: client.wsConnectionStatus, - builder: (context, status, child) { - switch (status) { - case ConnectionStatus.connected: - return _buildConnectedTitleState(context, snapshot.data); - case ConnectionStatus.connecting: - return _buildConnectingTitleState(context); - case ConnectionStatus.disconnected: - return _buildDisconnectedTitleState(context, client); - default: - return Offstage(); - } - }, - ); - }, + final otherMember = members.firstWhere( + (element) => element.userId != StreamChat.of(context).user.id, + orElse: () => null, ); - } - } - Widget _buildConnectedTitleState(BuildContext context, List members) { - var alternativeWidget; - - final otherMember = members.firstWhere( - (element) => element.userId != StreamChat.of(context).user.id, - orElse: () => null, - ); - - if (otherMember != null) { - if (otherMember.user.online) { - alternativeWidget = Text( - 'Online', - style: StreamChatTheme.of(context) - .channelTheme - .channelHeaderTheme - .lastMessageAt, - ); - } else { - alternativeWidget = Text( - 'Last seen ${Jiffy(otherMember.user.lastActive).fromNow()}', - style: textStyle, - ); + if (otherMember != null) { + if (otherMember.user.online) { + alternativeWidget = Text( + 'Online', + style: StreamChatTheme.of(context) + .channelTheme + .channelHeaderTheme + .lastMessageAt, + ); + } else { + alternativeWidget = Text( + 'Last seen ${Jiffy(otherMember.user.lastActive).fromNow()}', + style: textStyle, + ); + } } } From d59e89c700de55b21907897a4bef77dbcae33d10 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 12:50:46 +0100 Subject: [PATCH 2/5] fix thread back button behaviour --- lib/src/thread_header.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/thread_header.dart b/lib/src/thread_header.dart index c6cce13e..aa14cb61 100644 --- a/lib/src/thread_header.dart +++ b/lib/src/thread_header.dart @@ -85,7 +85,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget { ? AspectRatio( aspectRatio: 1, child: IconButton( - onPressed: onBackPressed, + onPressed: onBackPressed ?? () => Navigator.pop(context), icon: StreamSvgIcon.close( size: 24, color: Theme.of(context).brightness == Brightness.dark From 58b079abbad26b569a13eef3ab7c7fe005e4596f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 15:29:08 +0100 Subject: [PATCH 3/5] fix svgs icons --- example/lib/new_group_chat_screen.dart | 18 +++++++++++++++--- example/pubspec.yaml | 2 +- lib/src/stream_svg_icon.dart | 2 -- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/example/lib/new_group_chat_screen.dart b/example/lib/new_group_chat_screen.dart index a11767c3..8361c895 100644 --- a/example/lib/new_group_chat_screen.dart +++ b/example/lib/new_group_chat_screen.dart @@ -100,9 +100,21 @@ class _NewGroupChatScreenState extends State { child: TextField( controller: _controller, decoration: InputDecoration( - prefixIcon: StreamSvgIcon.search( - color: Colors.black, - size: 24, + prefixIconConstraints: BoxConstraints.tight( + Size( + 40, + 24, + ), + ), + prefixIcon: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + ), + child: StreamSvgIcon.search( + color: Colors.black, + size: 24, + ), ), hintText: 'Search', hintStyle: TextStyle( diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 43eb867e..491dbbb7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.72+74 +version: 1.0.73+75 environment: sdk: ">=2.2.2 <3.0.0" diff --git a/lib/src/stream_svg_icon.dart b/lib/src/stream_svg_icon.dart index 19daca34..2851df3a 100644 --- a/lib/src/stream_svg_icon.dart +++ b/lib/src/stream_svg_icon.dart @@ -25,7 +25,6 @@ class StreamSvgIcon extends StatelessWidget { height: height, key: key, color: color, - fit: BoxFit.scaleDown, alignment: Alignment.center, ) : SvgPicture.asset( @@ -35,7 +34,6 @@ class StreamSvgIcon extends StatelessWidget { width: width, height: height, color: color, - fit: BoxFit.scaleDown, alignment: Alignment.center, ); } From 3c9072e81c6d06fec23430963b38d6024375ccee Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 15:50:00 +0100 Subject: [PATCH 4/5] save config for advanced options --- example/lib/advanced_options_page.dart | 16 ++++++++++++++++ example/pubspec.yaml | 2 +- lib/src/channel_preview.dart | 2 +- lib/src/message_widget.dart | 3 ++- lib/src/user_avatar.dart | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/example/lib/advanced_options_page.dart b/example/lib/advanced_options_page.dart index 212a15a8..e07afefd 100644 --- a/example/lib/advanced_options_page.dart +++ b/example/lib/advanced_options_page.dart @@ -7,6 +7,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'main.dart'; import 'notifications_service.dart'; +import 'choose_user_page.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class AdvancedOptionsPage extends StatefulWidget { @override @@ -285,6 +287,20 @@ class _AdvancedOptionsPageState extends State { if (!kIsWeb) { initNotifications(client); } + + final secureStorage = FlutterSecureStorage(); + secureStorage.write( + key: kStreamApiKey, + value: apiKey, + ); + secureStorage.write( + key: kStreamUserId, + value: userId, + ); + secureStorage.write( + key: kStreamToken, + value: userToken, + ); } catch (e) { var errorText = 'Error connecting, retry'; if (e is Map) { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 491dbbb7..7c76b15f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.73+75 +version: 1.0.74+76 environment: sdk: ">=2.2.2 <3.0.0" diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 3c9eeace..26f68812 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -104,7 +104,7 @@ class ChannelPreview extends StatelessWidget { .isAfter(channel .state.lastMessage.createdAt)) .length == - (channel.memberCount ?? 0) - 1, + (channel.memberCount ?? 0), ), ); } diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 86479ebe..280de349 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -426,12 +426,13 @@ class _MessageWidgetState extends State { top: 0, child: Material( color: Colors.white, + clipBehavior: Clip.antiAlias, shape: CircleBorder(), child: Padding( padding: const EdgeInsets.all(1.0), child: UserAvatar( user: e.user, - constraints: BoxConstraints.loose(Size.fromRadius(16)), + constraints: BoxConstraints.loose(Size.fromRadius(8)), showOnlineStatus: false, ), ), diff --git a/lib/src/user_avatar.dart b/lib/src/user_avatar.dart index 2e1f3e0e..756252cc 100644 --- a/lib/src/user_avatar.dart +++ b/lib/src/user_avatar.dart @@ -40,6 +40,7 @@ class UserAvatar extends StatelessWidget { final streamChatTheme = StreamChatTheme.of(context); Widget avatar = ClipRRect( + clipBehavior: Clip.antiAlias, borderRadius: borderRadius ?? streamChatTheme.ownMessageTheme.avatarTheme.borderRadius, child: Container( From e936b828be3b73116fdcc69764d13371e06abdca Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 25 Nov 2020 15:52:32 +0100 Subject: [PATCH 5/5] fix api keyy --- example/lib/choose_user_page.dart | 2 +- example/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/lib/choose_user_page.dart b/example/lib/choose_user_page.dart index f1a53773..48b66b2d 100644 --- a/example/lib/choose_user_page.dart +++ b/example/lib/choose_user_page.dart @@ -132,7 +132,7 @@ class ChooseUserPage extends StatelessWidget { final secureStorage = FlutterSecureStorage(); final client = StreamChat.of(context).client; - + client.apiKey = kDefaultStreamApiKey; await client.setUser( user, token, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7c76b15f..02c2c726 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.74+76 +version: 1.0.75+77 environment: sdk: ">=2.2.2 <3.0.0"