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 'main.dart';
|
||||||
import 'notifications_service.dart';
|
import 'notifications_service.dart';
|
||||||
|
import 'choose_user_page.dart';
|
||||||
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
|
||||||
class AdvancedOptionsPage extends StatefulWidget {
|
class AdvancedOptionsPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@@ -285,6 +287,20 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
|
|||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
initNotifications(client);
|
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) {
|
} catch (e) {
|
||||||
var errorText = 'Error connecting, retry';
|
var errorText = 'Error connecting, retry';
|
||||||
if (e is Map) {
|
if (e is Map) {
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class ChooseUserPage extends StatelessWidget {
|
|||||||
|
|
||||||
final secureStorage = FlutterSecureStorage();
|
final secureStorage = FlutterSecureStorage();
|
||||||
final client = StreamChat.of(context).client;
|
final client = StreamChat.of(context).client;
|
||||||
|
client.apiKey = kDefaultStreamApiKey;
|
||||||
await client.setUser(
|
await client.setUser(
|
||||||
user,
|
user,
|
||||||
token,
|
token,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: example
|
name: example
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
version: 1.0.72+74
|
version: 1.0.75+77
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.2.2 <3.0.0"
|
||||||
|
|||||||
+45
-45
@@ -17,8 +17,34 @@ class ChannelInfo extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final client = StreamChat.of(context).client;
|
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) {
|
if (channel.memberCount != null && channel.memberCount > 2) {
|
||||||
return Text(
|
alternativeWidget = Text(
|
||||||
'${channel.memberCount} Members, ${channel.state.watcherCount} Online',
|
'${channel.memberCount} Members, ${channel.state.watcherCount} Online',
|
||||||
style: StreamChatTheme.of(context)
|
style: StreamChatTheme.of(context)
|
||||||
.channelTheme
|
.channelTheme
|
||||||
@@ -26,52 +52,26 @@ class ChannelInfo extends StatelessWidget {
|
|||||||
.lastMessageAt,
|
.lastMessageAt,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return StreamBuilder<List<Member>>(
|
final otherMember = members.firstWhere(
|
||||||
stream: channel.state.membersStream,
|
(element) => element.userId != StreamChat.of(context).user.id,
|
||||||
initialData: channel.state.members,
|
orElse: () => null,
|
||||||
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) {
|
if (otherMember != null) {
|
||||||
var alternativeWidget;
|
if (otherMember.user.online) {
|
||||||
|
alternativeWidget = Text(
|
||||||
final otherMember = members.firstWhere(
|
'Online',
|
||||||
(element) => element.userId != StreamChat.of(context).user.id,
|
style: StreamChatTheme.of(context)
|
||||||
orElse: () => null,
|
.channelTheme
|
||||||
);
|
.channelHeaderTheme
|
||||||
|
.lastMessageAt,
|
||||||
if (otherMember != null) {
|
);
|
||||||
if (otherMember.user.online) {
|
} else {
|
||||||
alternativeWidget = Text(
|
alternativeWidget = Text(
|
||||||
'Online',
|
'Last seen ${Jiffy(otherMember.user.lastActive).fromNow()}',
|
||||||
style: StreamChatTheme.of(context)
|
style: textStyle,
|
||||||
.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
|
.isAfter(channel
|
||||||
.state.lastMessage.createdAt))
|
.state.lastMessage.createdAt))
|
||||||
.length ==
|
.length ==
|
||||||
(channel.memberCount ?? 0) - 1,
|
(channel.memberCount ?? 0),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -426,12 +426,13 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
top: 0,
|
top: 0,
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
shape: CircleBorder(),
|
shape: CircleBorder(),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(1.0),
|
padding: const EdgeInsets.all(1.0),
|
||||||
child: UserAvatar(
|
child: UserAvatar(
|
||||||
user: e.user,
|
user: e.user,
|
||||||
constraints: BoxConstraints.loose(Size.fromRadius(16)),
|
constraints: BoxConstraints.loose(Size.fromRadius(8)),
|
||||||
showOnlineStatus: false,
|
showOnlineStatus: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class StreamSvgIcon extends StatelessWidget {
|
|||||||
height: height,
|
height: height,
|
||||||
key: key,
|
key: key,
|
||||||
color: color,
|
color: color,
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
)
|
)
|
||||||
: SvgPicture.asset(
|
: SvgPicture.asset(
|
||||||
@@ -35,7 +34,6 @@ class StreamSvgIcon extends StatelessWidget {
|
|||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
color: color,
|
color: color,
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
? AspectRatio(
|
? AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: onBackPressed,
|
onPressed: onBackPressed ?? () => Navigator.pop(context),
|
||||||
icon: StreamSvgIcon.close(
|
icon: StreamSvgIcon.close(
|
||||||
size: 24,
|
size: 24,
|
||||||
color: Theme.of(context).brightness == Brightness.dark
|
color: Theme.of(context).brightness == Brightness.dark
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class UserAvatar extends StatelessWidget {
|
|||||||
final streamChatTheme = StreamChatTheme.of(context);
|
final streamChatTheme = StreamChatTheme.of(context);
|
||||||
|
|
||||||
Widget avatar = ClipRRect(
|
Widget avatar = ClipRRect(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
borderRadius: borderRadius ??
|
borderRadius: borderRadius ??
|
||||||
streamChatTheme.ownMessageTheme.avatarTheme.borderRadius,
|
streamChatTheme.ownMessageTheme.avatarTheme.borderRadius,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|||||||
Reference in New Issue
Block a user