refactor: Migrate to null safety
This commit is contained in:
parent
5269f04a99
commit
55f0300f9f
163 changed files with 1759 additions and 1903 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue