Merge pull request #88 from GetStream/feature/createChannelInExample

Feature/create channel in example
This commit is contained in:
Deven Joshi
2020-09-24 15:06:10 +05:30
committed by GitHub
5 changed files with 217 additions and 15 deletions
+11 -9
View File
@@ -120,15 +120,17 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
stream: channel.lastMessageAtStream,
initialData: channel.lastMessageAt,
builder: (context, snapshot) {
return (snapshot.data != null)
? Text(
'Active ${Jiffy(snapshot.data.toLocal()).fromNow()}',
style: StreamChatTheme.of(context)
.channelTheme
.channelHeaderTheme
.lastMessageAt,
)
: SizedBox();
if (snapshot.data == null) {
return SizedBox();
}
final jiffyDate = Jiffy(snapshot.data?.toLocal());
return Text(
'Active ${jiffyDate.isBefore(Jiffy()) ? jiffyDate.fromNow() : 'now'}',
style: StreamChatTheme.of(context)
.channelTheme
.channelHeaderTheme
.lastMessageAt,
);
},
);
}
+1
View File
@@ -42,6 +42,7 @@ class ChannelName extends StatelessWidget {
return Text(
title,
style: textStyle,
overflow: TextOverflow.ellipsis,
);
},
);
+10 -5
View File
@@ -124,18 +124,23 @@ class ChannelsBlocState extends State<ChannelsBloc>
_subscriptions.add(client.on(EventType.messageNew).listen((e) {
final newChannels = List<Channel>.from(channels ?? []);
final index = newChannels.indexWhere((c) => c.cid == e.cid);
if (index > 0) {
final channel = newChannels.removeAt(index);
newChannels.insert(0, channel);
_channelsController.add(newChannels);
if (index > -1) {
if (index > 0) {
final channel = newChannels.removeAt(index);
newChannels.insert(0, channel);
}
} else {
final hiddenIndex = _hiddenChannels.indexWhere((c) => c.cid == e.cid);
if (hiddenIndex > -1) {
newChannels.insert(0, _hiddenChannels[hiddenIndex]);
_hiddenChannels.removeAt(hiddenIndex);
_channelsController.add(newChannels);
} else {
if (client.state.channels[e.cid] != null) {
newChannels.insert(0, client.state.channels[e.cid]);
}
}
}
_channelsController.add(newChannels);
}));
}