Publisher popover

This commit is contained in:
LittleSheep 2024-12-01 20:08:04 +08:00
parent 000caf4dd2
commit 32739821ba
6 changed files with 139 additions and 3 deletions

View File

@ -99,6 +99,10 @@
"publishersNew": "New Publisher",
"publisherNewSubtitle": "Create a new publisher identity.",
"publisherSyncWithAccount": "Sync with account",
"publisherTotalUpvote": "Upvote",
"publisherTotalDownvote": "Downvote",
"publisherSocialPoint": "Social Point",
"publisherJoinedAt": "Joined At",
"fieldPublisherBelongToRealm": "Belongs to",
"fieldPublisherBelongToRealmUnset": "Unset Publisher Belongs to Realm",
"writePostTypeStory": "Post a story",

View File

@ -99,6 +99,10 @@
"publishersNew": "新发布者",
"publisherNewSubtitle": "创建一个新的公共身份。",
"publisherSyncWithAccount": "同步账户信息",
"publisherTotalUpvote": "总顶数",
"publisherTotalDownvote": "总踩数",
"publisherSocialPoint": "社会信用点",
"publisherJoinedAt": "加入于",
"fieldPublisherBelongToRealm": "所属领域",
"fieldPublisherBelongToRealmUnset": "未设置发布者所属领域",
"writePostTypeStory": "发动态",

View File

@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:popover/popover.dart';
import 'package:provider/provider.dart';
import 'package:relative_time/relative_time.dart';
import 'package:styled_widget/styled_widget.dart';
@ -15,6 +16,7 @@ import 'package:surface/widgets/markdown_content.dart';
import 'package:gap/gap.dart';
import 'package:surface/widgets/post/post_comment_list.dart';
import 'package:surface/widgets/post/post_reaction.dart';
import 'package:surface/widgets/post/publisher_popover.dart';
class PostItem extends StatelessWidget {
final SnPost data;
@ -264,9 +266,27 @@ class _PostContentHeader extends StatelessWidget {
return Row(
children: [
AccountImage(
content: data.publisher.avatar,
radius: isCompact ? 12 : 20,
GestureDetector(
child: AccountImage(
content: data.publisher.avatar,
radius: isCompact ? 12 : 20,
),
onTap: () {
showPopover(
context: context,
transition: PopoverTransition.other,
bodyBuilder: (context) => SizedBox(
width: 400,
child: PublisherPopoverCard(
data: data.publisher,
).padding(horizontal: 16, vertical: 16),
),
direction: PopoverDirection.bottom,
arrowHeight: 5,
arrowWidth: 15,
arrowDxOffset: -190,
);
},
),
Gap(isCompact ? 8 : 12),
if (isCompact)

View File

@ -0,0 +1,99 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:surface/types/post.dart';
import 'package:surface/widgets/account/account_image.dart';
class PublisherPopoverCard extends StatelessWidget {
final SnPublisher data;
const PublisherPopoverCard({super.key, required this.data});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AccountImage(
content: data.avatar,
radius: 20,
),
Gap(16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(data.nick).bold(),
Text('@${data.name}').fontSize(13).opacity(0.75),
],
),
),
IconButton(
onPressed: () {},
icon: const Icon(Symbols.chevron_right),
padding: EdgeInsets.zero,
visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
),
const Gap(8)
],
),
const Gap(16),
Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('publisherSocialPoint').tr().fontSize(13).opacity(0.75),
Text((data.totalUpvote - data.totalDownvote).toString()),
],
),
),
SizedBox(
height: 20,
child: const VerticalDivider(
thickness: 1,
),
).padding(horizontal: 8),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('publisherTotalUpvote').tr().fontSize(13).opacity(0.75),
Text(data.totalUpvote.toString()),
],
),
),
SizedBox(
height: 20,
child: const VerticalDivider(
thickness: 1,
),
).padding(horizontal: 8),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('publisherTotalDownvote')
.tr()
.fontSize(13)
.opacity(0.75),
Text(data.totalDownvote.toString()),
],
),
),
],
),
],
);
}
}

View File

@ -1330,6 +1330,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.5.1"
popover:
dependency: "direct main"
description:
name: popover
sha256: "0606f3e10f92fc0459f5c52fd917738c29e7552323b28694d50c2d3312d0e1a2"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
protobuf:
dependency: transitive
description:

View File

@ -93,6 +93,7 @@ dependencies:
wakelock_plus: ^1.2.8
permission_handler: ^11.3.1
flutter_staggered_grid_view: ^0.7.0
popover: ^0.3.1
dev_dependencies:
flutter_test: