refactor: Migrate to null safety
This commit is contained in:
parent
5269f04a99
commit
55f0300f9f
163 changed files with 1759 additions and 1903 deletions
|
|
@ -18,34 +18,34 @@ import 'package:fluffychat/widgets/matrix.dart';
|
|||
enum AliasActions { copy, delete, setCanonical }
|
||||
|
||||
class ChatDetails extends StatefulWidget {
|
||||
const ChatDetails({Key key}) : super(key: key);
|
||||
const ChatDetails({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
ChatDetailsController createState() => ChatDetailsController();
|
||||
}
|
||||
|
||||
class ChatDetailsController extends State<ChatDetails> {
|
||||
List<User> members;
|
||||
List<User>? members;
|
||||
bool displaySettings = false;
|
||||
|
||||
void toggleDisplaySettings() =>
|
||||
setState(() => displaySettings = !displaySettings);
|
||||
|
||||
String get roomId => VRouter.of(context).pathParameters['roomid'];
|
||||
String? get roomId => VRouter.of(context).pathParameters['roomid'];
|
||||
|
||||
void setDisplaynameAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final input = await showTextInputDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context).changeTheNameOfTheGroup,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
title: L10n.of(context)!.changeTheNameOfTheGroup,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText: room.getLocalizedDisplayname(
|
||||
MatrixLocals(
|
||||
L10n.of(context),
|
||||
L10n.of(context)!,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -58,12 +58,12 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
);
|
||||
if (success.error == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(L10n.of(context).displaynameHasBeenChanged)));
|
||||
SnackBar(content: Text(L10n.of(context)!.displaynameHasBeenChanged)));
|
||||
}
|
||||
}
|
||||
|
||||
void editAliases() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!);
|
||||
|
||||
// The current endpoint doesnt seem to be implemented in Synapse. This may
|
||||
// change in the future and then we just need to switch to this api call:
|
||||
|
|
@ -76,7 +76,7 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
// While this is not working we use the unstable api:
|
||||
final aliases = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client
|
||||
future: () => room!.client
|
||||
.request(
|
||||
RequestType.GET,
|
||||
'/client/unstable/org.matrix.msc2432/rooms/${Uri.encodeComponent(room.id)}/aliases',
|
||||
|
|
@ -86,21 +86,21 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
// Switch to the stable api once it is implemented.
|
||||
|
||||
if (aliases.error != null) return;
|
||||
final adminMode = room.canSendEvent('m.room.canonical_alias');
|
||||
if (aliases.result.isEmpty && (room.canonicalAlias?.isNotEmpty ?? false)) {
|
||||
aliases.result.add(room.canonicalAlias);
|
||||
final adminMode = room!.canSendEvent('m.room.canonical_alias');
|
||||
if (aliases.result!.isEmpty && (room.canonicalAlias.isNotEmpty)) {
|
||||
aliases.result!.add(room.canonicalAlias);
|
||||
}
|
||||
if (aliases.result.isEmpty && adminMode) {
|
||||
if (aliases.result!.isEmpty && adminMode) {
|
||||
return setAliasAction();
|
||||
}
|
||||
final select = await showConfirmationDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context).editRoomAliases,
|
||||
title: L10n.of(context)!.editRoomAliases,
|
||||
actions: [
|
||||
if (adminMode)
|
||||
AlertDialogAction(label: L10n.of(context).create, key: 'new'),
|
||||
...aliases.result
|
||||
AlertDialogAction(label: L10n.of(context)!.create, key: 'new'),
|
||||
...aliases.result!
|
||||
.map((alias) => AlertDialogAction(key: alias, label: alias))
|
||||
.toList(),
|
||||
],
|
||||
|
|
@ -114,29 +114,30 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
title: select,
|
||||
actions: [
|
||||
AlertDialogAction(
|
||||
label: L10n.of(context).copyToClipboard,
|
||||
label: L10n.of(context)!.copyToClipboard,
|
||||
key: AliasActions.copy,
|
||||
isDefaultAction: true,
|
||||
),
|
||||
if (adminMode) ...{
|
||||
AlertDialogAction(
|
||||
label: L10n.of(context).setAsCanonicalAlias,
|
||||
label: L10n.of(context)!.setAsCanonicalAlias,
|
||||
key: AliasActions.setCanonical,
|
||||
isDestructiveAction: true,
|
||||
),
|
||||
AlertDialogAction(
|
||||
label: L10n.of(context).delete,
|
||||
label: L10n.of(context)!.delete,
|
||||
key: AliasActions.delete,
|
||||
isDestructiveAction: true,
|
||||
),
|
||||
},
|
||||
],
|
||||
);
|
||||
if (option == null) return;
|
||||
switch (option) {
|
||||
case AliasActions.copy:
|
||||
await Clipboard.setData(ClipboardData(text: select));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(L10n.of(context).copiedToClipboard)),
|
||||
SnackBar(content: Text(L10n.of(context)!.copiedToClipboard)),
|
||||
);
|
||||
break;
|
||||
case AliasActions.delete:
|
||||
|
|
@ -162,21 +163,21 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
}
|
||||
|
||||
void setAliasAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final domain = room.client.userID.domain;
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final domain = room.client.userID!.domain;
|
||||
|
||||
final input = await showTextInputDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context).setInvitationLink,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
title: L10n.of(context)!.setInvitationLink,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
prefixText: '#',
|
||||
suffixText: domain,
|
||||
hintText: L10n.of(context).alias,
|
||||
initialText: room.canonicalAlias?.localpart,
|
||||
hintText: L10n.of(context)!.alias,
|
||||
initialText: room.canonicalAlias.localpart,
|
||||
)
|
||||
],
|
||||
);
|
||||
|
|
@ -184,21 +185,21 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
room.client.setRoomAlias('#' + input.single + ':' + domain, room.id),
|
||||
room.client.setRoomAlias('#' + input.single + ':' + domain!, room.id),
|
||||
);
|
||||
}
|
||||
|
||||
void setTopicAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final input = await showTextInputDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context).setGroupDescription,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
title: L10n.of(context)!.setGroupDescription,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
hintText: L10n.of(context).setGroupDescription,
|
||||
hintText: L10n.of(context)!.setGroupDescription,
|
||||
initialText: room.topic,
|
||||
minLines: 1,
|
||||
maxLines: 4,
|
||||
|
|
@ -212,7 +213,7 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
);
|
||||
if (success.error == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(L10n.of(context).groupDescriptionHasBeenChanged)));
|
||||
content: Text(L10n.of(context)!.groupDescriptionHasBeenChanged)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +221,7 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.getRoomById(roomId)
|
||||
.getRoomById(roomId!)!
|
||||
.setGuestAccess(guestAccess),
|
||||
);
|
||||
|
||||
|
|
@ -229,7 +230,7 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.getRoomById(roomId)
|
||||
.getRoomById(roomId!)!
|
||||
.setHistoryVisibility(historyVisibility),
|
||||
);
|
||||
|
||||
|
|
@ -237,12 +238,12 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.getRoomById(roomId)
|
||||
.getRoomById(roomId!)!
|
||||
.setJoinRules(joinRule),
|
||||
);
|
||||
|
||||
void goToEmoteSettings() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
// 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.
|
||||
|
|
@ -256,24 +257,24 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
}
|
||||
|
||||
void setAvatarAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!);
|
||||
final actions = [
|
||||
if (PlatformInfos.isMobile)
|
||||
SheetAction(
|
||||
key: AvatarAction.camera,
|
||||
label: L10n.of(context).openCamera,
|
||||
label: L10n.of(context)!.openCamera,
|
||||
isDefaultAction: true,
|
||||
icon: Icons.camera_alt_outlined,
|
||||
),
|
||||
SheetAction(
|
||||
key: AvatarAction.file,
|
||||
label: L10n.of(context).openGallery,
|
||||
label: L10n.of(context)!.openGallery,
|
||||
icon: Icons.photo_outlined,
|
||||
),
|
||||
if (room?.avatar != null)
|
||||
SheetAction(
|
||||
key: AvatarAction.remove,
|
||||
label: L10n.of(context).delete,
|
||||
label: L10n.of(context)!.delete,
|
||||
isDestructiveAction: true,
|
||||
icon: Icons.delete_outlined,
|
||||
),
|
||||
|
|
@ -282,14 +283,14 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
? actions.single
|
||||
: await showModalActionSheet<AvatarAction>(
|
||||
context: context,
|
||||
title: L10n.of(context).editRoomAvatar,
|
||||
title: L10n.of(context)!.editRoomAvatar,
|
||||
actions: actions,
|
||||
);
|
||||
if (action == null) return;
|
||||
if (action == AvatarAction.remove) {
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setAvatar(null),
|
||||
future: () => room!.setAvatar(null),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -309,22 +310,22 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
} else {
|
||||
final result =
|
||||
await FilePickerCross.importFromStorage(type: FileTypeCross.image);
|
||||
if (result == null) return;
|
||||
if (result.fileName == null) return;
|
||||
file = MatrixFile(
|
||||
bytes: result.toUint8List(),
|
||||
name: result.fileName,
|
||||
name: result.fileName!,
|
||||
);
|
||||
}
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setAvatar(file),
|
||||
future: () => room!.setAvatar(file),
|
||||
);
|
||||
}
|
||||
|
||||
void requestMoreMembersAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!);
|
||||
final participants = await showFutureLoadingDialog(
|
||||
context: context, future: () => room.requestParticipants());
|
||||
context: context, future: () => room!.requestParticipants());
|
||||
if (participants.error == null) {
|
||||
setState(() => members = participants.result);
|
||||
}
|
||||
|
|
@ -334,7 +335,8 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
members ??= Matrix.of(context).client.getRoomById(roomId).getParticipants();
|
||||
members ??=
|
||||
Matrix.of(context).client.getRoomById(roomId!)!.getParticipants();
|
||||
return SizedBox(
|
||||
width: fixedWidth,
|
||||
child: ChatDetailsView(this),
|
||||
|
|
|
|||
|
|
@ -20,28 +20,28 @@ import '../../utils/url_launcher.dart';
|
|||
class ChatDetailsView extends StatelessWidget {
|
||||
final ChatDetailsController controller;
|
||||
|
||||
const ChatDetailsView(this.controller, {Key key}) : super(key: key);
|
||||
const ChatDetailsView(this.controller, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final room = Matrix.of(context).client.getRoomById(controller.roomId);
|
||||
final room = Matrix.of(context).client.getRoomById(controller.roomId!);
|
||||
if (room == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10n.of(context).oopsSomethingWentWrong),
|
||||
title: Text(L10n.of(context)!.oopsSomethingWentWrong),
|
||||
),
|
||||
body: Center(
|
||||
child: Text(L10n.of(context).youAreNoLongerParticipatingInThisChat),
|
||||
child: Text(L10n.of(context)!.youAreNoLongerParticipatingInThisChat),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
controller.members.removeWhere((u) => u.membership == Membership.leave);
|
||||
final actualMembersCount = (room.summary?.mInvitedMemberCount ?? 0) +
|
||||
(room.summary?.mJoinedMemberCount ?? 0);
|
||||
controller.members!.removeWhere((u) => u.membership == Membership.leave);
|
||||
final actualMembersCount = (room.summary.mInvitedMemberCount ?? 0) +
|
||||
(room.summary.mJoinedMemberCount ?? 0);
|
||||
final canRequestMoreMembers =
|
||||
controller.members.length < actualMembersCount;
|
||||
final iconColor = Theme.of(context).textTheme.bodyText1.color;
|
||||
controller.members!.length < actualMembersCount;
|
||||
final iconColor = Theme.of(context).textTheme.bodyText1!.color;
|
||||
return StreamBuilder(
|
||||
stream: room.onUpdate.stream,
|
||||
builder: (context, snapshot) {
|
||||
|
|
@ -56,16 +56,16 @@ class ChatDetailsView extends StatelessWidget {
|
|||
VRouter.of(context).path.startsWith('/spaces/')
|
||||
? VRouter.of(context).pop()
|
||||
: VRouter.of(context)
|
||||
.toSegments(['rooms', controller.roomId]),
|
||||
.toSegments(['rooms', controller.roomId!]),
|
||||
),
|
||||
elevation: Theme.of(context).appBarTheme.elevation,
|
||||
expandedHeight: 300.0,
|
||||
floating: true,
|
||||
pinned: true,
|
||||
actions: <Widget>[
|
||||
if (room.canonicalAlias?.isNotEmpty ?? false)
|
||||
if (room.canonicalAlias.isNotEmpty)
|
||||
IconButton(
|
||||
tooltip: L10n.of(context).share,
|
||||
tooltip: L10n.of(context)!.share,
|
||||
icon: Icon(Icons.adaptive.share_outlined),
|
||||
onPressed: () => FluffyShare.share(
|
||||
AppConfig.inviteLinkPrefix + room.canonicalAlias,
|
||||
|
|
@ -75,16 +75,17 @@ class ChatDetailsView extends StatelessWidget {
|
|||
],
|
||||
title: Text(
|
||||
room.getLocalizedDisplayname(
|
||||
MatrixLocals(L10n.of(context))),
|
||||
MatrixLocals(L10n.of(context)!)),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.appBarTheme
|
||||
.titleTextStyle
|
||||
.titleTextStyle!
|
||||
.color)),
|
||||
backgroundColor:
|
||||
Theme.of(context).appBarTheme.backgroundColor,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: ContentBanner(room.avatar,
|
||||
background: ContentBanner(
|
||||
mxContent: room.avatar,
|
||||
onEdit: room.canSendEvent('m.room.avatar')
|
||||
? controller.setAvatarAction
|
||||
: null),
|
||||
|
|
@ -93,7 +94,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
],
|
||||
body: MaxWidthBody(
|
||||
child: ListView.builder(
|
||||
itemCount: controller.members.length +
|
||||
itemCount: controller.members!.length +
|
||||
1 +
|
||||
(canRequestMoreMembers ? 1 : 0),
|
||||
itemBuilder: (BuildContext context, int i) => i == 0
|
||||
|
|
@ -111,15 +112,15 @@ class ChatDetailsView extends StatelessWidget {
|
|||
)
|
||||
: null,
|
||||
title: Text(
|
||||
'${L10n.of(context).groupDescription}:',
|
||||
'${L10n.of(context)!.groupDescription}:',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
fontWeight: FontWeight.bold)),
|
||||
subtitle: LinkText(
|
||||
text: room.topic?.isEmpty ?? true
|
||||
? L10n.of(context).addGroupDescription
|
||||
text: room.topic.isEmpty
|
||||
? L10n.of(context)!.addGroupDescription
|
||||
: room.topic,
|
||||
linkStyle:
|
||||
const TextStyle(color: Colors.blueAccent),
|
||||
|
|
@ -127,7 +128,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
fontSize: 14,
|
||||
color: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyText2
|
||||
.bodyText2!
|
||||
.color,
|
||||
),
|
||||
onLinkTap: (url) =>
|
||||
|
|
@ -141,7 +142,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
const Divider(height: 1),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context).settings,
|
||||
L10n.of(context)!.settings,
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.secondary,
|
||||
|
|
@ -163,10 +164,10 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: const Icon(
|
||||
Icons.people_outline_outlined),
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context).changeTheNameOfTheGroup),
|
||||
title: Text(L10n.of(context)!
|
||||
.changeTheNameOfTheGroup),
|
||||
subtitle: Text(room.getLocalizedDisplayname(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
onTap: controller.setDisplaynameAction,
|
||||
),
|
||||
if (room.joinRules == JoinRules.public)
|
||||
|
|
@ -178,11 +179,12 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: const Icon(Icons.link_outlined),
|
||||
),
|
||||
onTap: controller.editAliases,
|
||||
title: Text(L10n.of(context).editRoomAliases),
|
||||
title:
|
||||
Text(L10n.of(context)!.editRoomAliases),
|
||||
subtitle: Text(
|
||||
(room.canonicalAlias?.isNotEmpty ?? false)
|
||||
(room.canonicalAlias.isNotEmpty)
|
||||
? room.canonicalAlias
|
||||
: L10n.of(context).none),
|
||||
: L10n.of(context)!.none),
|
||||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
|
|
@ -192,9 +194,9 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: const Icon(
|
||||
Icons.insert_emoticon_outlined),
|
||||
),
|
||||
title: Text(L10n.of(context).emoteSettings),
|
||||
title: Text(L10n.of(context)!.emoteSettings),
|
||||
subtitle:
|
||||
Text(L10n.of(context).setCustomEmotes),
|
||||
Text(L10n.of(context)!.setCustomEmotes),
|
||||
onTap: controller.goToEmoteSettings,
|
||||
),
|
||||
PopupMenuButton(
|
||||
|
|
@ -206,14 +208,14 @@ class ChatDetailsView extends StatelessWidget {
|
|||
value: JoinRules.public,
|
||||
child: Text(JoinRules.public
|
||||
.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
),
|
||||
if (room.canChangeJoinRules)
|
||||
PopupMenuItem<JoinRules>(
|
||||
value: JoinRules.invite,
|
||||
child: Text(JoinRules.invite
|
||||
.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
),
|
||||
],
|
||||
child: ListTile(
|
||||
|
|
@ -222,11 +224,11 @@ class ChatDetailsView extends StatelessWidget {
|
|||
.scaffoldBackgroundColor,
|
||||
foregroundColor: iconColor,
|
||||
child: const Icon(Icons.shield_outlined)),
|
||||
title: Text(L10n.of(context)
|
||||
title: Text(L10n.of(context)!
|
||||
.whoIsAllowedToJoinThisGroup),
|
||||
subtitle: Text(
|
||||
room.joinRules.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context))),
|
||||
room.joinRules!.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)!)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -240,21 +242,21 @@ class ChatDetailsView extends StatelessWidget {
|
|||
value: HistoryVisibility.invited,
|
||||
child: Text(HistoryVisibility.invited
|
||||
.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
),
|
||||
if (room.canChangeHistoryVisibility)
|
||||
PopupMenuItem<HistoryVisibility>(
|
||||
value: HistoryVisibility.joined,
|
||||
child: Text(HistoryVisibility.joined
|
||||
.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
),
|
||||
if (room.canChangeHistoryVisibility)
|
||||
PopupMenuItem<HistoryVisibility>(
|
||||
value: HistoryVisibility.shared,
|
||||
child: Text(HistoryVisibility.shared
|
||||
.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
),
|
||||
if (room.canChangeHistoryVisibility)
|
||||
PopupMenuItem<HistoryVisibility>(
|
||||
|
|
@ -262,7 +264,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: Text(HistoryVisibility
|
||||
.worldReadable
|
||||
.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)))),
|
||||
MatrixLocals(L10n.of(context)!))),
|
||||
),
|
||||
],
|
||||
child: ListTile(
|
||||
|
|
@ -273,12 +275,11 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child:
|
||||
const Icon(Icons.visibility_outlined),
|
||||
),
|
||||
title: Text(L10n.of(context)
|
||||
title: Text(L10n.of(context)!
|
||||
.visibilityOfTheChatHistory),
|
||||
subtitle: Text(
|
||||
room.historyVisibility.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context))) ??
|
||||
'',
|
||||
room.historyVisibility!.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context)!)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -293,7 +294,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: Text(
|
||||
GuestAccess.canJoin
|
||||
.getLocalizedString(MatrixLocals(
|
||||
L10n.of(context))),
|
||||
L10n.of(context)!)),
|
||||
),
|
||||
),
|
||||
if (room.canChangeGuestAccess)
|
||||
|
|
@ -302,7 +303,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: Text(
|
||||
GuestAccess.forbidden
|
||||
.getLocalizedString(MatrixLocals(
|
||||
L10n.of(context))),
|
||||
L10n.of(context)!)),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -314,19 +315,19 @@ class ChatDetailsView extends StatelessWidget {
|
|||
child: const Icon(
|
||||
Icons.person_add_alt_1_outlined),
|
||||
),
|
||||
title: Text(L10n.of(context)
|
||||
title: Text(L10n.of(context)!
|
||||
.areGuestsAllowedToJoin),
|
||||
subtitle: Text(
|
||||
room.guestAccess.getLocalizedString(
|
||||
MatrixLocals(L10n.of(context))),
|
||||
MatrixLocals(L10n.of(context)!)),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title:
|
||||
Text(L10n.of(context).editChatPermissions),
|
||||
Text(L10n.of(context)!.editChatPermissions),
|
||||
subtitle: Text(
|
||||
L10n.of(context).whoCanPerformWhichAction),
|
||||
L10n.of(context)!.whoCanPerformWhichAction),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
|
|
@ -342,9 +343,9 @@ class ChatDetailsView extends StatelessWidget {
|
|||
ListTile(
|
||||
title: Text(
|
||||
actualMembersCount > 1
|
||||
? L10n.of(context).countParticipants(
|
||||
? L10n.of(context)!.countParticipants(
|
||||
actualMembersCount.toString())
|
||||
: L10n.of(context).emptyChat,
|
||||
: L10n.of(context)!.emptyChat,
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.secondary,
|
||||
|
|
@ -354,7 +355,8 @@ class ChatDetailsView extends StatelessWidget {
|
|||
),
|
||||
room.canInvite
|
||||
? ListTile(
|
||||
title: Text(L10n.of(context).inviteContact),
|
||||
title:
|
||||
Text(L10n.of(context)!.inviteContact),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Theme.of(context).primaryColor,
|
||||
|
|
@ -368,13 +370,13 @@ class ChatDetailsView extends StatelessWidget {
|
|||
: Container(),
|
||||
],
|
||||
)
|
||||
: i < controller.members.length + 1
|
||||
? ParticipantListItem(controller.members[i - 1])
|
||||
: i < controller.members!.length + 1
|
||||
? ParticipantListItem(controller.members![i - 1])
|
||||
: ListTile(
|
||||
title: Text(L10n.of(context)
|
||||
title: Text(L10n.of(context)!
|
||||
.loadCountMoreParticipants(
|
||||
(actualMembersCount -
|
||||
controller.members.length)
|
||||
controller.members!.length)
|
||||
.toString())),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
|
|
|
|||
|
|
@ -9,20 +9,20 @@ import '../user_bottom_sheet/user_bottom_sheet.dart';
|
|||
class ParticipantListItem extends StatelessWidget {
|
||||
final User user;
|
||||
|
||||
const ParticipantListItem(this.user, {Key key}) : super(key: key);
|
||||
const ParticipantListItem(this.user, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final membershipBatch = <Membership, String>{
|
||||
Membership.join: '',
|
||||
Membership.ban: L10n.of(context).banned,
|
||||
Membership.invite: L10n.of(context).invited,
|
||||
Membership.leave: L10n.of(context).leftTheChat,
|
||||
Membership.ban: L10n.of(context)!.banned,
|
||||
Membership.invite: L10n.of(context)!.invited,
|
||||
Membership.leave: L10n.of(context)!.leftTheChat,
|
||||
};
|
||||
final permissionBatch = user.powerLevel == 100
|
||||
? L10n.of(context).admin
|
||||
? L10n.of(context)!.admin
|
||||
: user.powerLevel >= 50
|
||||
? L10n.of(context).moderator
|
||||
? L10n.of(context)!.moderator
|
||||
: '';
|
||||
|
||||
return Opacity(
|
||||
|
|
@ -49,7 +49,7 @@ class ParticipantListItem extends StatelessWidget {
|
|||
),
|
||||
child: Center(child: Text(permissionBatch)),
|
||||
),
|
||||
membershipBatch[user.membership].isEmpty
|
||||
membershipBatch[user.membership]!.isEmpty
|
||||
? Container()
|
||||
: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
|
|
@ -59,7 +59,7 @@ class ParticipantListItem extends StatelessWidget {
|
|||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child:
|
||||
Center(child: Text(membershipBatch[user.membership])),
|
||||
Center(child: Text(membershipBatch[user.membership]!)),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue