♻️ Refactor account badge showing
This commit is contained in:
@ -29,6 +29,7 @@ import 'package:surface/types/attachment.dart';
|
||||
import 'package:surface/types/post.dart';
|
||||
import 'package:surface/types/reaction.dart';
|
||||
import 'package:surface/widgets/account/account_image.dart';
|
||||
import 'package:surface/widgets/account/badge.dart';
|
||||
import 'package:surface/widgets/attachment/attachment_item.dart';
|
||||
import 'package:surface/widgets/attachment/attachment_list.dart';
|
||||
import 'package:surface/widgets/dialog.dart';
|
||||
@ -43,8 +44,6 @@ import 'package:surface/widgets/post/publisher_popover.dart';
|
||||
import 'package:surface/widgets/universal_image.dart';
|
||||
import 'package:xml/xml.dart';
|
||||
|
||||
import '../../screens/account/profile_page.dart' show kBadgesMeta;
|
||||
|
||||
class OpenablePostItem extends StatelessWidget {
|
||||
final SnPost data;
|
||||
final bool showReactions;
|
||||
@ -887,7 +886,7 @@ class _PostContentHeader extends StatelessWidget {
|
||||
'publisherId': data.publisherId,
|
||||
});
|
||||
if (!context.mounted) return;
|
||||
context.showSnackbar('postDeleted'.tr(args: ['#${data.id}']));
|
||||
onDeleted.call();
|
||||
} catch (err) {
|
||||
if (!context.mounted) return;
|
||||
context.showErrorDialog(err);
|
||||
@ -930,19 +929,10 @@ class _PostContentHeader extends StatelessWidget {
|
||||
borderRadius:
|
||||
data.publisher.type == 1 ? (isCompact ? 4 : 8) : 20,
|
||||
badge: (user?.badges.isNotEmpty ?? false)
|
||||
? Icon(
|
||||
kBadgesMeta[user!.badges.first.type]?.$2 ??
|
||||
Symbols.question_mark,
|
||||
color: kBadgesMeta[user.badges.first.type]?.$3,
|
||||
fill: 1,
|
||||
size: 18,
|
||||
shadows: [
|
||||
Shadow(
|
||||
offset: Offset(1, 1),
|
||||
blurRadius: 5.0,
|
||||
color: Color.fromARGB(200, 0, 0, 0),
|
||||
),
|
||||
],
|
||||
? AccountBadge(
|
||||
badge: user!.badges.first,
|
||||
radius: 16,
|
||||
padding: EdgeInsets.all(2),
|
||||
)
|
||||
: null,
|
||||
)
|
||||
|
@ -9,10 +9,9 @@ import 'package:surface/providers/sn_network.dart';
|
||||
import 'package:surface/providers/user_directory.dart';
|
||||
import 'package:surface/types/post.dart';
|
||||
import 'package:surface/widgets/account/account_image.dart';
|
||||
import 'package:surface/widgets/account/badge.dart';
|
||||
import 'package:surface/widgets/universal_image.dart';
|
||||
|
||||
import '../../screens/account/profile_page.dart' show kBadgesMeta;
|
||||
|
||||
class PublisherPopoverCard extends StatelessWidget {
|
||||
final SnPublisher data;
|
||||
|
||||
@ -76,39 +75,22 @@ class PublisherPopoverCard extends StatelessWidget {
|
||||
const Gap(8)
|
||||
],
|
||||
).padding(horizontal: 16),
|
||||
if (user != null && user.badges.isNotEmpty) const Gap(16),
|
||||
if (user != null && user.badges.isNotEmpty)
|
||||
Wrap(
|
||||
spacing: 4,
|
||||
children: user.badges
|
||||
.map(
|
||||
(ele) => Tooltip(
|
||||
richMessage: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: kBadgesMeta[ele.type]?.$1.tr() ??
|
||||
'unknown'.tr()),
|
||||
if (ele.metadata['title'] != null)
|
||||
TextSpan(
|
||||
text: '\n${ele.metadata['title']}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: DateFormat.yMEd().format(ele.createdAt),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
kBadgesMeta[ele.type]?.$2 ?? Symbols.question_mark,
|
||||
color: kBadgesMeta[ele.type]?.$3,
|
||||
fill: 1,
|
||||
),
|
||||
),
|
||||
(ele) => AccountBadge(badge: ele),
|
||||
)
|
||||
.toList(),
|
||||
).padding(horizontal: 24),
|
||||
).padding(horizontal: 24, top: 16),
|
||||
const Gap(16),
|
||||
if (data.description.isNotEmpty)
|
||||
Text(
|
||||
data.description,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
).padding(horizontal: 26, bottom: 20),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
Reference in New Issue
Block a user