mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 13:09:24 +01:00
Merge branch 'krille/use-stream-builder' into 'master'
Krille/use stream builder See merge request ChristianPauly/fluffychat-flutter!40
This commit is contained in:
commit
facf1f87a9
@ -1,4 +1,3 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
@ -131,14 +130,6 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||||||
if (participants != null) setState(() => members = participants);
|
if (participants != null) setState(() => members = participants);
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscription onUpdate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
onUpdate?.cancel();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.room == null) {
|
if (widget.room == null) {
|
||||||
@ -156,293 +147,313 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||||||
final int actualMembersCount =
|
final int actualMembersCount =
|
||||||
widget.room.mInvitedMemberCount + widget.room.mJoinedMemberCount;
|
widget.room.mInvitedMemberCount + widget.room.mJoinedMemberCount;
|
||||||
final bool canRequestMoreMembers = members.length < actualMembersCount;
|
final bool canRequestMoreMembers = members.length < actualMembersCount;
|
||||||
this.onUpdate ??= widget.room.onUpdate.stream
|
|
||||||
.listen((id) => setState(() => members = null));
|
|
||||||
return AdaptivePageLayout(
|
return AdaptivePageLayout(
|
||||||
primaryPage: FocusPage.SECOND,
|
primaryPage: FocusPage.SECOND,
|
||||||
firstScaffold: ChatList(
|
firstScaffold: ChatList(
|
||||||
activeChat: widget.room.id,
|
activeChat: widget.room.id,
|
||||||
),
|
),
|
||||||
secondScaffold: Scaffold(
|
secondScaffold: StreamBuilder(
|
||||||
body: NestedScrollView(
|
stream: widget.room.onUpdate.stream,
|
||||||
headerSliverBuilder:
|
builder: (context, snapshot) {
|
||||||
(BuildContext context, bool innerBoxIsScrolled) => <Widget>[
|
return Scaffold(
|
||||||
SliverAppBar(
|
body: NestedScrollView(
|
||||||
expandedHeight: 300.0,
|
headerSliverBuilder:
|
||||||
floating: true,
|
(BuildContext context, bool innerBoxIsScrolled) => <Widget>[
|
||||||
pinned: true,
|
SliverAppBar(
|
||||||
actions: <Widget>[
|
expandedHeight: 300.0,
|
||||||
if (widget.room.canonicalAlias?.isNotEmpty ?? false)
|
floating: true,
|
||||||
IconButton(
|
pinned: true,
|
||||||
icon: Icon(Icons.share),
|
actions: <Widget>[
|
||||||
onPressed: () {
|
if (widget.room.canonicalAlias?.isNotEmpty ?? false)
|
||||||
Clipboard.setData(
|
IconButton(
|
||||||
ClipboardData(text: widget.room.canonicalAlias),
|
icon: Icon(Icons.share),
|
||||||
);
|
onPressed: () {
|
||||||
showToast(L10n.of(context).copiedToClipboard);
|
Clipboard.setData(
|
||||||
},
|
ClipboardData(text: widget.room.canonicalAlias),
|
||||||
|
);
|
||||||
|
showToast(L10n.of(context).copiedToClipboard);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ChatSettingsPopupMenu(widget.room, false)
|
||||||
|
],
|
||||||
|
title: Text(
|
||||||
|
widget.room.getLocalizedDisplayname(L10n.of(context)),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.appBarTheme
|
||||||
|
.textTheme
|
||||||
|
.headline6
|
||||||
|
.color)),
|
||||||
|
backgroundColor: Theme.of(context).appBarTheme.color,
|
||||||
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
|
background: ContentBanner(widget.room.avatar,
|
||||||
|
onEdit: widget.room.canSendEvent("m.room.avatar") &&
|
||||||
|
!kIsWeb
|
||||||
|
? () => setAvatarAction(context)
|
||||||
|
: null),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
ChatSettingsPopupMenu(widget.room, false)
|
],
|
||||||
],
|
body: ListView.builder(
|
||||||
title: Text(widget.room.getLocalizedDisplayname(L10n.of(context)),
|
itemCount:
|
||||||
style: TextStyle(
|
members.length + 1 + (canRequestMoreMembers ? 1 : 0),
|
||||||
color: Theme.of(context)
|
itemBuilder: (BuildContext context, int i) => i == 0
|
||||||
.appBarTheme
|
? Column(
|
||||||
.textTheme
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
.headline6
|
children: <Widget>[
|
||||||
.color)),
|
ListTile(
|
||||||
backgroundColor: Theme.of(context).appBarTheme.color,
|
leading: widget.room.canSendEvent("m.room.topic")
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
? CircleAvatar(
|
||||||
background: ContentBanner(widget.room.avatar,
|
backgroundColor: Theme.of(context)
|
||||||
onEdit: widget.room.canSendEvent("m.room.avatar") && !kIsWeb
|
.scaffoldBackgroundColor,
|
||||||
? () => setAvatarAction(context)
|
foregroundColor: Colors.grey,
|
||||||
: null),
|
child: Icon(Icons.edit),
|
||||||
),
|
)
|
||||||
),
|
: null,
|
||||||
],
|
title: Text(
|
||||||
body: ListView.builder(
|
"${L10n.of(context).groupDescription}:",
|
||||||
itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0),
|
style: TextStyle(
|
||||||
itemBuilder: (BuildContext context, int i) => i == 0
|
color: Theme.of(context).primaryColor,
|
||||||
? Column(
|
fontWeight: FontWeight.bold)),
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
subtitle: LinkText(
|
||||||
children: <Widget>[
|
text: widget.room.topic?.isEmpty ?? true
|
||||||
ListTile(
|
? L10n.of(context).addGroupDescription
|
||||||
leading: widget.room.canSendEvent("m.room.topic")
|
: widget.room.topic,
|
||||||
? CircleAvatar(
|
linkStyle: TextStyle(color: Colors.blueAccent),
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyText2
|
||||||
|
.color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: widget.room.canSendEvent("m.room.topic")
|
||||||
|
? () => setTopicAction(context)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
Divider(thickness: 1),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
L10n.of(context).settings,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.room.canSendEvent("m.room.name"))
|
||||||
|
ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
foregroundColor: Colors.grey,
|
||||||
|
child: Icon(Icons.people),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
L10n.of(context).changeTheNameOfTheGroup),
|
||||||
|
subtitle: Text(widget.room
|
||||||
|
.getLocalizedDisplayname(L10n.of(context))),
|
||||||
|
onTap: () => setDisplaynameAction(context),
|
||||||
|
),
|
||||||
|
if (widget.room
|
||||||
|
.canSendEvent("m.room.canonical_alias") &&
|
||||||
|
widget.room.joinRules == JoinRules.public)
|
||||||
|
ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
foregroundColor: Colors.grey,
|
||||||
|
child: Icon(Icons.link),
|
||||||
|
),
|
||||||
|
onTap: () => setCanonicalAliasAction(context),
|
||||||
|
title: Text(L10n.of(context).setInvitationLink),
|
||||||
|
subtitle: Text(
|
||||||
|
(widget.room.canonicalAlias?.isNotEmpty ??
|
||||||
|
false)
|
||||||
|
? widget.room.canonicalAlias
|
||||||
|
: L10n.of(context).none),
|
||||||
|
),
|
||||||
|
PopupMenuButton(
|
||||||
|
child: ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: Theme.of(context)
|
||||||
|
.scaffoldBackgroundColor,
|
||||||
|
foregroundColor: Colors.grey,
|
||||||
|
child: Icon(Icons.public)),
|
||||||
|
title: Text(L10n.of(context)
|
||||||
|
.whoIsAllowedToJoinThisGroup),
|
||||||
|
subtitle: Text(
|
||||||
|
widget.room.joinRules
|
||||||
|
.getLocalizedString(L10n.of(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSelected: (JoinRules joinRule) =>
|
||||||
|
SimpleDialogs(context)
|
||||||
|
.tryRequestWithLoadingDialog(
|
||||||
|
widget.room.setJoinRules(joinRule),
|
||||||
|
),
|
||||||
|
itemBuilder: (BuildContext context) =>
|
||||||
|
<PopupMenuEntry<JoinRules>>[
|
||||||
|
if (widget.room.canChangeJoinRules)
|
||||||
|
PopupMenuItem<JoinRules>(
|
||||||
|
value: JoinRules.public,
|
||||||
|
child: Text(JoinRules.public
|
||||||
|
.getLocalizedString(L10n.of(context))),
|
||||||
|
),
|
||||||
|
if (widget.room.canChangeJoinRules)
|
||||||
|
PopupMenuItem<JoinRules>(
|
||||||
|
value: JoinRules.invite,
|
||||||
|
child: Text(JoinRules.invite
|
||||||
|
.getLocalizedString(L10n.of(context))),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
PopupMenuButton(
|
||||||
|
child: ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
foregroundColor: Colors.grey,
|
||||||
|
child: Icon(Icons.visibility),
|
||||||
|
),
|
||||||
|
title: Text(L10n.of(context)
|
||||||
|
.visibilityOfTheChatHistory),
|
||||||
|
subtitle: Text(
|
||||||
|
widget.room.historyVisibility
|
||||||
|
.getLocalizedString(L10n.of(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSelected:
|
||||||
|
(HistoryVisibility historyVisibility) =>
|
||||||
|
SimpleDialogs(context)
|
||||||
|
.tryRequestWithLoadingDialog(
|
||||||
|
widget.room
|
||||||
|
.setHistoryVisibility(historyVisibility),
|
||||||
|
),
|
||||||
|
itemBuilder: (BuildContext context) =>
|
||||||
|
<PopupMenuEntry<HistoryVisibility>>[
|
||||||
|
if (widget.room.canChangeHistoryVisibility)
|
||||||
|
PopupMenuItem<HistoryVisibility>(
|
||||||
|
value: HistoryVisibility.invited,
|
||||||
|
child: Text(HistoryVisibility.invited
|
||||||
|
.getLocalizedString(L10n.of(context))),
|
||||||
|
),
|
||||||
|
if (widget.room.canChangeHistoryVisibility)
|
||||||
|
PopupMenuItem<HistoryVisibility>(
|
||||||
|
value: HistoryVisibility.joined,
|
||||||
|
child: Text(HistoryVisibility.joined
|
||||||
|
.getLocalizedString(L10n.of(context))),
|
||||||
|
),
|
||||||
|
if (widget.room.canChangeHistoryVisibility)
|
||||||
|
PopupMenuItem<HistoryVisibility>(
|
||||||
|
value: HistoryVisibility.shared,
|
||||||
|
child: Text(HistoryVisibility.shared
|
||||||
|
.getLocalizedString(L10n.of(context))),
|
||||||
|
),
|
||||||
|
if (widget.room.canChangeHistoryVisibility)
|
||||||
|
PopupMenuItem<HistoryVisibility>(
|
||||||
|
value: HistoryVisibility.world_readable,
|
||||||
|
child: Text(HistoryVisibility.world_readable
|
||||||
|
.getLocalizedString(L10n.of(context))),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (widget.room.joinRules == JoinRules.public)
|
||||||
|
PopupMenuButton(
|
||||||
|
child: ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: Theme.of(context)
|
||||||
|
.scaffoldBackgroundColor,
|
||||||
|
foregroundColor: Colors.grey,
|
||||||
|
child: Icon(Icons.info_outline),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
L10n.of(context).areGuestsAllowedToJoin),
|
||||||
|
subtitle: Text(
|
||||||
|
widget.room.guestAccess
|
||||||
|
.getLocalizedString(L10n.of(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSelected: (GuestAccess guestAccess) =>
|
||||||
|
SimpleDialogs(context)
|
||||||
|
.tryRequestWithLoadingDialog(
|
||||||
|
widget.room.setGuestAccess(guestAccess),
|
||||||
|
),
|
||||||
|
itemBuilder: (BuildContext context) =>
|
||||||
|
<PopupMenuEntry<GuestAccess>>[
|
||||||
|
if (widget.room.canChangeGuestAccess)
|
||||||
|
PopupMenuItem<GuestAccess>(
|
||||||
|
value: GuestAccess.can_join,
|
||||||
|
child: Text(
|
||||||
|
GuestAccess.can_join.getLocalizedString(
|
||||||
|
L10n.of(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.room.canChangeGuestAccess)
|
||||||
|
PopupMenuItem<GuestAccess>(
|
||||||
|
value: GuestAccess.forbidden,
|
||||||
|
child: Text(
|
||||||
|
GuestAccess.forbidden
|
||||||
|
.getLocalizedString(
|
||||||
|
L10n.of(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Divider(thickness: 1),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
actualMembersCount > 1
|
||||||
|
? L10n.of(context).countParticipants(
|
||||||
|
actualMembersCount.toString())
|
||||||
|
: L10n.of(context).emptyChat,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
widget.room.canInvite
|
||||||
|
? ListTile(
|
||||||
|
title: Text(L10n.of(context).inviteContact),
|
||||||
|
leading: CircleAvatar(
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).primaryColor,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
onTap: () => Navigator.of(context).push(
|
||||||
|
AppRoute.defaultRoute(
|
||||||
|
context,
|
||||||
|
InvitationSelection(widget.room),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: i < members.length + 1
|
||||||
|
? ParticipantListItem(members[i - 1])
|
||||||
|
: ListTile(
|
||||||
|
title: Text(L10n.of(context)
|
||||||
|
.loadCountMoreParticipants(
|
||||||
|
(actualMembersCount - members.length)
|
||||||
|
.toString())),
|
||||||
|
leading: CircleAvatar(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
foregroundColor: Colors.grey,
|
child: Icon(
|
||||||
child: Icon(Icons.edit),
|
Icons.refresh,
|
||||||
)
|
color: Colors.grey,
|
||||||
: null,
|
|
||||||
title: Text("${L10n.of(context).groupDescription}:",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
fontWeight: FontWeight.bold)),
|
|
||||||
subtitle: LinkText(
|
|
||||||
text: widget.room.topic?.isEmpty ?? true
|
|
||||||
? L10n.of(context).addGroupDescription
|
|
||||||
: widget.room.topic,
|
|
||||||
linkStyle: TextStyle(color: Colors.blueAccent),
|
|
||||||
textStyle: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: Theme.of(context).textTheme.bodyText2.color,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: widget.room.canSendEvent("m.room.topic")
|
|
||||||
? () => setTopicAction(context)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
Divider(thickness: 1),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
L10n.of(context).settings,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.room.canSendEvent("m.room.name"))
|
|
||||||
ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
foregroundColor: Colors.grey,
|
|
||||||
child: Icon(Icons.people),
|
|
||||||
),
|
|
||||||
title: Text(L10n.of(context).changeTheNameOfTheGroup),
|
|
||||||
subtitle: Text(widget.room
|
|
||||||
.getLocalizedDisplayname(L10n.of(context))),
|
|
||||||
onTap: () => setDisplaynameAction(context),
|
|
||||||
),
|
|
||||||
if (widget.room.canSendEvent("m.room.canonical_alias") &&
|
|
||||||
widget.room.joinRules == JoinRules.public)
|
|
||||||
ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
foregroundColor: Colors.grey,
|
|
||||||
child: Icon(Icons.link),
|
|
||||||
),
|
|
||||||
onTap: () => setCanonicalAliasAction(context),
|
|
||||||
title: Text(L10n.of(context).setInvitationLink),
|
|
||||||
subtitle: Text(
|
|
||||||
(widget.room.canonicalAlias?.isNotEmpty ?? false)
|
|
||||||
? widget.room.canonicalAlias
|
|
||||||
: L10n.of(context).none),
|
|
||||||
),
|
|
||||||
PopupMenuButton(
|
|
||||||
child: ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
foregroundColor: Colors.grey,
|
|
||||||
child: Icon(Icons.public)),
|
|
||||||
title: Text(
|
|
||||||
L10n.of(context).whoIsAllowedToJoinThisGroup),
|
|
||||||
subtitle: Text(
|
|
||||||
widget.room.joinRules
|
|
||||||
.getLocalizedString(L10n.of(context)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onSelected: (JoinRules joinRule) =>
|
|
||||||
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
|
||||||
widget.room.setJoinRules(joinRule),
|
|
||||||
),
|
|
||||||
itemBuilder: (BuildContext context) =>
|
|
||||||
<PopupMenuEntry<JoinRules>>[
|
|
||||||
if (widget.room.canChangeJoinRules)
|
|
||||||
PopupMenuItem<JoinRules>(
|
|
||||||
value: JoinRules.public,
|
|
||||||
child: Text(JoinRules.public
|
|
||||||
.getLocalizedString(L10n.of(context))),
|
|
||||||
),
|
|
||||||
if (widget.room.canChangeJoinRules)
|
|
||||||
PopupMenuItem<JoinRules>(
|
|
||||||
value: JoinRules.invite,
|
|
||||||
child: Text(JoinRules.invite
|
|
||||||
.getLocalizedString(L10n.of(context))),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
PopupMenuButton(
|
|
||||||
child: ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
foregroundColor: Colors.grey,
|
|
||||||
child: Icon(Icons.visibility),
|
|
||||||
),
|
|
||||||
title:
|
|
||||||
Text(L10n.of(context).visibilityOfTheChatHistory),
|
|
||||||
subtitle: Text(
|
|
||||||
widget.room.historyVisibility
|
|
||||||
.getLocalizedString(L10n.of(context)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onSelected: (HistoryVisibility historyVisibility) =>
|
|
||||||
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
|
||||||
widget.room.setHistoryVisibility(historyVisibility),
|
|
||||||
),
|
|
||||||
itemBuilder: (BuildContext context) =>
|
|
||||||
<PopupMenuEntry<HistoryVisibility>>[
|
|
||||||
if (widget.room.canChangeHistoryVisibility)
|
|
||||||
PopupMenuItem<HistoryVisibility>(
|
|
||||||
value: HistoryVisibility.invited,
|
|
||||||
child: Text(HistoryVisibility.invited
|
|
||||||
.getLocalizedString(L10n.of(context))),
|
|
||||||
),
|
|
||||||
if (widget.room.canChangeHistoryVisibility)
|
|
||||||
PopupMenuItem<HistoryVisibility>(
|
|
||||||
value: HistoryVisibility.joined,
|
|
||||||
child: Text(HistoryVisibility.joined
|
|
||||||
.getLocalizedString(L10n.of(context))),
|
|
||||||
),
|
|
||||||
if (widget.room.canChangeHistoryVisibility)
|
|
||||||
PopupMenuItem<HistoryVisibility>(
|
|
||||||
value: HistoryVisibility.shared,
|
|
||||||
child: Text(HistoryVisibility.shared
|
|
||||||
.getLocalizedString(L10n.of(context))),
|
|
||||||
),
|
|
||||||
if (widget.room.canChangeHistoryVisibility)
|
|
||||||
PopupMenuItem<HistoryVisibility>(
|
|
||||||
value: HistoryVisibility.world_readable,
|
|
||||||
child: Text(HistoryVisibility.world_readable
|
|
||||||
.getLocalizedString(L10n.of(context))),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (widget.room.joinRules == JoinRules.public)
|
|
||||||
PopupMenuButton(
|
|
||||||
child: ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
foregroundColor: Colors.grey,
|
|
||||||
child: Icon(Icons.info_outline),
|
|
||||||
),
|
|
||||||
title:
|
|
||||||
Text(L10n.of(context).areGuestsAllowedToJoin),
|
|
||||||
subtitle: Text(
|
|
||||||
widget.room.guestAccess
|
|
||||||
.getLocalizedString(L10n.of(context)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onSelected: (GuestAccess guestAccess) =>
|
|
||||||
SimpleDialogs(context)
|
|
||||||
.tryRequestWithLoadingDialog(
|
|
||||||
widget.room.setGuestAccess(guestAccess),
|
|
||||||
),
|
|
||||||
itemBuilder: (BuildContext context) =>
|
|
||||||
<PopupMenuEntry<GuestAccess>>[
|
|
||||||
if (widget.room.canChangeGuestAccess)
|
|
||||||
PopupMenuItem<GuestAccess>(
|
|
||||||
value: GuestAccess.can_join,
|
|
||||||
child: Text(
|
|
||||||
GuestAccess.can_join
|
|
||||||
.getLocalizedString(L10n.of(context)),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.room.canChangeGuestAccess)
|
onTap: () => requestMoreMembersAction(context),
|
||||||
PopupMenuItem<GuestAccess>(
|
),
|
||||||
value: GuestAccess.forbidden,
|
),
|
||||||
child: Text(
|
),
|
||||||
GuestAccess.forbidden
|
);
|
||||||
.getLocalizedString(L10n.of(context)),
|
}),
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Divider(thickness: 1),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
actualMembersCount > 1
|
|
||||||
? L10n.of(context).countParticipants(
|
|
||||||
actualMembersCount.toString())
|
|
||||||
: L10n.of(context).emptyChat,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
widget.room.canInvite
|
|
||||||
? ListTile(
|
|
||||||
title: Text(L10n.of(context).inviteContact),
|
|
||||||
leading: CircleAvatar(
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
),
|
|
||||||
onTap: () => Navigator.of(context).push(
|
|
||||||
AppRoute.defaultRoute(
|
|
||||||
context,
|
|
||||||
InvitationSelection(widget.room),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: i < members.length + 1
|
|
||||||
? ParticipantListItem(members[i - 1])
|
|
||||||
: ListTile(
|
|
||||||
title: Text(L10n.of(context).loadCountMoreParticipants(
|
|
||||||
(actualMembersCount - members.length).toString())),
|
|
||||||
leading: CircleAvatar(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
child: Icon(
|
|
||||||
Icons.refresh,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () => requestMoreMembersAction(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||||
import 'package:fluffychat/components/avatar.dart';
|
import 'package:fluffychat/components/avatar.dart';
|
||||||
@ -35,120 +33,105 @@ class ChatEncryptionSettings extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
||||||
Room room;
|
|
||||||
|
|
||||||
StreamSubscription roomUpdate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
roomUpdate?.cancel();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
room ??= Matrix.of(context).client.getRoomById(widget.id);
|
final room = Matrix.of(context).client.getRoomById(widget.id);
|
||||||
roomUpdate ??= room.onUpdate.stream.listen((s) => setState(() => null));
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(L10n.of(context).participatingUserDevices),
|
title: Text(L10n.of(context).participatingUserDevices),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: StreamBuilder(
|
||||||
children: <Widget>[
|
stream: room.onUpdate.stream,
|
||||||
FutureBuilder<List<DeviceKeys>>(
|
builder: (context, snapshot) {
|
||||||
future: room.getUserDeviceKeys(),
|
return FutureBuilder<List<DeviceKeys>>(
|
||||||
builder: (BuildContext context, snapshot) {
|
future: room.getUserDeviceKeys(),
|
||||||
if (snapshot.hasError) {
|
builder: (BuildContext context, snapshot) {
|
||||||
return Center(
|
if (snapshot.hasError) {
|
||||||
child: Text(L10n.of(context).oopsSomethingWentWrong +
|
return Center(
|
||||||
": " +
|
child: Text(L10n.of(context).oopsSomethingWentWrong +
|
||||||
snapshot.error.toString()),
|
": " +
|
||||||
);
|
snapshot.error.toString()),
|
||||||
}
|
);
|
||||||
if (!snapshot.hasData) {
|
}
|
||||||
return Center(child: CircularProgressIndicator());
|
if (!snapshot.hasData) {
|
||||||
}
|
return Center(child: CircularProgressIndicator());
|
||||||
final List<DeviceKeys> deviceKeys = snapshot.data;
|
}
|
||||||
return Expanded(
|
final List<DeviceKeys> deviceKeys = snapshot.data;
|
||||||
child: ListView.separated(
|
return Expanded(
|
||||||
separatorBuilder: (BuildContext context, int i) =>
|
child: ListView.separated(
|
||||||
Divider(height: 1),
|
separatorBuilder: (BuildContext context, int i) =>
|
||||||
itemCount: deviceKeys.length,
|
Divider(height: 1),
|
||||||
itemBuilder: (BuildContext context, int i) => Column(
|
itemCount: deviceKeys.length,
|
||||||
mainAxisSize: MainAxisSize.min,
|
itemBuilder: (BuildContext context, int i) => Column(
|
||||||
children: <Widget>[
|
mainAxisSize: MainAxisSize.min,
|
||||||
if (i == 0 ||
|
children: <Widget>[
|
||||||
deviceKeys[i].userId != deviceKeys[i - 1].userId)
|
if (i == 0 ||
|
||||||
Material(
|
deviceKeys[i].userId != deviceKeys[i - 1].userId)
|
||||||
child: ListTile(
|
Material(
|
||||||
leading: Avatar(
|
child: ListTile(
|
||||||
room
|
leading: Avatar(
|
||||||
|
room
|
||||||
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
||||||
|
.avatarUrl,
|
||||||
|
room
|
||||||
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
||||||
|
.calcDisplayname(),
|
||||||
|
),
|
||||||
|
title: Text(room
|
||||||
.getUserByMXIDSync(deviceKeys[i].userId)
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
||||||
.avatarUrl,
|
.calcDisplayname()),
|
||||||
room
|
subtitle: Text(deviceKeys[i].userId),
|
||||||
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
||||||
.calcDisplayname(),
|
|
||||||
),
|
),
|
||||||
title: Text(room
|
elevation: 2,
|
||||||
.getUserByMXIDSync(deviceKeys[i].userId)
|
|
||||||
.calcDisplayname()),
|
|
||||||
subtitle: Text(deviceKeys[i].userId),
|
|
||||||
),
|
),
|
||||||
elevation: 2,
|
CheckboxListTile(
|
||||||
),
|
title: Text(
|
||||||
CheckboxListTile(
|
"${deviceKeys[i].unsigned["device_display_name"] ?? L10n.of(context).unknownDevice} - ${deviceKeys[i].deviceId}",
|
||||||
title: Text(
|
style: TextStyle(
|
||||||
"${deviceKeys[i].unsigned["device_display_name"] ?? L10n.of(context).unknownDevice} - ${deviceKeys[i].deviceId}",
|
color: deviceKeys[i].blocked
|
||||||
style: TextStyle(
|
? Colors.red
|
||||||
color: deviceKeys[i].blocked
|
: deviceKeys[i].verified
|
||||||
? Colors.red
|
? Colors.green
|
||||||
: deviceKeys[i].verified
|
: Colors.orange),
|
||||||
? Colors.green
|
),
|
||||||
: Colors.orange),
|
subtitle: Text(
|
||||||
),
|
deviceKeys[i]
|
||||||
subtitle: Text(
|
.keys["ed25519:${deviceKeys[i].deviceId}"]
|
||||||
deviceKeys[i]
|
.beautified,
|
||||||
.keys["ed25519:${deviceKeys[i].deviceId}"]
|
style: TextStyle(
|
||||||
.beautified,
|
color: Theme.of(context)
|
||||||
style: TextStyle(
|
.textTheme
|
||||||
color:
|
.bodyText2
|
||||||
Theme.of(context).textTheme.bodyText2.color),
|
.color),
|
||||||
),
|
),
|
||||||
value: deviceKeys[i].verified,
|
value: deviceKeys[i].verified,
|
||||||
onChanged: (bool newVal) {
|
onChanged: (bool newVal) {
|
||||||
if (newVal == true) {
|
if (newVal == true) {
|
||||||
if (deviceKeys[i].blocked) {
|
if (deviceKeys[i].blocked) {
|
||||||
|
deviceKeys[i].setBlocked(
|
||||||
|
false, Matrix.of(context).client);
|
||||||
|
}
|
||||||
deviceKeys[i]
|
deviceKeys[i]
|
||||||
.setBlocked(false, Matrix.of(context).client);
|
.setVerified(true, Matrix.of(context).client);
|
||||||
|
} else {
|
||||||
|
if (deviceKeys[i].verified) {
|
||||||
|
deviceKeys[i].setVerified(
|
||||||
|
false, Matrix.of(context).client);
|
||||||
|
}
|
||||||
|
deviceKeys[i]
|
||||||
|
.setBlocked(true, Matrix.of(context).client);
|
||||||
}
|
}
|
||||||
deviceKeys[i]
|
setState(() => null);
|
||||||
.setVerified(true, Matrix.of(context).client);
|
},
|
||||||
} else {
|
),
|
||||||
if (deviceKeys[i].verified) {
|
],
|
||||||
deviceKeys[i].setVerified(
|
),
|
||||||
false, Matrix.of(context).client);
|
|
||||||
}
|
|
||||||
deviceKeys[i]
|
|
||||||
.setBlocked(true, Matrix.of(context).client);
|
|
||||||
}
|
|
||||||
setState(() => null);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
),
|
}),
|
||||||
Divider(thickness: 1, height: 1),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Outbound MegOlm session ID:"),
|
|
||||||
subtitle: Text(
|
|
||||||
room.outboundGroupSession?.session_id()?.beautified ?? "None"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,21 +52,17 @@ class ChatList extends StatefulWidget {
|
|||||||
|
|
||||||
class _ChatListState extends State<ChatList> {
|
class _ChatListState extends State<ChatList> {
|
||||||
bool get searchMode => searchController.text?.isNotEmpty ?? false;
|
bool get searchMode => searchController.text?.isNotEmpty ?? false;
|
||||||
StreamSubscription sub;
|
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
SelectMode selectMode = SelectMode.normal;
|
|
||||||
Timer coolDown;
|
Timer coolDown;
|
||||||
PublicRoomsResponse publicRoomsResponse;
|
PublicRoomsResponse publicRoomsResponse;
|
||||||
bool loadingPublicRooms = false;
|
bool loadingPublicRooms = false;
|
||||||
String searchServer;
|
String searchServer;
|
||||||
|
|
||||||
Future<bool> waitForFirstSync(BuildContext context) async {
|
Future<void> waitForFirstSync(BuildContext context) async {
|
||||||
Client client = Matrix.of(context).client;
|
Client client = Matrix.of(context).client;
|
||||||
if (client.prevBatch?.isEmpty ?? true) {
|
if (client.prevBatch?.isEmpty ?? true) {
|
||||||
await client.onFirstSync.stream.first;
|
await client.onFirstSync.stream.first;
|
||||||
}
|
}
|
||||||
sub ??= client.onSync.stream
|
|
||||||
.listen((s) => mounted ? setState(() => null) : null);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,230 +201,243 @@ class _ChatListState extends State<ChatList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
sub?.cancel();
|
|
||||||
searchController.removeListener(
|
searchController.removeListener(
|
||||||
() => setState(() => null),
|
() => setState(() => null),
|
||||||
);
|
);
|
||||||
_intentDataStreamSubscription?.cancel();
|
_intentDataStreamSubscription?.cancel();
|
||||||
_intentFileStreamSubscription?.cancel();
|
_intentFileStreamSubscription?.cancel();
|
||||||
_onShareContentChangedSub?.cancel();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscription _onShareContentChangedSub;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_onShareContentChangedSub ??= Matrix.of(context)
|
return StreamBuilder(
|
||||||
.onShareContentChanged
|
stream: Matrix.of(context).onShareContentChanged.stream,
|
||||||
.stream
|
builder: (context, snapshot) {
|
||||||
.listen((c) => setState(() => null));
|
final selectMode = Matrix.of(context).shareContent == null
|
||||||
if (Matrix.of(context).shareContent != null) {
|
? SelectMode.normal
|
||||||
selectMode = SelectMode.share;
|
: SelectMode.share;
|
||||||
} else if (selectMode == SelectMode.share) {
|
return Scaffold(
|
||||||
setState(() => selectMode = SelectMode.normal);
|
drawer: selectMode == SelectMode.share
|
||||||
}
|
? null
|
||||||
return Scaffold(
|
: Drawer(
|
||||||
drawer: selectMode == SelectMode.share
|
child: SafeArea(
|
||||||
? null
|
child: ListView(
|
||||||
: Drawer(
|
padding: EdgeInsets.zero,
|
||||||
child: SafeArea(
|
children: <Widget>[
|
||||||
child: ListView(
|
ListTile(
|
||||||
padding: EdgeInsets.zero,
|
leading: Icon(Icons.edit),
|
||||||
children: <Widget>[
|
title: Text(L10n.of(context).setStatus),
|
||||||
ListTile(
|
onTap: () => _setStatus(context),
|
||||||
leading: Icon(Icons.edit),
|
),
|
||||||
title: Text(L10n.of(context).setStatus),
|
Divider(height: 1),
|
||||||
onTap: () => _setStatus(context),
|
ListTile(
|
||||||
),
|
leading: Icon(Icons.people_outline),
|
||||||
Divider(height: 1),
|
title: Text(L10n.of(context).createNewGroup),
|
||||||
ListTile(
|
onTap: () => _drawerTapAction(NewGroupView()),
|
||||||
leading: Icon(Icons.people_outline),
|
),
|
||||||
title: Text(L10n.of(context).createNewGroup),
|
ListTile(
|
||||||
onTap: () => _drawerTapAction(NewGroupView()),
|
leading: Icon(Icons.person_add),
|
||||||
),
|
title: Text(L10n.of(context).newPrivateChat),
|
||||||
ListTile(
|
onTap: () => _drawerTapAction(NewPrivateChatView()),
|
||||||
leading: Icon(Icons.person_add),
|
),
|
||||||
title: Text(L10n.of(context).newPrivateChat),
|
Divider(height: 1),
|
||||||
onTap: () => _drawerTapAction(NewPrivateChatView()),
|
ListTile(
|
||||||
),
|
leading: Icon(Icons.archive),
|
||||||
Divider(height: 1),
|
title: Text(L10n.of(context).archive),
|
||||||
ListTile(
|
onTap: () => _drawerTapAction(
|
||||||
leading: Icon(Icons.archive),
|
Archive(),
|
||||||
title: Text(L10n.of(context).archive),
|
|
||||||
onTap: () => _drawerTapAction(
|
|
||||||
Archive(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.settings),
|
|
||||||
title: Text(L10n.of(context).settings),
|
|
||||||
onTap: () => _drawerTapAction(
|
|
||||||
SettingsView(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(height: 1),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.share),
|
|
||||||
title: Text(L10n.of(context).inviteContact),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Share.share(L10n.of(context).inviteText(
|
|
||||||
Matrix.of(context).client.userID,
|
|
||||||
"https://matrix.to/#/${Matrix.of(context).client.userID}"));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
appBar: AppBar(
|
|
||||||
leading: selectMode != SelectMode.share
|
|
||||||
? null
|
|
||||||
: IconButton(
|
|
||||||
icon: Icon(Icons.close),
|
|
||||||
onPressed: () => Matrix.of(context).shareContent = null,
|
|
||||||
),
|
|
||||||
titleSpacing: 0,
|
|
||||||
title: selectMode == SelectMode.share
|
|
||||||
? Text(L10n.of(context).share)
|
|
||||||
: Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
height: 42,
|
|
||||||
margin: EdgeInsets.only(right: 8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).secondaryHeaderColor,
|
|
||||||
borderRadius: BorderRadius.circular(90),
|
|
||||||
),
|
|
||||||
child: TextField(
|
|
||||||
autocorrect: false,
|
|
||||||
controller: searchController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
suffixIcon: loadingPublicRooms
|
|
||||||
? Container(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: Container(
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: Icon(Icons.search),
|
ListTile(
|
||||||
contentPadding: EdgeInsets.all(9),
|
leading: Icon(Icons.settings),
|
||||||
border: InputBorder.none,
|
title: Text(L10n.of(context).settings),
|
||||||
hintText: L10n.of(context).searchForAChat,
|
onTap: () => _drawerTapAction(
|
||||||
|
SettingsView(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(height: 1),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(Icons.share),
|
||||||
|
title: Text(L10n.of(context).inviteContact),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Share.share(L10n.of(context).inviteText(
|
||||||
|
Matrix.of(context).client.userID,
|
||||||
|
"https://matrix.to/#/${Matrix.of(context).client.userID}"));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
appBar: AppBar(
|
||||||
),
|
leading: selectMode != SelectMode.share
|
||||||
),
|
? null
|
||||||
floatingActionButton: (AdaptivePageLayout.columnMode(context) ||
|
: IconButton(
|
||||||
selectMode == SelectMode.share)
|
icon: Icon(Icons.close),
|
||||||
? null
|
onPressed: () => Matrix.of(context).shareContent = null,
|
||||||
: SpeedDial(
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
overlayColor: blackWhiteColor(context),
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
|
||||||
children: [
|
|
||||||
SpeedDialChild(
|
|
||||||
child: Icon(Icons.people_outline),
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
label: L10n.of(context).createNewGroup,
|
|
||||||
labelStyle: TextStyle(fontSize: 18.0, color: Colors.black),
|
|
||||||
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
|
||||||
AppRoute.defaultRoute(context, NewGroupView()),
|
|
||||||
(r) => r.isFirst),
|
|
||||||
),
|
|
||||||
SpeedDialChild(
|
|
||||||
child: Icon(Icons.person_add),
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
label: L10n.of(context).newPrivateChat,
|
|
||||||
labelStyle: TextStyle(fontSize: 18.0, color: Colors.black),
|
|
||||||
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
|
||||||
AppRoute.defaultRoute(context, NewPrivateChatView()),
|
|
||||||
(r) => r.isFirst),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: FutureBuilder<bool>(
|
|
||||||
future: waitForFirstSync(context),
|
|
||||||
builder: (BuildContext context, snapshot) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
List<Room> rooms = List<Room>.from(Matrix.of(context).client.rooms);
|
|
||||||
rooms.removeWhere((Room room) =>
|
|
||||||
searchMode &&
|
|
||||||
!room.displayname
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(searchController.text.toLowerCase() ?? ""));
|
|
||||||
if (rooms.isEmpty && (!searchMode || publicRoomsResponse == null)) {
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
Icon(
|
|
||||||
searchMode ? Icons.search : Icons.chat_bubble_outline,
|
|
||||||
size: 80,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
),
|
||||||
Text(searchMode
|
titleSpacing: 0,
|
||||||
? L10n.of(context).noRoomsFound
|
title: selectMode == SelectMode.share
|
||||||
: L10n.of(context).startYourFirstChat),
|
? Text(L10n.of(context).share)
|
||||||
],
|
: Container(
|
||||||
),
|
padding: EdgeInsets.all(8),
|
||||||
);
|
height: 42,
|
||||||
}
|
margin: EdgeInsets.only(right: 8),
|
||||||
final int publicRoomsCount =
|
decoration: BoxDecoration(
|
||||||
(publicRoomsResponse?.publicRooms?.length ?? 0);
|
color: Theme.of(context).secondaryHeaderColor,
|
||||||
final int totalCount = rooms.length + publicRoomsCount;
|
borderRadius: BorderRadius.circular(90),
|
||||||
return ListView.separated(
|
),
|
||||||
separatorBuilder: (BuildContext context, int i) =>
|
child: TextField(
|
||||||
i == totalCount - publicRoomsCount
|
autocorrect: false,
|
||||||
? Material(
|
controller: searchController,
|
||||||
elevation: 2,
|
decoration: InputDecoration(
|
||||||
child: ListTile(
|
suffixIcon: loadingPublicRooms
|
||||||
title: Text(L10n.of(context).publicRooms),
|
? Container(
|
||||||
),
|
alignment: Alignment.centerRight,
|
||||||
)
|
child: Container(
|
||||||
: Container(),
|
width: 20,
|
||||||
itemCount: totalCount + 1,
|
height: 20,
|
||||||
itemBuilder: (BuildContext context, int i) {
|
child: CircularProgressIndicator(),
|
||||||
if (i == 0) {
|
),
|
||||||
return Matrix.of(context).client.statusList.isEmpty
|
)
|
||||||
? Container()
|
: Icon(Icons.search),
|
||||||
: PreferredSize(
|
contentPadding: EdgeInsets.all(9),
|
||||||
preferredSize: Size.fromHeight(89),
|
border: InputBorder.none,
|
||||||
child: Container(
|
hintText: L10n.of(context).searchForAChat,
|
||||||
height: 81,
|
),
|
||||||
child: ListView.builder(
|
),
|
||||||
scrollDirection: Axis.horizontal,
|
),
|
||||||
itemCount:
|
),
|
||||||
Matrix.of(context).client.statusList.length,
|
floatingActionButton: (AdaptivePageLayout.columnMode(context) ||
|
||||||
itemBuilder: (BuildContext context, int i) =>
|
selectMode == SelectMode.share)
|
||||||
PresenceListItem(Matrix.of(context)
|
? null
|
||||||
.client
|
: SpeedDial(
|
||||||
.statusList[i]),
|
child: Icon(Icons.add),
|
||||||
),
|
overlayColor: blackWhiteColor(context),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
|
children: [
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(Icons.people_outline),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
backgroundColor: Colors.blue,
|
||||||
|
label: L10n.of(context).createNewGroup,
|
||||||
|
labelStyle:
|
||||||
|
TextStyle(fontSize: 18.0, color: Colors.black),
|
||||||
|
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
||||||
|
AppRoute.defaultRoute(context, NewGroupView()),
|
||||||
|
(r) => r.isFirst),
|
||||||
|
),
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(Icons.person_add),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
label: L10n.of(context).newPrivateChat,
|
||||||
|
labelStyle:
|
||||||
|
TextStyle(fontSize: 18.0, color: Colors.black),
|
||||||
|
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
||||||
|
AppRoute.defaultRoute(
|
||||||
|
context, NewPrivateChatView()),
|
||||||
|
(r) => r.isFirst),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: StreamBuilder(
|
||||||
|
stream: Matrix.of(context).client.onSync.stream,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return FutureBuilder<void>(
|
||||||
|
future: waitForFirstSync(context),
|
||||||
|
builder: (BuildContext context, snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
List<Room> rooms =
|
||||||
|
List<Room>.from(Matrix.of(context).client.rooms);
|
||||||
|
rooms.removeWhere((Room room) =>
|
||||||
|
searchMode &&
|
||||||
|
!room.displayname.toLowerCase().contains(
|
||||||
|
searchController.text.toLowerCase() ?? ""));
|
||||||
|
if (rooms.isEmpty &&
|
||||||
|
(!searchMode || publicRoomsResponse == null)) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
searchMode
|
||||||
|
? Icons.search
|
||||||
|
: Icons.chat_bubble_outline,
|
||||||
|
size: 80,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
Text(searchMode
|
||||||
|
? L10n.of(context).noRoomsFound
|
||||||
|
: L10n.of(context).startYourFirstChat),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
i--;
|
final int publicRoomsCount =
|
||||||
return i < rooms.length
|
(publicRoomsResponse?.publicRooms?.length ?? 0);
|
||||||
? ChatListItem(
|
final int totalCount = rooms.length + publicRoomsCount;
|
||||||
rooms[i],
|
return ListView.separated(
|
||||||
activeChat: widget.activeChat == rooms[i].id,
|
separatorBuilder: (BuildContext context, int i) =>
|
||||||
)
|
i == totalCount - publicRoomsCount
|
||||||
: PublicRoomListItem(
|
? Material(
|
||||||
publicRoomsResponse.publicRooms[i - rooms.length]);
|
elevation: 2,
|
||||||
});
|
child: ListTile(
|
||||||
} else {
|
title: Text(
|
||||||
return Center(
|
L10n.of(context).publicRooms),
|
||||||
child: CircularProgressIndicator(),
|
),
|
||||||
);
|
)
|
||||||
}
|
: Container(),
|
||||||
},
|
itemCount: totalCount + 1,
|
||||||
),
|
itemBuilder: (BuildContext context, int i) {
|
||||||
);
|
if (i == 0) {
|
||||||
|
return Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.statusList
|
||||||
|
.isEmpty
|
||||||
|
? Container()
|
||||||
|
: PreferredSize(
|
||||||
|
preferredSize: Size.fromHeight(89),
|
||||||
|
child: Container(
|
||||||
|
height: 81,
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.statusList
|
||||||
|
.length,
|
||||||
|
itemBuilder:
|
||||||
|
(BuildContext context, int i) =>
|
||||||
|
PresenceListItem(
|
||||||
|
Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.statusList[i]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
return i < rooms.length
|
||||||
|
? ChatListItem(
|
||||||
|
rooms[i],
|
||||||
|
activeChat:
|
||||||
|
widget.activeChat == rooms[i].id,
|
||||||
|
)
|
||||||
|
: PublicRoomListItem(publicRoomsResponse
|
||||||
|
.publicRooms[i - rooms.length]);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user