Merge branches 'feature/new-ui' and 'qa/new-chat-screens' of github.com:GetStream/stream-chat-flutter into qa/new-chat-screens
Conflicts: example/lib/new_group_chat_screen.dart
This commit is contained in:
@@ -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<AdvancedOptionsPage> {
|
||||
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) {
|
||||
|
||||
@@ -133,7 +133,7 @@ class ChooseUserPage extends StatelessWidget {
|
||||
|
||||
final secureStorage = FlutterSecureStorage();
|
||||
final client = StreamChat.of(context).client;
|
||||
|
||||
client.apiKey = kDefaultStreamApiKey;
|
||||
await client.setUser(
|
||||
user,
|
||||
token,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: example
|
||||
description: A new Flutter project.
|
||||
version: 1.0.72+74
|
||||
version: 1.0.75+77
|
||||
|
||||
environment:
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
+45
-45
@@ -17,8 +17,34 @@ class ChannelInfo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final client = StreamChat.of(context).client;
|
||||
return StreamBuilder<List<Member>>(
|
||||
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<Member> 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<List<Member>>(
|
||||
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<Member> 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class ChannelPreview extends StatelessWidget {
|
||||
.isAfter(channel
|
||||
.state.lastMessage.createdAt))
|
||||
.length ==
|
||||
(channel.memberCount ?? 0) - 1,
|
||||
(channel.memberCount ?? 0),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -426,12 +426,13 @@ class _MessageWidgetState extends State<MessageWidget> {
|
||||
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,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user