Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

feat(ui): open a contact's page from the contact list

baiyuze38f400ab8eae
diff --git a/ui/lib/pages/send_page.dart b/ui/lib/pages/send_page.dart
index 11650a5..357695e 100644
--- a/ui/lib/pages/send_page.dart
+++ b/ui/lib/pages/send_page.dart
@@ -1303,6 +1303,8 @@ class _PersonNodeState extends State<_PersonNode> {
onTap: () => f != null
? openFriendSend(context, f)
: showFriendSendDialog(context, SendTarget.stranger(st!)),
+ // 右键好友:打开好友页(状态、传输记录)
+ onSecondaryTap: f != null ? () => showFriendHistory(context, f) : null,
child: SizedBox(
width: 84,
child: Opacity(
diff --git a/ui/lib/widgets/friends_dialog.dart b/ui/lib/widgets/friends_dialog.dart
index f4ead6b..5511a0d 100644
--- a/ui/lib/widgets/friends_dialog.dart
+++ b/ui/lib/widgets/friends_dialog.dart
@@ -156,7 +156,10 @@ class _FriendRow extends StatelessWidget {
: l.friendNoActivity,
if (f.autoAccept) l.friendAutoAccept,
].join(' · ');
+ // 点一行打开这个好友的页面:状态、自动接收、和对方的传输记录
return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => showFriendHistory(context, f),
onSecondaryTapUp: (d) => _menu(context, d.globalPosition),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: Insets.sm),
@@ -645,14 +648,42 @@ class _FriendHistoryDialog extends StatelessWidget {
children: [
Row(
children: [
- PersonAvatar(deviceId: f.id, name: f.displayName, hash: f.avatarHash, size: 32),
+ PersonAvatar(deviceId: f.id, name: f.displayName, hash: f.avatarHash, size: 44),
const SizedBox(width: Insets.md),
- Expanded(child: Text(l.friendHistoryTitle(friendTitle(f)), style: context.text.titleMedium)),
- TextButton(onPressed: () => openFriendSend(context, f), child: Text(l.friendSendAction)),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(friendTitle(f), style: context.text.titleMedium, maxLines: 1, overflow: TextOverflow.ellipsis),
+ Text(friendStatus(l, state, f), style: context.text.bodySmall?.copyWith(color: p.textDim)),
+ ],
+ ),
+ ),
+ FilledButton(onPressed: () => openFriendSend(context, f), child: Text(l.friendSendAction)),
+ const SizedBox(width: Insets.xs),
IconAction(icon: AppIcons.xmark, tooltip: l.close, onTap: () => Navigator.pop(context)),
],
),
const SizedBox(height: Insets.md),
+ Padding(
+ padding: const EdgeInsets.only(right: Insets.md),
+ child: Row(
+ children: [
+ Expanded(child: Text(l.friendAutoAccept, style: context.text.bodyMedium)),
+ SmallSwitch(
+ value: f.autoAccept,
+ onChanged: (v) => state.setFriendAutoAccept(f.id, v).catchError((Object e) {
+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);
+ }),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: Insets.md),
+ Divider(height: 1, color: p.separator),
+ const SizedBox(height: Insets.md),
+ Text(l.friendHistory, style: context.text.titleSmall),
+ const SizedBox(height: Insets.xs),
if (list.isEmpty)
Padding(
padding: const EdgeInsets.all(Insets.xl),
diff --git a/ui/test/friends_test.dart b/ui/test/friends_test.dart
index cfe37b0..d3f997c 100644
--- a/ui/test/friends_test.dart
+++ b/ui/test/friends_test.dart
@@ -7,12 +7,17 @@ import 'package:pasteferry_ui/gen/pasteferry/v1/daemon.pb.dart';
import 'package:pasteferry_ui/i18n.dart';
import 'package:pasteferry_ui/main.dart';
import 'package:pasteferry_ui/widgets/friend_send_dialog.dart';
+import 'package:pasteferry_ui/widgets/common.dart';
import 'package:pasteferry_ui/widgets/friends_dialog.dart';
/// 记下界面调了哪些好友相关的操作,不连后台服务
class _FriendsState extends AppState {
final answers = <(String, bool, bool)>[];
final receiveFromCalls = <String>[];
+ final autoCalls = <(String, bool)>[];
+
+ @override
+ Future<void> setFriendAutoAccept(String id, bool auto) async => autoCalls.add((id, auto));
@override
Future<void> answerIncoming(String transferId, bool accept, {bool always = false}) async {
@@ -178,4 +183,22 @@ void main() {
expect(friendCanSend(_xiaoming), isTrue);
expect(friendCanSend(_ajie), isFalse);
});
+
+ testWidgets('好友列表里点一个好友:打开好友页,能开自动接收、看传输记录', (tester) async {
+ final state = _demo();
+ await openSend(tester, state);
+ final ctx = tester.element(find.byType(Shell));
+ final l = AppLocalizations.of(ctx);
+ showFriendsDialog(ctx);
+ await _settle(tester);
+ await tester.tap(find.text('小明 · MacBook Air'));
+ await _settle(tester);
+ expect(find.text(l.friendHistory), findsOneWidget);
+ expect(find.text(l.friendAutoAccept), findsOneWidget);
+ await tester.tap(find.descendant(
+ of: find.ancestor(of: find.text(l.friendAutoAccept), matching: find.byType(Row)).first,
+ matching: find.byType(SmallSwitch)));
+ await _settle(tester);
+ expect(state.autoCalls, [('xm', true)]);
+ });
}
diff --git a/ui/tool/screenshots/screenshots_test.dart b/ui/tool/screenshots/screenshots_test.dart
index ea3ca25..415af80 100644
--- a/ui/tool/screenshots/screenshots_test.dart
+++ b/ui/tool/screenshots/screenshots_test.dart
@@ -554,6 +554,16 @@ void main() {
});
});
+ testWidgets('friend-page-dark', (tester) async {
+ final state = _friendsDemo();
+ await _shoot(tester, 'friend-page-dark', state: state, section: Section.send, settle: false,
+ brightness: Brightness.dark, window: const Size(1180, 720), arrange: () async {
+ showFriendHistory(tester.element(find.byType(Shell)), state.friends.first);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 400));
+ });
+ });
+
testWidgets('add-friend-dark', (tester) async {
await _shoot(tester, 'add-friend-dark', state: _friendsDemo(), section: Section.send, settle: false,
brightness: Brightness.dark, window: const Size(1180, 720), arrange: () async {