chore: Follow up user dialog

This commit is contained in:
Christian Kußowski 2026-02-25 08:25:34 +01:00
commit ad7a2d9a01
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -11,6 +11,7 @@ import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/fluffy_share.dart';
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/presence_builder.dart';
import '../../utils/url_launcher.dart';
@ -47,9 +48,7 @@ class UserDialog extends StatelessWidget {
final theme = Theme.of(context);
final avatar = profile.avatarUrl;
return AlertDialog.adaptive(
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: PresenceBuilder(
content: PresenceBuilder(
userId: profile.userId,
client: Matrix.of(context).client,
builder: (context, presence) {
@ -59,9 +58,9 @@ class UserDialog extends StatelessWidget {
final presenceText = presence.currentlyActive == true
? L10n.of(context).currentlyActive
: lastActiveTimestamp != null
? L10n.of(context).lastActiveAgo(
lastActiveTimestamp.localizedTimeShort(context),
)
? L10n.of(
context,
).lastActiveAgo(lastActiveTimestamp.localizedTimeShort(context))
: null;
return Column(
spacing: 16,
@ -115,10 +114,9 @@ class UserDialog extends StatelessWidget {
right: 4.0,
),
child: AnimatedScale(
duration: FluffyThemes
.animationDuration,
curve:
FluffyThemes.animationCurve,
duration:
FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
scale: hovered
? 1.33
: copied
@ -138,8 +136,9 @@ class UserDialog extends StatelessWidget {
),
TextSpan(text: profile.userId),
],
style: theme.textTheme.bodyMedium
?.copyWith(fontSize: 10),
style: theme.textTheme.bodyMedium?.copyWith(
fontSize: 10,
),
),
maxLines: 1,
overflow: .ellipsis,
@ -179,22 +178,7 @@ class UserDialog extends StatelessWidget {
mainAxisAlignment: .spaceBetween,
spacing: 4,
children: [
_IconTextButton(
label: L10n.of(context).chat,
icon: Icons.chat_outlined,
onTap: () async {
final router = GoRouter.of(context);
final roomIdResult = await showFutureLoadingDialog(
context: context,
future: () => client.startDirectChat(profile.userId),
);
final roomId = roomIdResult.result;
if (roomId == null) return;
if (context.mounted) Navigator.of(context).pop();
router.go('/rooms/$roomId');
},
),
_IconTextButton(
_AdaptiveIconTextButton(
label: L10n.of(context).block,
icon: Icons.block_outlined,
onTap: () {
@ -206,27 +190,96 @@ class UserDialog extends StatelessWidget {
);
},
),
_IconTextButton(
_AdaptiveIconTextButton(
label: L10n.of(context).report,
icon: Icons.gavel_outlined,
onTap: () async {
Navigator.of(context).pop();
final reason = await showTextInputDialog(
context: context,
title: L10n.of(context).whyDoYouWantToReportThis,
okLabel: L10n.of(context).report,
cancelLabel: L10n.of(context).cancel,
hintText: L10n.of(context).reason,
);
if (reason == null || reason.isEmpty) return;
await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(
context,
).client.reportUser(profile.userId, reason),
);
},
),
_AdaptiveIconTextButton(
label: L10n.of(context).share,
icon: Icons.adaptive.share,
onTap: () => FluffyShare.share(profile.userId, context),
),
],
),
_AdaptiveDialogInkWell(
onTap: () async {
final router = GoRouter.of(context);
final roomIdResult = await showFutureLoadingDialog(
context: context,
future: () => client.startDirectChat(profile.userId),
);
final roomId = roomIdResult.result;
if (roomId == null) return;
if (context.mounted) Navigator.of(context).pop();
router.go('/rooms/$roomId');
},
child: Text(
L10n.of(context).sendAMessage,
style: TextStyle(color: theme.colorScheme.secondary),
),
),
],
);
},
),
);
}
}
class _AdaptiveDialogInkWell extends StatelessWidget {
final Widget child;
final VoidCallback onTap;
const _AdaptiveDialogInkWell({required this.onTap, required this.child});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
if ({TargetPlatform.iOS, TargetPlatform.macOS}.contains(theme.platform)) {
return CupertinoButton(
onPressed: onTap,
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
color: theme.colorScheme.surfaceBright,
padding: EdgeInsets.all(8),
child: child,
);
}
return Material(
color: theme.colorScheme.surfaceBright,
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
child: InkWell(
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(child: child),
),
),
);
}
}
class _IconTextButton extends StatelessWidget {
class _AdaptiveIconTextButton extends StatelessWidget {
final String label;
final IconData icon;
final VoidCallback onTap;
const _IconTextButton({
const _AdaptiveIconTextButton({
required this.label,
required this.icon,
required this.onTap,
@ -234,20 +287,17 @@ class _IconTextButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final color = Theme.of(context).colorScheme.secondary;
return Expanded(
child: CupertinoButton(
onPressed: onTap,
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
color: theme.colorScheme.surfaceBright,
padding: EdgeInsets.all(8),
child: _AdaptiveDialogInkWell(
onTap: onTap,
child: Column(
mainAxisSize: .min,
children: [
Icon(icon),
Icon(icon, color: color),
Text(
label,
style: TextStyle(fontSize: 12),
style: TextStyle(fontSize: 12, color: color),
maxLines: 1,
overflow: .ellipsis,
),