|
|
|
@ -104,228 +104,277 @@ class UserBottomSheetView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: ListView(
|
|
|
|
|
children: [
|
|
|
|
|
if (user?.membership == Membership.knock)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: Material(
|
|
|
|
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
|
child: ListTile(
|
|
|
|
|
minVerticalPadding: 16,
|
|
|
|
|
title: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 12.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
L10n.of(context)!
|
|
|
|
|
.userWouldLikeToChangeTheChat(displayname),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Row(
|
|
|
|
|
children: [
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
backgroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.background,
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.primary,
|
|
|
|
|
body: StreamBuilder<Object>(
|
|
|
|
|
stream: user?.room.client.onSync.stream.where(
|
|
|
|
|
(syncUpdate) =>
|
|
|
|
|
syncUpdate.rooms?.join?[user.room.id]?.timeline?.events?.any(
|
|
|
|
|
(state) => state.type == EventTypes.RoomPowerLevels,
|
|
|
|
|
) ??
|
|
|
|
|
false,
|
|
|
|
|
),
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
return ListView(
|
|
|
|
|
children: [
|
|
|
|
|
if (user?.membership == Membership.knock)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: Material(
|
|
|
|
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
|
child: ListTile(
|
|
|
|
|
minVerticalPadding: 16,
|
|
|
|
|
title: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 12.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
L10n.of(context)!
|
|
|
|
|
.userWouldLikeToChangeTheChat(displayname),
|
|
|
|
|
),
|
|
|
|
|
onPressed: controller.knockAccept,
|
|
|
|
|
icon: const Icon(Icons.check_outlined),
|
|
|
|
|
label: Text(L10n.of(context)!.accept),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
backgroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.errorContainer,
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
),
|
|
|
|
|
onPressed: controller.knockDecline,
|
|
|
|
|
icon: const Icon(Icons.cancel_outlined),
|
|
|
|
|
label: Text(L10n.of(context)!.decline),
|
|
|
|
|
subtitle: Row(
|
|
|
|
|
children: [
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
backgroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.background,
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.primary,
|
|
|
|
|
),
|
|
|
|
|
onPressed: controller.knockAccept,
|
|
|
|
|
icon: const Icon(Icons.check_outlined),
|
|
|
|
|
label: Text(L10n.of(context)!.accept),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
backgroundColor: Theme.of(context)
|
|
|
|
|
.colorScheme
|
|
|
|
|
.errorContainer,
|
|
|
|
|
foregroundColor: Theme.of(context)
|
|
|
|
|
.colorScheme
|
|
|
|
|
.onErrorContainer,
|
|
|
|
|
),
|
|
|
|
|
onPressed: controller.knockDecline,
|
|
|
|
|
icon: const Icon(Icons.cancel_outlined),
|
|
|
|
|
label: Text(L10n.of(context)!.decline),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Material(
|
|
|
|
|
elevation:
|
|
|
|
|
Theme.of(context).appBarTheme.scrolledUnderElevation ??
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Material(
|
|
|
|
|
elevation: Theme.of(context)
|
|
|
|
|
.appBarTheme
|
|
|
|
|
.scrolledUnderElevation ??
|
|
|
|
|
4,
|
|
|
|
|
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
side: BorderSide(
|
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
|
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
side: BorderSide(
|
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
Avatar.defaultSize * 2.5,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Avatar(
|
|
|
|
|
mxContent: avatarUrl,
|
|
|
|
|
name: displayname,
|
|
|
|
|
size: Avatar.defaultSize * 2.5,
|
|
|
|
|
fontSize: 18 * 2.5,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
Avatar.defaultSize * 2.5,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
onPressed: () => FluffyShare.share(
|
|
|
|
|
'https://matrix.to/#/$userId',
|
|
|
|
|
context,
|
|
|
|
|
),
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.adaptive.share_outlined,
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
label: Text(
|
|
|
|
|
displayname,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
// style: const TextStyle(fontSize: 18),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
onPressed: () => FluffyShare.share(
|
|
|
|
|
userId,
|
|
|
|
|
context,
|
|
|
|
|
copyOnly: true,
|
|
|
|
|
),
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.copy_outlined,
|
|
|
|
|
size: 14,
|
|
|
|
|
),
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.secondary,
|
|
|
|
|
),
|
|
|
|
|
label: Text(
|
|
|
|
|
userId,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
// style: const TextStyle(fontSize: 12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Avatar(
|
|
|
|
|
mxContent: avatarUrl,
|
|
|
|
|
name: displayname,
|
|
|
|
|
size: Avatar.defaultSize * 2.5,
|
|
|
|
|
fontSize: 18 * 2.5,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (userId != client.userID)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 16.0,
|
|
|
|
|
vertical: 8.0,
|
|
|
|
|
),
|
|
|
|
|
child: ElevatedButton.icon(
|
|
|
|
|
onPressed: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.message),
|
|
|
|
|
icon: const Icon(Icons.forum_outlined),
|
|
|
|
|
label: Text(
|
|
|
|
|
controller.widget.user == null
|
|
|
|
|
? L10n.of(context)!.startConversation
|
|
|
|
|
: L10n.of(context)!.sendAMessage,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
onPressed: () => FluffyShare.share(
|
|
|
|
|
'https://matrix.to/#/$userId',
|
|
|
|
|
context,
|
|
|
|
|
),
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.adaptive.share_outlined,
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
label: Text(
|
|
|
|
|
displayname,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
// style: const TextStyle(fontSize: 18),
|
|
|
|
|
PresenceBuilder(
|
|
|
|
|
userId: userId,
|
|
|
|
|
client: client,
|
|
|
|
|
builder: (context, presence) {
|
|
|
|
|
final status = presence?.statusMsg;
|
|
|
|
|
if (status == null || status.isEmpty) {
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
}
|
|
|
|
|
return ListTile(
|
|
|
|
|
title: SelectableLinkify(
|
|
|
|
|
text: status,
|
|
|
|
|
style: const TextStyle(fontSize: 16),
|
|
|
|
|
options: const LinkifyOptions(humanize: false),
|
|
|
|
|
linkStyle: const TextStyle(
|
|
|
|
|
color: Colors.blueAccent,
|
|
|
|
|
decorationColor: Colors.blueAccent,
|
|
|
|
|
),
|
|
|
|
|
onOpen: (url) =>
|
|
|
|
|
UrlLauncher(context, url.url).launchUrl(),
|
|
|
|
|
),
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
onPressed: () => FluffyShare.share(
|
|
|
|
|
userId,
|
|
|
|
|
context,
|
|
|
|
|
copyOnly: true,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (controller.widget.onMention != null)
|
|
|
|
|
ListTile(
|
|
|
|
|
leading: const Icon(Icons.alternate_email_outlined),
|
|
|
|
|
title: Text(L10n.of(context)!.mention),
|
|
|
|
|
onTap: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.mention),
|
|
|
|
|
),
|
|
|
|
|
if (user != null) ...[
|
|
|
|
|
Divider(height: 1, color: Theme.of(context).dividerColor),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(
|
|
|
|
|
'${L10n.of(context)!.userRole} (${user.powerLevel})',
|
|
|
|
|
),
|
|
|
|
|
leading: const Icon(Icons.person_outlined),
|
|
|
|
|
trailing: DropdownButton<int>(
|
|
|
|
|
onChanged: user.canChangePowerLevel
|
|
|
|
|
? controller.setPowerLevel
|
|
|
|
|
: null,
|
|
|
|
|
value: {0, 50, 100}.contains(user.powerLevel)
|
|
|
|
|
? user.powerLevel
|
|
|
|
|
: null,
|
|
|
|
|
items: [
|
|
|
|
|
DropdownMenuItem(
|
|
|
|
|
value: 0,
|
|
|
|
|
child: Text(L10n.of(context)!.user),
|
|
|
|
|
),
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.copy_outlined,
|
|
|
|
|
size: 14,
|
|
|
|
|
DropdownMenuItem(
|
|
|
|
|
value: 50,
|
|
|
|
|
child: Text(L10n.of(context)!.moderator),
|
|
|
|
|
),
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).colorScheme.secondary,
|
|
|
|
|
DropdownMenuItem(
|
|
|
|
|
value: 100,
|
|
|
|
|
child: Text(L10n.of(context)!.admin),
|
|
|
|
|
),
|
|
|
|
|
label: Text(
|
|
|
|
|
userId,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
// style: const TextStyle(fontSize: 12),
|
|
|
|
|
DropdownMenuItem(
|
|
|
|
|
value: null,
|
|
|
|
|
child: Text(L10n.of(context)!.custom),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (userId != client.userID)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 16.0,
|
|
|
|
|
vertical: 8.0,
|
|
|
|
|
),
|
|
|
|
|
child: ElevatedButton.icon(
|
|
|
|
|
onPressed: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.message),
|
|
|
|
|
icon: const Icon(Icons.forum_outlined),
|
|
|
|
|
label: Text(
|
|
|
|
|
controller.widget.user == null
|
|
|
|
|
? L10n.of(context)!.startConversation
|
|
|
|
|
: L10n.of(context)!.sendAMessage,
|
|
|
|
|
Divider(height: 1, color: Theme.of(context).dividerColor),
|
|
|
|
|
],
|
|
|
|
|
if (user != null && user.canKick)
|
|
|
|
|
ListTile(
|
|
|
|
|
textColor: Theme.of(context).colorScheme.error,
|
|
|
|
|
iconColor: Theme.of(context).colorScheme.error,
|
|
|
|
|
title: Text(L10n.of(context)!.kickFromChat),
|
|
|
|
|
leading: const Icon(Icons.exit_to_app_outlined),
|
|
|
|
|
onTap: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.kick),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
PresenceBuilder(
|
|
|
|
|
userId: userId,
|
|
|
|
|
client: client,
|
|
|
|
|
builder: (context, presence) {
|
|
|
|
|
final status = presence?.statusMsg;
|
|
|
|
|
if (status == null || status.isEmpty) {
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
}
|
|
|
|
|
return ListTile(
|
|
|
|
|
title: SelectableLinkify(
|
|
|
|
|
text: status,
|
|
|
|
|
style: const TextStyle(fontSize: 16),
|
|
|
|
|
options: const LinkifyOptions(humanize: false),
|
|
|
|
|
linkStyle: const TextStyle(
|
|
|
|
|
color: Colors.blueAccent,
|
|
|
|
|
decorationColor: Colors.blueAccent,
|
|
|
|
|
if (user != null &&
|
|
|
|
|
user.canBan &&
|
|
|
|
|
user.membership != Membership.ban)
|
|
|
|
|
ListTile(
|
|
|
|
|
textColor: Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
iconColor: Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
title: Text(L10n.of(context)!.banFromChat),
|
|
|
|
|
leading: const Icon(Icons.warning_sharp),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
controller.participantAction(UserBottomSheetAction.ban),
|
|
|
|
|
)
|
|
|
|
|
else if (user != null &&
|
|
|
|
|
user.canBan &&
|
|
|
|
|
user.membership == Membership.ban)
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.unbanFromChat),
|
|
|
|
|
leading: const Icon(Icons.warning_outlined),
|
|
|
|
|
onTap: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.unban),
|
|
|
|
|
),
|
|
|
|
|
if (user != null && user.id != client.userID)
|
|
|
|
|
ListTile(
|
|
|
|
|
textColor: Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
iconColor: Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
title: Text(L10n.of(context)!.reportUser),
|
|
|
|
|
leading: const Icon(Icons.report_outlined),
|
|
|
|
|
onTap: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.report),
|
|
|
|
|
),
|
|
|
|
|
if (profileSearchError != null)
|
|
|
|
|
ListTile(
|
|
|
|
|
leading: const Icon(
|
|
|
|
|
Icons.warning_outlined,
|
|
|
|
|
color: Colors.orange,
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
L10n.of(context)!.profileNotFound,
|
|
|
|
|
style: const TextStyle(color: Colors.orange),
|
|
|
|
|
),
|
|
|
|
|
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (controller.widget.onMention != null)
|
|
|
|
|
ListTile(
|
|
|
|
|
leading: const Icon(Icons.alternate_email_outlined),
|
|
|
|
|
title: Text(L10n.of(context)!.mention),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
controller.participantAction(UserBottomSheetAction.mention),
|
|
|
|
|
),
|
|
|
|
|
if (user != null && user.canChangePowerLevel)
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.setPermissionsLevel),
|
|
|
|
|
leading: const Icon(Icons.edit_attributes_outlined),
|
|
|
|
|
onTap: () => controller
|
|
|
|
|
.participantAction(UserBottomSheetAction.permission),
|
|
|
|
|
),
|
|
|
|
|
if (user != null && user.canKick)
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.kickFromChat),
|
|
|
|
|
leading: const Icon(Icons.exit_to_app_outlined),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
controller.participantAction(UserBottomSheetAction.kick),
|
|
|
|
|
),
|
|
|
|
|
if (user != null &&
|
|
|
|
|
user.canBan &&
|
|
|
|
|
user.membership != Membership.ban)
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.banFromChat),
|
|
|
|
|
leading: const Icon(Icons.warning_sharp),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
controller.participantAction(UserBottomSheetAction.ban),
|
|
|
|
|
)
|
|
|
|
|
else if (user != null &&
|
|
|
|
|
user.canBan &&
|
|
|
|
|
user.membership == Membership.ban)
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.unbanFromChat),
|
|
|
|
|
leading: const Icon(Icons.warning_outlined),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
controller.participantAction(UserBottomSheetAction.unban),
|
|
|
|
|
),
|
|
|
|
|
if (user != null && user.id != client.userID)
|
|
|
|
|
ListTile(
|
|
|
|
|
textColor: Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
iconColor: Theme.of(context).colorScheme.onErrorContainer,
|
|
|
|
|
title: Text(L10n.of(context)!.reportUser),
|
|
|
|
|
leading: const Icon(Icons.report_outlined),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
controller.participantAction(UserBottomSheetAction.report),
|
|
|
|
|
),
|
|
|
|
|
if (profileSearchError != null)
|
|
|
|
|
ListTile(
|
|
|
|
|
leading: const Icon(
|
|
|
|
|
Icons.warning_outlined,
|
|
|
|
|
color: Colors.orange,
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
L10n.of(context)!.profileNotFound,
|
|
|
|
|
style: const TextStyle(color: Colors.orange),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|