2020-10-03 11:11:07 +00:00
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
2020-01-01 18:10:13 +00:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2020-06-10 08:07:01 +00:00
|
|
|
import 'package:famedlysdk/matrix_api.dart';
|
2020-10-04 15:01:54 +00:00
|
|
|
|
|
|
|
import 'package:file_picker_cross/file_picker_cross.dart';
|
2020-10-06 19:59:36 +00:00
|
|
|
import 'package:furrychat/components/adaptive_page_layout.dart';
|
|
|
|
import 'package:furrychat/components/chat_settings_popup_menu.dart';
|
|
|
|
import 'package:furrychat/components/content_banner.dart';
|
|
|
|
import 'package:furrychat/components/dialogs/simple_dialogs.dart';
|
|
|
|
import 'package:furrychat/components/list_items/participant_list_item.dart';
|
|
|
|
import 'package:furrychat/utils/app_route.dart';
|
|
|
|
import 'package:furrychat/utils/matrix_locals.dart';
|
|
|
|
import 'package:furrychat/utils/platform_infos.dart';
|
|
|
|
import 'package:furrychat/views/chat_list.dart';
|
|
|
|
import 'package:furrychat/views/invitation_selection.dart';
|
2020-01-23 11:11:57 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-01-01 18:10:13 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2020-01-19 18:28:12 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2020-10-03 11:11:07 +00:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2020-01-01 18:10:13 +00:00
|
|
|
import 'package:image_picker/image_picker.dart';
|
2020-09-05 11:45:03 +00:00
|
|
|
import 'package:matrix_link_text/link_text.dart';
|
2020-10-03 11:11:07 +00:00
|
|
|
|
2020-10-14 01:21:28 +00:00
|
|
|
import 'package:furrychat/views/settings/settings_emotes.dart';
|
|
|
|
import 'package:furrychat/views/settings/settings_multiple_emotes.dart';
|
|
|
|
import 'package:furrychat/utils/url_launcher.dart';
|
2020-01-01 18:10:13 +00:00
|
|
|
|
|
|
|
class ChatDetails extends StatefulWidget {
|
|
|
|
final Room room;
|
|
|
|
|
|
|
|
const ChatDetails(this.room);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_ChatDetailsState createState() => _ChatDetailsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ChatDetailsState extends State<ChatDetails> {
|
|
|
|
List<User> members;
|
2020-02-16 10:09:28 +00:00
|
|
|
void setDisplaynameAction(BuildContext context) async {
|
2020-05-13 13:58:59 +00:00
|
|
|
var enterText = SimpleDialogs(context).enterText(
|
2020-05-07 05:52:40 +00:00
|
|
|
titleText: L10n.of(context).changeTheNameOfTheGroup,
|
|
|
|
labelText: L10n.of(context).changeTheNameOfTheGroup,
|
2020-10-03 11:11:07 +00:00
|
|
|
hintText:
|
|
|
|
widget.room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
|
2020-02-16 10:09:28 +00:00
|
|
|
);
|
2020-05-13 13:58:59 +00:00
|
|
|
final displayname = await enterText;
|
2020-02-16 10:09:28 +00:00
|
|
|
if (displayname == null) return;
|
2020-04-27 11:36:39 +00:00
|
|
|
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-01-01 18:10:13 +00:00
|
|
|
widget.room.setName(displayname),
|
|
|
|
);
|
2020-01-04 12:53:49 +00:00
|
|
|
if (success != false) {
|
2020-05-13 08:45:50 +00:00
|
|
|
BotToast.showText(text: L10n.of(context).displaynameHasBeenChanged);
|
2020-01-01 18:10:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 10:09:28 +00:00
|
|
|
void setCanonicalAliasAction(context) async {
|
2020-05-13 13:58:59 +00:00
|
|
|
final s = await SimpleDialogs(context).enterText(
|
2020-05-07 05:52:40 +00:00
|
|
|
titleText: L10n.of(context).setInvitationLink,
|
|
|
|
labelText: L10n.of(context).setInvitationLink,
|
|
|
|
hintText: L10n.of(context).alias.toLowerCase(),
|
2020-05-13 13:58:59 +00:00
|
|
|
prefixText: '#',
|
|
|
|
suffixText: ':' + widget.room.client.userID.domain,
|
2020-02-16 10:09:28 +00:00
|
|
|
);
|
|
|
|
if (s == null) return;
|
2020-05-13 13:58:59 +00:00
|
|
|
final domain = widget.room.client.userID.domain;
|
|
|
|
final canonicalAlias = '%23' + s + '%3A' + domain;
|
|
|
|
final aliasEvent = widget.room.getState('m.room.aliases', domain);
|
|
|
|
final aliases =
|
|
|
|
aliasEvent != null ? aliasEvent.content['aliases'] ?? [] : [];
|
2020-01-19 14:07:42 +00:00
|
|
|
if (aliases.indexWhere((s) => s == canonicalAlias) == -1) {
|
2020-05-13 13:58:59 +00:00
|
|
|
var newAliases = List<String>.from(aliases);
|
2020-01-19 14:07:42 +00:00
|
|
|
newAliases.add(canonicalAlias);
|
2020-04-27 11:36:39 +00:00
|
|
|
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-08-16 10:54:43 +00:00
|
|
|
widget.room.client.requestRoomAliasInformations(canonicalAlias),
|
2020-01-19 14:07:42 +00:00
|
|
|
);
|
|
|
|
if (response == false) {
|
2020-04-27 11:36:39 +00:00
|
|
|
final success =
|
|
|
|
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-08-16 10:54:43 +00:00
|
|
|
widget.room.client.createRoomAlias(canonicalAlias, widget.room.id),
|
2020-01-19 14:07:42 +00:00
|
|
|
);
|
|
|
|
if (success == false) return;
|
|
|
|
}
|
|
|
|
}
|
2020-04-27 11:36:39 +00:00
|
|
|
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-08-16 10:54:43 +00:00
|
|
|
widget.room.client.sendState(widget.room.id, 'm.room.canonical_alias', {
|
2020-06-10 08:07:01 +00:00
|
|
|
'alias': '#$s:$domain',
|
|
|
|
}),
|
2020-01-19 14:07:42 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-02-16 10:09:28 +00:00
|
|
|
void setTopicAction(BuildContext context) async {
|
2020-05-13 13:58:59 +00:00
|
|
|
final displayname = await SimpleDialogs(context).enterText(
|
2020-05-07 05:52:40 +00:00
|
|
|
titleText: L10n.of(context).setGroupDescription,
|
|
|
|
labelText: L10n.of(context).setGroupDescription,
|
2020-02-16 10:09:28 +00:00
|
|
|
hintText: (widget.room.topic?.isNotEmpty ?? false)
|
|
|
|
? widget.room.topic
|
2020-05-07 05:52:40 +00:00
|
|
|
: L10n.of(context).addGroupDescription,
|
2020-02-16 10:09:28 +00:00
|
|
|
multiLine: true,
|
|
|
|
);
|
|
|
|
if (displayname == null) return;
|
2020-04-27 11:36:39 +00:00
|
|
|
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-01-17 11:06:03 +00:00
|
|
|
widget.room.setDescription(displayname),
|
|
|
|
);
|
|
|
|
if (success != false) {
|
2020-05-13 08:45:50 +00:00
|
|
|
BotToast.showText(text: L10n.of(context).groupDescriptionHasBeenChanged);
|
2020-01-17 11:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-01 18:10:13 +00:00
|
|
|
void setAvatarAction(BuildContext context) async {
|
2020-10-04 15:01:54 +00:00
|
|
|
MatrixFile file;
|
|
|
|
if (PlatformInfos.isMobile) {
|
|
|
|
final result = await ImagePicker().getImage(
|
|
|
|
source: ImageSource.gallery,
|
|
|
|
imageQuality: 50,
|
|
|
|
maxWidth: 1600,
|
|
|
|
maxHeight: 1600);
|
|
|
|
if (result == null) return;
|
|
|
|
file = MatrixFile(
|
|
|
|
bytes: await result.readAsBytes(),
|
|
|
|
name: result.path,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
final result = await FilePickerCross.importFromStorage(
|
|
|
|
type: FileTypeCross.image,
|
|
|
|
);
|
|
|
|
if (result == null) return;
|
|
|
|
file = MatrixFile(
|
|
|
|
bytes: result.toUint8List(),
|
|
|
|
name: result.fileName,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-27 11:36:39 +00:00
|
|
|
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-10-04 15:01:54 +00:00
|
|
|
widget.room.setAvatar(file),
|
2020-01-01 18:10:13 +00:00
|
|
|
);
|
2020-01-04 12:53:49 +00:00
|
|
|
if (success != false) {
|
2020-05-13 08:45:50 +00:00
|
|
|
BotToast.showText(text: L10n.of(context).avatarHasBeenChanged);
|
2020-01-01 18:10:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void requestMoreMembersAction(BuildContext context) async {
|
2020-04-27 11:36:39 +00:00
|
|
|
final List<User> participants = await SimpleDialogs(context)
|
2020-01-01 18:10:13 +00:00
|
|
|
.tryRequestWithLoadingDialog(widget.room.requestParticipants());
|
|
|
|
if (participants != null) setState(() => members = participants);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-01-05 11:27:03 +00:00
|
|
|
if (widget.room == null) {
|
2020-01-20 12:46:39 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2020-05-07 05:52:40 +00:00
|
|
|
title: Text(L10n.of(context).oopsSomethingWentWrong),
|
2020-01-20 12:46:39 +00:00
|
|
|
),
|
|
|
|
body: Center(
|
2020-05-07 05:52:40 +00:00
|
|
|
child: Text(L10n.of(context).youAreNoLongerParticipatingInThisChat),
|
2020-01-20 12:46:39 +00:00
|
|
|
),
|
2020-01-05 11:27:03 +00:00
|
|
|
);
|
|
|
|
}
|
2020-01-01 18:10:13 +00:00
|
|
|
members ??= widget.room.getParticipants();
|
2020-04-02 11:14:39 +00:00
|
|
|
members.removeWhere((u) => u.membership == Membership.leave);
|
2020-05-13 13:58:59 +00:00
|
|
|
final actualMembersCount =
|
2020-01-01 18:10:13 +00:00
|
|
|
widget.room.mInvitedMemberCount + widget.room.mJoinedMemberCount;
|
2020-05-13 13:58:59 +00:00
|
|
|
final canRequestMoreMembers = members.length < actualMembersCount;
|
2020-01-01 18:10:13 +00:00
|
|
|
return AdaptivePageLayout(
|
|
|
|
primaryPage: FocusPage.SECOND,
|
|
|
|
firstScaffold: ChatList(
|
|
|
|
activeChat: widget.room.id,
|
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
secondScaffold: StreamBuilder(
|
|
|
|
stream: widget.room.onUpdate.stream,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return Scaffold(
|
|
|
|
body: NestedScrollView(
|
|
|
|
headerSliverBuilder:
|
|
|
|
(BuildContext context, bool innerBoxIsScrolled) => <Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
expandedHeight: 300.0,
|
|
|
|
floating: true,
|
|
|
|
pinned: true,
|
|
|
|
actions: <Widget>[
|
|
|
|
if (widget.room.canonicalAlias?.isNotEmpty ?? false)
|
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.share),
|
|
|
|
onPressed: () {
|
|
|
|
Clipboard.setData(
|
|
|
|
ClipboardData(text: widget.room.canonicalAlias),
|
|
|
|
);
|
2020-05-13 08:45:50 +00:00
|
|
|
BotToast.showText(
|
|
|
|
text: L10n.of(context).copiedToClipboard);
|
2020-05-09 05:17:55 +00:00
|
|
|
},
|
2020-01-19 14:07:42 +00:00
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
ChatSettingsPopupMenu(widget.room, false)
|
|
|
|
],
|
|
|
|
title: Text(
|
2020-10-03 11:11:07 +00:00
|
|
|
widget.room.getLocalizedDisplayname(
|
|
|
|
MatrixLocals(L10n.of(context))),
|
2020-05-09 05:17:55 +00:00
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.appBarTheme
|
|
|
|
.textTheme
|
|
|
|
.headline6
|
|
|
|
.color)),
|
|
|
|
backgroundColor: Theme.of(context).appBarTheme.color,
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
|
background: ContentBanner(widget.room.avatar,
|
2020-05-13 13:58:59 +00:00
|
|
|
onEdit: widget.room.canSendEvent('m.room.avatar') &&
|
2020-05-09 05:17:55 +00:00
|
|
|
!kIsWeb
|
|
|
|
? () => setAvatarAction(context)
|
|
|
|
: null),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
body: ListView.builder(
|
|
|
|
itemCount:
|
|
|
|
members.length + 1 + (canRequestMoreMembers ? 1 : 0),
|
|
|
|
itemBuilder: (BuildContext context, int i) => i == 0
|
|
|
|
? Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
2020-05-13 13:58:59 +00:00
|
|
|
leading: widget.room.canSendEvent('m.room.topic')
|
2020-05-09 05:17:55 +00:00
|
|
|
? CircleAvatar(
|
|
|
|
backgroundColor: Theme.of(context)
|
|
|
|
.scaffoldBackgroundColor,
|
|
|
|
foregroundColor: Colors.grey,
|
|
|
|
child: Icon(Icons.edit),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
title: Text(
|
2020-05-13 13:58:59 +00:00
|
|
|
'${L10n.of(context).groupDescription}:',
|
2020-05-09 05:17:55 +00:00
|
|
|
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,
|
|
|
|
),
|
2020-09-05 11:45:03 +00:00
|
|
|
onLinkTap: (url) =>
|
|
|
|
UrlLauncher(context, url).launchUrl(),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
2020-05-13 13:58:59 +00:00
|
|
|
onTap: widget.room.canSendEvent('m.room.topic')
|
2020-05-09 05:17:55 +00:00
|
|
|
? () => setTopicAction(context)
|
|
|
|
: null,
|
2020-01-17 09:39:46 +00:00
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).settings,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
2020-01-03 11:07:04 +00:00
|
|
|
),
|
2020-05-13 13:58:59 +00:00
|
|
|
if (widget.room.canSendEvent('m.room.name'))
|
2020-05-09 05:17:55 +00:00
|
|
|
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
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedDisplayname(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
onTap: () => setDisplaynameAction(context),
|
|
|
|
),
|
|
|
|
if (widget.room
|
2020-05-13 13:58:59 +00:00
|
|
|
.canSendEvent('m.room.canonical_alias') &&
|
2020-05-09 05:17:55 +00:00
|
|
|
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),
|
|
|
|
),
|
2020-05-12 07:02:33 +00:00
|
|
|
ListTile(
|
|
|
|
leading: CircleAvatar(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
foregroundColor: Colors.grey,
|
|
|
|
child: Icon(Icons.insert_emoticon),
|
|
|
|
),
|
|
|
|
title: Text(L10n.of(context).emoteSettings),
|
2020-10-03 10:31:29 +00:00
|
|
|
onTap: () async {
|
|
|
|
// okay, we need to test if there are any emote state events other than the default one
|
|
|
|
// if so, we need to be directed to a selection screen for which pack we want to look at
|
|
|
|
// otherwise, we just open the normal one.
|
|
|
|
if ((widget.room.states
|
|
|
|
.states['im.ponies.room_emotes'] ??
|
|
|
|
<String, Event>{})
|
|
|
|
.keys
|
|
|
|
.any((String s) => s.isNotEmpty)) {
|
2020-05-12 07:02:33 +00:00
|
|
|
await Navigator.of(context).push(
|
2020-10-03 10:31:29 +00:00
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
MultipleEmotesSettingsView(
|
|
|
|
room: widget.room),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
await Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
EmotesSettingsView(room: widget.room),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2020-05-12 07:02:33 +00:00
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
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(
|
2020-10-03 11:11:07 +00:00
|
|
|
widget.room.joinRules.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context))),
|
2020-02-16 09:48:20 +00:00
|
|
|
),
|
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
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
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
if (widget.room.canChangeJoinRules)
|
|
|
|
PopupMenuItem<JoinRules>(
|
|
|
|
value: JoinRules.invite,
|
|
|
|
child: Text(JoinRules.invite
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
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
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context))),
|
2020-02-16 09:48:20 +00:00
|
|
|
),
|
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
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
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
if (widget.room.canChangeHistoryVisibility)
|
|
|
|
PopupMenuItem<HistoryVisibility>(
|
|
|
|
value: HistoryVisibility.joined,
|
|
|
|
child: Text(HistoryVisibility.joined
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
if (widget.room.canChangeHistoryVisibility)
|
|
|
|
PopupMenuItem<HistoryVisibility>(
|
|
|
|
value: HistoryVisibility.shared,
|
|
|
|
child: Text(HistoryVisibility.shared
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
if (widget.room.canChangeHistoryVisibility)
|
|
|
|
PopupMenuItem<HistoryVisibility>(
|
|
|
|
value: HistoryVisibility.world_readable,
|
|
|
|
child: Text(HistoryVisibility.world_readable
|
2020-10-03 11:11:07 +00:00
|
|
|
.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context)))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
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(
|
2020-10-03 11:11:07 +00:00
|
|
|
widget.room.guestAccess.getLocalizedString(
|
|
|
|
MatrixLocals(L10n.of(context))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
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(
|
2020-10-03 11:11:07 +00:00
|
|
|
MatrixLocals(L10n.of(context))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
if (widget.room.canChangeGuestAccess)
|
|
|
|
PopupMenuItem<GuestAccess>(
|
|
|
|
value: GuestAccess.forbidden,
|
|
|
|
child: Text(
|
|
|
|
GuestAccess.forbidden
|
|
|
|
.getLocalizedString(
|
2020-10-03 11:11:07 +00:00
|
|
|
MatrixLocals(L10n.of(context))),
|
2020-05-09 05:17:55 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
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(),
|
2020-02-16 09:48:20 +00:00
|
|
|
],
|
2020-05-09 05:17:55 +00:00
|
|
|
)
|
|
|
|
: i < members.length + 1
|
|
|
|
? ParticipantListItem(members[i - 1])
|
|
|
|
: ListTile(
|
|
|
|
title: Text(L10n.of(context)
|
|
|
|
.loadCountMoreParticipants(
|
|
|
|
(actualMembersCount - members.length)
|
|
|
|
.toString())),
|
2020-02-16 09:48:20 +00:00
|
|
|
leading: CircleAvatar(
|
2020-05-09 05:17:55 +00:00
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
child: Icon(
|
|
|
|
Icons.refresh,
|
|
|
|
color: Colors.grey,
|
2020-02-16 09:48:20 +00:00
|
|
|
),
|
|
|
|
),
|
2020-05-09 05:17:55 +00:00
|
|
|
onTap: () => requestMoreMembersAction(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
2020-01-01 18:10:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|