|
|
|
@ -4,6 +4,8 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/pages/invitation_selection/invitation_selection.dart';
|
|
|
|
|
import 'package:fluffychat/pages/user_bottom_sheet/user_bottom_sheet.dart';
|
|
|
|
|
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
@ -87,12 +89,7 @@ class InvitationSelectionView extends StatelessWidget {
|
|
|
|
|
itemCount: controller.foundProfiles.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int i) =>
|
|
|
|
|
_InviteContactListTile(
|
|
|
|
|
avatarUrl: controller.foundProfiles[i].avatarUrl,
|
|
|
|
|
displayname: controller
|
|
|
|
|
.foundProfiles[i].displayName ??
|
|
|
|
|
controller.foundProfiles[i].userId.localpart ??
|
|
|
|
|
L10n.of(context).user,
|
|
|
|
|
userId: controller.foundProfiles[i].userId,
|
|
|
|
|
profile: controller.foundProfiles[i],
|
|
|
|
|
isMember: participants
|
|
|
|
|
.contains(controller.foundProfiles[i].userId),
|
|
|
|
|
onTap: () => controller.inviteAction(
|
|
|
|
@ -121,11 +118,14 @@ class InvitationSelectionView extends StatelessWidget {
|
|
|
|
|
itemCount: contacts.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int i) =>
|
|
|
|
|
_InviteContactListTile(
|
|
|
|
|
avatarUrl: contacts[i].avatarUrl,
|
|
|
|
|
displayname: contacts[i].displayName ??
|
|
|
|
|
contacts[i].id.localpart ??
|
|
|
|
|
L10n.of(context).user,
|
|
|
|
|
userId: contacts[i].id,
|
|
|
|
|
user: contacts[i],
|
|
|
|
|
profile: Profile(
|
|
|
|
|
avatarUrl: contacts[i].avatarUrl,
|
|
|
|
|
displayName: contacts[i].displayName ??
|
|
|
|
|
contacts[i].id.localpart ??
|
|
|
|
|
L10n.of(context).user,
|
|
|
|
|
userId: contacts[i].id,
|
|
|
|
|
),
|
|
|
|
|
isMember: participants.contains(contacts[i].id),
|
|
|
|
|
onTap: () => controller.inviteAction(
|
|
|
|
|
context,
|
|
|
|
@ -148,16 +148,14 @@ class InvitationSelectionView extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InviteContactListTile extends StatelessWidget {
|
|
|
|
|
final String userId;
|
|
|
|
|
final String displayname;
|
|
|
|
|
final Uri? avatarUrl;
|
|
|
|
|
final Profile profile;
|
|
|
|
|
final User? user;
|
|
|
|
|
final bool isMember;
|
|
|
|
|
final void Function() onTap;
|
|
|
|
|
|
|
|
|
|
const _InviteContactListTile({
|
|
|
|
|
required this.userId,
|
|
|
|
|
required this.displayname,
|
|
|
|
|
required this.avatarUrl,
|
|
|
|
|
required this.profile,
|
|
|
|
|
this.user,
|
|
|
|
|
required this.isMember,
|
|
|
|
|
required this.onTap,
|
|
|
|
|
});
|
|
|
|
@ -165,32 +163,39 @@ class _InviteContactListTile extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
final l10n = L10n.of(context);
|
|
|
|
|
|
|
|
|
|
return Opacity(
|
|
|
|
|
opacity: isMember ? 0.5 : 1,
|
|
|
|
|
child: ListTile(
|
|
|
|
|
leading: Avatar(
|
|
|
|
|
mxContent: avatarUrl,
|
|
|
|
|
name: displayname,
|
|
|
|
|
presenceUserId: userId,
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
displayname,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
userId,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: theme.colorScheme.secondary,
|
|
|
|
|
return ListTile(
|
|
|
|
|
leading: Avatar(
|
|
|
|
|
mxContent: profile.avatarUrl,
|
|
|
|
|
name: profile.displayName,
|
|
|
|
|
presenceUserId: profile.userId,
|
|
|
|
|
onTap: () => showAdaptiveBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (c) => UserBottomSheet(
|
|
|
|
|
user: user,
|
|
|
|
|
profile: profile,
|
|
|
|
|
outerContext: context,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onTap: isMember ? null : onTap,
|
|
|
|
|
trailing: isMember
|
|
|
|
|
? Text(L10n.of(context).participant)
|
|
|
|
|
: const Icon(Icons.person_add_outlined),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
profile.displayName ?? profile.userId.localpart ?? l10n.user,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
profile.userId,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: theme.colorScheme.secondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing: TextButton.icon(
|
|
|
|
|
onPressed: isMember ? null : onTap,
|
|
|
|
|
label: Text(isMember ? l10n.participant : l10n.invite),
|
|
|
|
|
icon: Icon(isMember ? Icons.check : Icons.add),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|