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): contacts, avatars and accepting files from contacts

baiyuzefe218d0c9496
diff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dart
index 02106f5..2ea5cd1 100644
--- a/ui/lib/app_state.dart
+++ b/ui/lib/app_state.dart
@@ -26,6 +26,7 @@ enum SendFailure {
needRelayConsent,
noPaths,
unknownDevice,
+ badNote,
other,
}
@@ -36,6 +37,11 @@ enum PairingFailure {
codeExpired,
badAddress,
noChannel,
+ // 加好友(2.6.0):码的用途不对、对方版本太旧、已经是自己的设备
+ friendCode,
+ deviceCode,
+ peerOutdated,
+ alreadyPaired,
other,
}
@@ -105,6 +111,24 @@ class AppState extends ChangeNotifier implements RecordDetails {
Device? _pendingPairing;
final Set<String> _handledPairingSessions = {};
+ /// 好友(2.6.0),见 design/friends-send.md
+ List<Friend> _friends = const [];
+ Profile? _profile;
+
+ /// 有人兑换了本机的好友码,等用户确认;非空时界面弹出确认框
+ FriendRequest? _pendingFriend;
+ final Set<String> _handledFriendSessions = {};
+
+ /// 加好友时对方取消了的设备(确认框据此关掉并提示)
+ final Set<String> _friendCancelled = {};
+
+ /// 头像:设备 ID(本机为空字符串)→ (哈希, 图片)。哈希变了再取
+ final Map<String, (String, Uint8List?)> _avatars = {};
+ final Set<String> _avatarLoading = {};
+
+ /// 别人发来、等用户接受的批次里,用户在弹窗里处理过的
+ final Set<String> _handledAsks = {};
+
/// 连不上后台服务时,它的安装状态。界面据此决定显示欢迎页还是重启提示。
ServiceState? _serviceState;
bool _serviceChecked = false;
@@ -173,12 +197,20 @@ class AppState extends ChangeNotifier implements RecordDetails {
const {
'scanning',
'waiting',
+ 'asking',
'active',
'queued',
}.contains(t.status),
)
.lastOrNull;
+ /// 让主窗口切到某一页("send"、"settings"),比如好友连不上时点了「打开服务…」
+ void requestPage(String page) {
+ _pageRequest = page;
+ _pageRequestSerial++;
+ notifyListeners();
+ }
+
String get pageRequest => _pageRequest;
int get pageRequestSerial => _pageRequestSerial;
@@ -199,6 +231,36 @@ class AppState extends ChangeNotifier implements RecordDetails {
Device? get pendingPairing => _pendingPairing;
ServiceState? get serviceState => _serviceState;
+ List<Friend> get friends => List.unmodifiable(_friends);
+ Friend? friendById(String id) => _friends.where((f) => f.id == id).firstOrNull;
+ Profile? get profile => _profile;
+ FriendRequest? get pendingFriendRequest => _pendingFriend;
+ bool friendCancelled(String deviceId) => _friendCancelled.contains(deviceId);
+
+ /// 好友、陌生设备发来、在等本机用户接受的批次(最早的在前)
+ List<Transfer> get askingIncoming => _transfers
+ .where((t) =>
+ t.direction == TransferDirection.TRANSFER_DIRECTION_INCOMING &&
+ t.status == 'asking' &&
+ !_handledAsks.contains(t.id))
+ .toList()
+ .reversed
+ .toList();
+
+ /// 谁可以给我发文件:off / friends / everyone(「所有人」过了时间由后台服务改回 friends)
+ String get receiveFrom {
+ final v = _config?.receiveFrom ?? '';
+ return v.isEmpty ? 'friends' : v;
+ }
+
+ /// 「所有人」到什么时候;没开时为 null
+ DateTime? get everyoneUntil {
+ final until = _config?.everyoneUntilUnix.toInt() ?? 0;
+ return receiveFrom == 'everyone' && until > 0
+ ? DateTime.fromMillisecondsSinceEpoch(until * 1000)
+ : null;
+ }
+
bool get isOnline => _link == LinkState.online;
int get onlinePeerCount => _peers.where((p) => p.online).length;
@@ -319,6 +381,7 @@ class AppState extends ChangeNotifier implements RecordDetails {
await _loadQuickPasteStatus();
await _loadDevices();
+ await _loadFriends();
await _loadTransfers();
await refreshNotificationStatus();
@@ -459,7 +522,13 @@ class AppState extends ChangeNotifier implements RecordDetails {
ServiceState? serviceState,
QuickPasteStatus? quickPaste,
List<Transfer> transfers = const [],
+ List<Friend> friends = const [],
+ Profile? profile,
+ FriendRequest? pendingFriend,
}) {
+ _friends = friends;
+ _profile = profile;
+ _pendingFriend = pendingFriend;
_status = status;
_config = config;
_self = self;
@@ -519,6 +588,23 @@ class AppState extends ChangeNotifier implements RecordDetails {
}
}
+ Future<void> _loadFriends() async {
+ final conn = _conn;
+ if (conn == null) return;
+ try {
+ final results = await Future.wait([
+ conn.client.listFriends(Empty()),
+ conn.client.getProfile(Empty()),
+ ]);
+ _friends = (results[0] as ListFriendsResponse).friends;
+ _profile = results[1] as Profile;
+ } on GrpcError {
+ // 旧版后台服务没有好友
+ _friends = const [];
+ _profile = null;
+ }
+ }
+
void _scheduleRetry(String message) {
if (_quitting) return;
_events?.cancel();
@@ -595,6 +681,32 @@ class AppState extends ChangeNotifier implements RecordDetails {
_pageRequest = ev.navigate;
_pageRequestSerial++;
+ case Event_Payload.friendChanged:
+ final f = ev.friendChanged;
+ final i = _friends.indexWhere((x) => x.id == f.id);
+ final next = List<Friend>.from(_friends);
+ if (i >= 0) {
+ next[i] = f;
+ } else {
+ next.add(f);
+ }
+ _friends = next;
+ _friendCancelled.remove(f.id);
+
+ case Event_Payload.friendRemoved:
+ _friends = _friends.where((f) => f.id != ev.friendRemoved).toList();
+ _friendCancelled.add(ev.friendRemoved);
+ if (_pendingFriend?.deviceId == ev.friendRemoved) _pendingFriend = null;
+
+ case Event_Payload.friendRequest:
+ if (!_handledFriendSessions.contains(ev.friendRequest.session)) {
+ _pendingFriend = ev.friendRequest;
+ _friendCancelled.remove(ev.friendRequest.deviceId);
+ }
+
+ case Event_Payload.profileChanged:
+ _profile = ev.profileChanged;
+
default:
break;
}
@@ -771,6 +883,133 @@ class AppState extends ChangeNotifier implements RecordDetails {
notifyListeners();
}
+ // ─────────────────────────── 好友 ───────────────────────────
+
+ /// 生成好友码(F 加 6 位),以及本机的局域网地址
+ Future<PairingCode> createFriendCode() async {
+ final resp = await _client.createFriendCode(Empty());
+ return (code: resp.code, addresses: resp.lanAddresses.toList());
+ }
+
+ /// 输入好友码,返回对方的名片;之后在确认框里 [confirmFriend]
+ Future<FriendRequest> redeemFriendCode(String code, {String address = ''}) async {
+ final r = await _client.redeemFriendCode(
+ RedeemPairingCodeRequest(code: code.trim().toUpperCase(), address: address.trim()),
+ // 局域网里找几秒,找不到去服务器上兑换,还要等对方说明用途
+ options: CallOptions(timeout: const Duration(seconds: 40)),
+ );
+ _handledFriendSessions.add(r.session);
+ _friendCancelled.remove(r.deviceId);
+ return r;
+ }
+
+ /// 确认框里点了「添加」或「取消」。两边都添加了,好友会经事件出现在列表里
+ Future<void> confirmFriend(String session, bool accept) async {
+ _handledFriendSessions.add(session);
+ if (_pendingFriend?.session == session) _pendingFriend = null;
+ notifyListeners();
+ await _client.confirmFriend(ConfirmPairingRequest(pairingSession: session, accept: accept));
+ }
+
+ void dismissPendingFriend() {
+ final s = _pendingFriend?.session;
+ if (s != null) _handledFriendSessions.add(s);
+ _pendingFriend = null;
+ notifyListeners();
+ }
+
+ Future<void> removeFriend(String id) async {
+ await _client.removeFriend(FriendRef(deviceId: id));
+ _friends = _friends.where((f) => f.id != id).toList();
+ notifyListeners();
+ }
+
+ Future<void> setFriendAutoAccept(String id, bool on) async {
+ final f = await _client.setFriendAutoAccept(SetFriendAutoAcceptRequest(deviceId: id, autoAccept: on));
+ final i = _friends.indexWhere((x) => x.id == id);
+ if (i >= 0) {
+ _friends = List<Friend>.from(_friends)..[i] = f;
+ notifyListeners();
+ }
+ }
+
+ Future<void> setDisplayName(String name) async {
+ _profile = await _client.setDisplayName(SetDisplayNameRequest(name: name));
+ notifyListeners();
+ }
+
+ /// 设置头像:[image] 是图片数据(粘贴、拖入),否则读 [path];裁剪区域按原图比例
+ Future<void> setAvatar({String path = '', List<int>? image, double x = 0, double y = 0, double size = 0}) async {
+ _profile = await _client.setAvatar(
+ SetAvatarRequest(path: path, image: image, cropX: x, cropY: y, cropSize: size),
+ options: CallOptions(timeout: const Duration(seconds: 20)),
+ );
+ _avatars.remove('');
+ notifyListeners();
+ }
+
+ Future<void> resetAvatar() async {
+ _profile = await _client.resetAvatar(Empty());
+ _avatars.remove('');
+ notifyListeners();
+ }
+
+ /// 头像图片(本机为空字符串)。还没取到时返回 null 并在后台去取,取到后刷新界面
+ Uint8List? avatarOf(String deviceId, List<int> hash) {
+ if (hash.isEmpty) return null;
+ final key = hash.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
+ final cached = _avatars[deviceId];
+ if (cached != null && cached.$1 == key) return cached.$2;
+ if (_conn == null || _avatarLoading.contains(deviceId)) return cached?.$2;
+ _avatarLoading.add(deviceId);
+ _client.getAvatar(GetAvatarRequest(deviceId: deviceId)).then((a) {
+ _avatars[deviceId] = (key, a.jpeg.isEmpty ? null : Uint8List.fromList(a.jpeg));
+ notifyListeners();
+ }).catchError((_) {}).whenComplete(() => _avatarLoading.remove(deviceId));
+ return cached?.$2;
+ }
+
+ /// 测试与截图用:直接放入一张头像
+ @visibleForTesting
+ void debugAvatar(String deviceId, List<int> hash, Uint8List? image) {
+ final key = hash.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
+ _avatars[deviceId] = (key, image);
+ }
+
+ /// 发送窗口、头像里的「粘贴」:剪贴板里的文件,或者剪贴板里的图片存成的文件
+ Future<PasteFilesResponse> pasteFiles() => _client.pasteFiles(Empty());
+
+ /// 隔空传送页打开期间订阅:附近开着「所有人」的陌生设备
+ Stream<List<Stranger>> watchStrangers() =>
+ _client.watchStrangers(Empty()).map((e) => e.strangers.toList());
+
+ /// 接收弹窗里的「接受」「拒绝」
+ Future<void> answerIncoming(String transferId, bool accept, {bool always = false}) async {
+ _handledAsks.add(transferId);
+ notifyListeners();
+ try {
+ await _client.answerIncoming(AnswerIncomingRequest(transferId: transferId, accept: accept, always: always));
+ } on GrpcError catch (e) {
+ // 已经过时了(对方取消、超时):不用再提示
+ if (e.code != StatusCode.failedPrecondition) rethrow;
+ }
+ }
+
+ /// 测试用:只在界面上记下这一批处理过了
+ @visibleForTesting
+ Future<void> answerIncomingLocally(String transferId) async {
+ _handledAsks.add(transferId);
+ notifyListeners();
+ }
+
+ /// 弹窗关掉但没回答(比如用户点了别处):这一批不再弹,留在列表里还能处理
+ void dismissAsk(String transferId) {
+ _handledAsks.add(transferId);
+ notifyListeners();
+ }
+
+ Future<void> setReceiveFrom(String v) => updateConfig(config!.deepCopy()..receiveFrom = v);
+
/// 手动告诉后台服务某台设备的地址:跨网段、或两边都换了地址时用。
Future<void> setDeviceAddress(String deviceId, String address) =>
_client.setDeviceAddress(
@@ -1061,13 +1300,17 @@ class AppState extends ChangeNotifier implements RecordDetails {
String deviceId,
List<String> paths, {
bool allowRelay = false,
+ String note = '',
}) async {
final t = await _client.sendFiles(
SendFilesRequest(
deviceId: deviceId,
paths: paths,
allowRelay: allowRelay,
+ note: note,
),
+ // 发给「所有人」模式下的陌生设备时要先连上它
+ options: CallOptions(timeout: const Duration(seconds: 30)),
);
_upsertTransfer(t);
notifyListeners();
@@ -1117,6 +1360,7 @@ class AppState extends ChangeNotifier implements RecordDetails {
'relay' => SendFailure.needRelayConsent,
'no_paths' => SendFailure.noPaths,
'unknown_device' => SendFailure.unknownDevice,
+ 'bad_note' => SendFailure.badNote,
_ => SendFailure.other,
};
}
@@ -1148,6 +1392,10 @@ class AppState extends ChangeNotifier implements RecordDetails {
'code_expired' => PairingFailure.codeExpired,
'bad_address' => PairingFailure.badAddress,
'no_channel' => PairingFailure.noChannel,
+ 'friend_code' => PairingFailure.friendCode,
+ 'device_code' => PairingFailure.deviceCode,
+ 'peer_outdated' => PairingFailure.peerOutdated,
+ 'already_paired' => PairingFailure.alreadyPaired,
_ => PairingFailure.other,
};
}
diff --git a/ui/lib/icons.dart b/ui/lib/icons.dart
index 8af2927..34fd1b9 100644
--- a/ui/lib/icons.dart
+++ b/ui/lib/icons.dart
@@ -51,6 +51,10 @@ abstract final class AppIcons {
static IconData get doc => _pick(CupertinoIcons.doc, FluentIcons.document_24_regular);
static IconData get chevronLeft => _pick(CupertinoIcons.chevron_left, FluentIcons.chevron_left_24_regular);
static IconData get chevronRight => _pick(CupertinoIcons.chevron_right, FluentIcons.chevron_right_24_regular);
+ static IconData get chevronDown => _pick(CupertinoIcons.chevron_down, FluentIcons.chevron_down_24_regular);
+ static IconData get person => _pick(CupertinoIcons.person, FluentIcons.person_24_regular);
+ static IconData get people => _pick(CupertinoIcons.person_2, FluentIcons.people_24_regular);
+ static IconData get personAdd => _pick(CupertinoIcons.person_badge_plus, FluentIcons.person_add_24_regular);
static IconData get chevronUpDown =>
_pick(CupertinoIcons.chevron_up_chevron_down, FluentIcons.chevron_up_down_24_regular);
static IconData get link => _pick(CupertinoIcons.link, FluentIcons.link_24_regular);
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
index 6943510..925ddc3 100644
--- a/ui/lib/l10n/app_en.arb
+++ b/ui/lib/l10n/app_en.arb
@@ -1316,5 +1316,245 @@
"quitAppDesc": "Stop all PasteFerry processes. Your launch-at-login preference is preserved.",
"quitTransfersWarning": "Files are still being transferred. Quit and interrupt these transfers?",
"backgroundRunningTitle": "PasteFerry will keep running",
- "backgroundRunningBody": "Closing the window keeps sync and quick paste running. To stop everything, choose Quit PasteFerry in Settings or the app menu."
+ "backgroundRunningBody": "Closing the window keeps sync and quick paste running. To stop everything, choose Quit PasteFerry in Settings or the app menu.",
+ "displayAs": "Shown as",
+ "editName": "Change Name",
+ "nameHint": "The name your contacts see",
+ "nameDefaultHint": "Leave empty to use your account name.",
+ "avatarTitle": "Profile Picture",
+ "avatarChoose": "Choose Image…",
+ "avatarPaste": "Paste Image",
+ "avatarReset": "Use Default Picture",
+ "avatarZoom": "Zoom",
+ "avatarDragHint": "Drag to move the picture.",
+ "avatarNoImage": "There's no image on the clipboard.",
+ "avatarBad": "This image can't be used. Choose a PNG, JPEG or GIF.",
+ "done": "Done",
+ "friendsTitle": "Contacts",
+ "addFriend": "Add Contact",
+ "friendsEmpty": "No contacts yet",
+ "friendsEmptyBody": "Add someone who also uses PasteFerry to send each other files without pairing. Contacts can only send files; they never see your clipboard.",
+ "friendSendAction": "Send…",
+ "friendHistory": "Transfers",
+ "friendHistoryTitle": "Transfers with {name}",
+ "@friendHistoryTitle": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "friendHistoryEmpty": "No transfers yet.",
+ "friendAutoAccept": "Accept Files Automatically",
+ "friendRemove": "Remove Contact",
+ "friendRemoveTitle": "Remove {name}?",
+ "@friendRemoveTitle": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "friendRemoveBody": "You'll be removed from each other's contacts and can no longer send each other files. Past transfers stay on this computer.",
+ "friendLastActivity": "Last transfer {time}",
+ "@friendLastActivity": {
+ "placeholders": {
+ "time": {
+ "type": "String"
+ }
+ }
+ },
+ "friendNoActivity": "No transfers yet",
+ "friendCodeShare": "Send this code to your contact. When they enter it in PasteFerry, you'll be added to each other's contacts.",
+ "friendCodeExpires": "Expires in {time}",
+ "@friendCodeExpires": {
+ "placeholders": {
+ "time": {
+ "type": "String"
+ }
+ }
+ },
+ "friendCodeOr": "or",
+ "friendCodeEnter": "Enter their contact code",
+ "friendCodeAdd": "Add",
+ "friendCodeWaiting": "Waiting for them to enter it…",
+ "friendConfirmBody": "Add {name} to your contacts?",
+ "@friendConfirmBody": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "friendSafetyCode": "Check safety code (optional)",
+ "friendSafetyHint": "When you're together, compare these two lines. If they match on both computers, no one has interfered.",
+ "friendWaitingPeer": "Waiting for them to add you…",
+ "friendAdded": "{name} was added to your contacts",
+ "@friendAdded": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "friendPeerCancelled": "{name} cancelled",
+ "@friendPeerCancelled": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "friendErrFriendCode": "This is a contact code. Enter it in Add Contact on the Send Files page.",
+ "friendErrDeviceCode": "This is a pairing code. Enter it in Devices → Add Device.",
+ "friendErrOutdated": "They need PasteFerry 2.6.0 or later.",
+ "friendErrAlreadyPaired": "That computer is already one of your devices.",
+ "friendErrNoChannel": "You're not on the same network. Turn on Service on both computers to add each other.",
+ "openService": "Turn On Service…",
+ "noteLabel": "Note (optional)",
+ "noteHintEmpty": "Choose files first",
+ "noteHint": "For example: please sign page 3",
+ "noteLine": "Note: {note}",
+ "@noteLine": {
+ "placeholders": {
+ "note": {
+ "type": "String"
+ }
+ }
+ },
+ "sendAction": "Send",
+ "sendItemsSummary": "{count} items · {size}",
+ "@sendItemsSummary": {
+ "placeholders": {
+ "count": {
+ "type": "String"
+ },
+ "size": {
+ "type": "String"
+ }
+ }
+ },
+ "sendDropOrPaste": "Drop files or images here, or paste ({key})",
+ "@sendDropOrPaste": {
+ "placeholders": {
+ "key": {
+ "type": "String"
+ }
+ }
+ },
+ "sendDropMorePaste": "Drop or paste more",
+ "sendPasteNothing": "Nothing to paste. Copy files or an image first.",
+ "sendRemoveItem": "Remove",
+ "sendFriendSaved": "{name} accepts each batch before it's sent.",
+ "@sendFriendSaved": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "transferAskingOut": "Waiting for {name} to accept…",
+ "@transferAskingOut": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "transferAskingIn": "Waiting for you to accept",
+ "reasonDeclined": "{name} declined",
+ "@reasonDeclined": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "reasonTimeout": "{name} didn't respond",
+ "@reasonTimeout": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "reasonNotAllowed": "{name} isn't accepting files",
+ "@reasonNotAllowed": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "reasonRateLimited": "{name} isn't accepting your files right now",
+ "@reasonRateLimited": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "reasonYouDeclined": "Declined",
+ "reasonYouIgnored": "Ignored",
+ "sendAgain": "Send Again",
+ "incomingTitle": "{name} wants to send you files",
+ "@incomingTitle": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "incomingAlways": "Always accept files from this contact",
+ "incomingDecline": "Decline",
+ "incomingAccept": "Accept",
+ "incomingCountdown": "Declines automatically in {seconds} s",
+ "@incomingCountdown": {
+ "placeholders": {
+ "seconds": {
+ "type": "String"
+ }
+ }
+ },
+ "incomingStranger": "Nearby",
+ "friendsStrip": "Contacts",
+ "strangersStrip": "Nearby with Everyone on",
+ "strangerNearby": "Nearby",
+ "friendNeedService": "Turn on Service",
+ "friendCantReach": "Can't connect",
+ "reachSelfNoService": "You and {name} aren't on the same network. Turn on Service to send files; if no direct connection is possible, they go through the Service relay.",
+ "@reachSelfNoService": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "reachPeerNoService": "{name} hasn't turned on Service, so you can only send files on the same network. Ask them to turn on Service in PasteFerry.",
+ "@reachPeerNoService": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "reachDifferentServer": "You aren't using the same server. Turn on Service on both computers, or use the same server, to send files.",
+ "receiveFromLabel": "Let these people send me files:",
+ "receiveFromOff": "No One",
+ "receiveFromFriends": "Contacts Only",
+ "receiveFromEveryone": "Everyone",
+ "everyoneLeft": "Everyone · {minutes} min left",
+ "@everyoneLeft": {
+ "placeholders": {
+ "minutes": {
+ "type": "String"
+ }
+ }
+ },
+ "receiveFromOffDesc": "Only your own paired computers can send you files.",
+ "receiveFromFriendsDesc": "Your contacts can send you files. You accept each batch.",
+ "receiveFromEveryoneDesc": "Anyone on the same network can send you files for 10 minutes. You accept each batch.",
+ "everyoneEnded": "Everyone is off; back to Contacts Only.",
+ "friendsCountTooltip": "Contacts",
+ "waitingAccept": "Waiting…"
}
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
index 866c5f8..a9d9a93 100644
--- a/ui/lib/l10n/app_ja.arb
+++ b/ui/lib/l10n/app_ja.arb
@@ -513,5 +513,95 @@
"quitAppDesc": "すべてのプロセスを終了します。ログイン時の起動設定は保持されます。",
"quitTransfersWarning": "ファイル転送中です。転送を中断して終了しますか?",
"backgroundRunningTitle": "PasteFerry はバックグラウンドで動作します",
- "backgroundRunningBody": "ウィンドウを閉じても同期とクイック貼り付けは続きます。完全に停止するには、設定またはアプリメニューの「PasteFerry を終了」を選んでください。"
+ "backgroundRunningBody": "ウィンドウを閉じても同期とクイック貼り付けは続きます。完全に停止するには、設定またはアプリメニューの「PasteFerry を終了」を選んでください。",
+ "displayAs": "表示名",
+ "editName": "名前を変更",
+ "nameHint": "連絡先に表示される名前",
+ "nameDefaultHint": "空欄にするとアカウント名を使います。",
+ "avatarTitle": "プロフィール画像",
+ "avatarChoose": "画像を選択…",
+ "avatarPaste": "画像をペースト",
+ "avatarReset": "デフォルトの画像に戻す",
+ "avatarZoom": "拡大",
+ "avatarDragHint": "ドラッグで位置を調整できます。",
+ "avatarNoImage": "クリップボードに画像がありません。",
+ "avatarBad": "この画像は使えません。PNG、JPEG、GIF を選んでください。",
+ "done": "完了",
+ "friendsTitle": "連絡先",
+ "addFriend": "連絡先を追加",
+ "friendsEmpty": "連絡先はまだありません",
+ "friendsEmptyBody": "連絡先に追加すると、ペアリングせずにファイルを送り合えます。連絡先はファイルを送れるだけで、クリップボードは見えません。",
+ "friendSendAction": "送信…",
+ "friendHistory": "転送履歴",
+ "friendHistoryTitle": "{name} との転送",
+ "friendHistoryEmpty": "まだ転送していません。",
+ "friendAutoAccept": "ファイルを自動で受け入れる",
+ "friendRemove": "連絡先を削除",
+ "friendRemoveTitle": "{name} を削除しますか?",
+ "friendRemoveBody": "お互いの連絡先から削除され、ファイルを送り合えなくなります。これまでの転送履歴はこのパソコンに残ります。",
+ "friendLastActivity": "最終転送 {time}",
+ "friendNoActivity": "まだ転送なし",
+ "friendCodeShare": "このコードを相手に送ってください。相手が PasteFerry に入力すると、お互いの連絡先に追加されます。",
+ "friendCodeExpires": "あと {time} で無効",
+ "friendCodeOr": "または",
+ "friendCodeEnter": "相手のコードを入力",
+ "friendCodeAdd": "追加",
+ "friendCodeWaiting": "相手の入力を待っています…",
+ "friendConfirmBody": "{name} を連絡先に追加しますか?",
+ "friendSafetyCode": "安全コードを確認(任意)",
+ "friendSafetyHint": "対面のときに確認できます。両方のパソコンでこの 2 行が同じなら、誰にも割り込まれていません。",
+ "friendWaitingPeer": "相手の追加を待っています…",
+ "friendAdded": "{name} を連絡先に追加しました",
+ "friendPeerCancelled": "{name} がキャンセルしました",
+ "friendErrFriendCode": "これは連絡先のコードです。ファイル送信ページの「連絡先を追加」で入力してください。",
+ "friendErrDeviceCode": "これはペアリングコードです。「デバイス → デバイスを追加」で入力してください。",
+ "friendErrOutdated": "相手は PasteFerry 2.6.0 以降が必要です。",
+ "friendErrAlreadyPaired": "そのパソコンはすでにあなたのデバイスです。",
+ "friendErrNoChannel": "同じネットワークにいません。両方のパソコンで「サービス」をオンにすると追加できます。",
+ "openService": "サービスをオンにする…",
+ "noteLabel": "メモ(任意)",
+ "noteHintEmpty": "先にファイルを選んでください",
+ "noteHint": "例:3 ページ目に署名してください",
+ "noteLine": "メモ:{note}",
+ "sendAction": "送信",
+ "sendItemsSummary": "{count} 項目 · {size}",
+ "sendDropOrPaste": "ファイルや画像をここにドロップ、またはペースト({key})",
+ "sendDropMorePaste": "さらにドロップまたはペースト",
+ "sendPasteNothing": "ペーストできるファイルや画像がありません。",
+ "sendRemoveItem": "削除",
+ "sendFriendSaved": "相手が受け入れると送信が始まります。",
+ "transferAskingOut": "{name} の受け入れを待っています…",
+ "transferAskingIn": "受け入れを待っています",
+ "reasonDeclined": "{name} が拒否しました",
+ "reasonTimeout": "{name} から応答がありません",
+ "reasonNotAllowed": "{name} はファイルを受け付けていません",
+ "reasonRateLimited": "{name} は現在あなたのファイルを受け付けていません",
+ "reasonYouDeclined": "拒否しました",
+ "reasonYouIgnored": "無視しました",
+ "sendAgain": "もう一度送る",
+ "incomingTitle": "{name} からファイルが届いています",
+ "incomingAlways": "今後この連絡先のファイルを自動で受け入れる",
+ "incomingDecline": "拒否",
+ "incomingAccept": "受け入れる",
+ "incomingCountdown": "{seconds} 秒後に自動で拒否",
+ "incomingStranger": "近くのデバイス",
+ "friendsStrip": "連絡先",
+ "strangersStrip": "近くで「すべての人」がオンのデバイス",
+ "strangerNearby": "近く",
+ "friendNeedService": "サービスが必要",
+ "friendCantReach": "接続できません",
+ "reachSelfNoService": "{name} と同じネットワークにいません。サービスをオンにするとファイルを送れます。直接接続できないときはサービスの中継を使います。",
+ "reachPeerNoService": "{name} はサービスをオンにしていないため、同じネットワークにいるときしか送れません。PasteFerry でサービスをオンにしてもらってください。",
+ "reachDifferentServer": "同じサーバーを使っていません。両方でサービスをオンにするか、同じサーバーを使うと送れます。",
+ "receiveFromLabel": "ファイルの送信を許可:",
+ "receiveFromOff": "許可しない",
+ "receiveFromFriends": "連絡先のみ",
+ "receiveFromEveryone": "すべての人",
+ "everyoneLeft": "すべての人 · 残り {minutes} 分",
+ "receiveFromOffDesc": "ペアリングした自分のパソコンだけが送れます。",
+ "receiveFromFriendsDesc": "連絡先が送れます。毎回あなたが受け入れます。",
+ "receiveFromEveryoneDesc": "同じネットワークの誰でも 10 分間送れます。毎回あなたが受け入れます。",
+ "everyoneEnded": "「すべての人」が終了し、「連絡先のみ」に戻りました。",
+ "friendsCountTooltip": "連絡先",
+ "waitingAccept": "承認待ち"
}
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
index c10e81a..e2dd9cf 100644
--- a/ui/lib/l10n/app_localizations.dart
+++ b/ui/lib/l10n/app_localizations.dart
@@ -3193,6 +3193,546 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Closing the window keeps sync and quick paste running. To stop everything, choose Quit PasteFerry in Settings or the app menu.'**
String get backgroundRunningBody;
+
+ /// No description provided for @displayAs.
+ ///
+ /// In en, this message translates to:
+ /// **'Shown as'**
+ String get displayAs;
+
+ /// No description provided for @editName.
+ ///
+ /// In en, this message translates to:
+ /// **'Change Name'**
+ String get editName;
+
+ /// No description provided for @nameHint.
+ ///
+ /// In en, this message translates to:
+ /// **'The name your contacts see'**
+ String get nameHint;
+
+ /// No description provided for @nameDefaultHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Leave empty to use your account name.'**
+ String get nameDefaultHint;
+
+ /// No description provided for @avatarTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Profile Picture'**
+ String get avatarTitle;
+
+ /// No description provided for @avatarChoose.
+ ///
+ /// In en, this message translates to:
+ /// **'Choose Image…'**
+ String get avatarChoose;
+
+ /// No description provided for @avatarPaste.
+ ///
+ /// In en, this message translates to:
+ /// **'Paste Image'**
+ String get avatarPaste;
+
+ /// No description provided for @avatarReset.
+ ///
+ /// In en, this message translates to:
+ /// **'Use Default Picture'**
+ String get avatarReset;
+
+ /// No description provided for @avatarZoom.
+ ///
+ /// In en, this message translates to:
+ /// **'Zoom'**
+ String get avatarZoom;
+
+ /// No description provided for @avatarDragHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Drag to move the picture.'**
+ String get avatarDragHint;
+
+ /// No description provided for @avatarNoImage.
+ ///
+ /// In en, this message translates to:
+ /// **'There\'s no image on the clipboard.'**
+ String get avatarNoImage;
+
+ /// No description provided for @avatarBad.
+ ///
+ /// In en, this message translates to:
+ /// **'This image can\'t be used. Choose a PNG, JPEG or GIF.'**
+ String get avatarBad;
+
+ /// No description provided for @done.
+ ///
+ /// In en, this message translates to:
+ /// **'Done'**
+ String get done;
+
+ /// No description provided for @friendsTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Contacts'**
+ String get friendsTitle;
+
+ /// No description provided for @addFriend.
+ ///
+ /// In en, this message translates to:
+ /// **'Add Contact'**
+ String get addFriend;
+
+ /// No description provided for @friendsEmpty.
+ ///
+ /// In en, this message translates to:
+ /// **'No contacts yet'**
+ String get friendsEmpty;
+
+ /// No description provided for @friendsEmptyBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Add someone who also uses PasteFerry to send each other files without pairing. Contacts can only send files; they never see your clipboard.'**
+ String get friendsEmptyBody;
+
+ /// No description provided for @friendSendAction.
+ ///
+ /// In en, this message translates to:
+ /// **'Send…'**
+ String get friendSendAction;
+
+ /// No description provided for @friendHistory.
+ ///
+ /// In en, this message translates to:
+ /// **'Transfers'**
+ String get friendHistory;
+
+ /// No description provided for @friendHistoryTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Transfers with {name}'**
+ String friendHistoryTitle(String name);
+
+ /// No description provided for @friendHistoryEmpty.
+ ///
+ /// In en, this message translates to:
+ /// **'No transfers yet.'**
+ String get friendHistoryEmpty;
+
+ /// No description provided for @friendAutoAccept.
+ ///
+ /// In en, this message translates to:
+ /// **'Accept Files Automatically'**
+ String get friendAutoAccept;
+
+ /// No description provided for @friendRemove.
+ ///
+ /// In en, this message translates to:
+ /// **'Remove Contact'**
+ String get friendRemove;
+
+ /// No description provided for @friendRemoveTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Remove {name}?'**
+ String friendRemoveTitle(String name);
+
+ /// No description provided for @friendRemoveBody.
+ ///
+ /// In en, this message translates to:
+ /// **'You\'ll be removed from each other\'s contacts and can no longer send each other files. Past transfers stay on this computer.'**
+ String get friendRemoveBody;
+
+ /// No description provided for @friendLastActivity.
+ ///
+ /// In en, this message translates to:
+ /// **'Last transfer {time}'**
+ String friendLastActivity(String time);
+
+ /// No description provided for @friendNoActivity.
+ ///
+ /// In en, this message translates to:
+ /// **'No transfers yet'**
+ String get friendNoActivity;
+
+ /// No description provided for @friendCodeShare.
+ ///
+ /// In en, this message translates to:
+ /// **'Send this code to your contact. When they enter it in PasteFerry, you\'ll be added to each other\'s contacts.'**
+ String get friendCodeShare;
+
+ /// No description provided for @friendCodeExpires.
+ ///
+ /// In en, this message translates to:
+ /// **'Expires in {time}'**
+ String friendCodeExpires(String time);
+
+ /// No description provided for @friendCodeOr.
+ ///
+ /// In en, this message translates to:
+ /// **'or'**
+ String get friendCodeOr;
+
+ /// No description provided for @friendCodeEnter.
+ ///
+ /// In en, this message translates to:
+ /// **'Enter their contact code'**
+ String get friendCodeEnter;
+
+ /// No description provided for @friendCodeAdd.
+ ///
+ /// In en, this message translates to:
+ /// **'Add'**
+ String get friendCodeAdd;
+
+ /// No description provided for @friendCodeWaiting.
+ ///
+ /// In en, this message translates to:
+ /// **'Waiting for them to enter it…'**
+ String get friendCodeWaiting;
+
+ /// No description provided for @friendConfirmBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Add {name} to your contacts?'**
+ String friendConfirmBody(String name);
+
+ /// No description provided for @friendSafetyCode.
+ ///
+ /// In en, this message translates to:
+ /// **'Check safety code (optional)'**
+ String get friendSafetyCode;
+
+ /// No description provided for @friendSafetyHint.
+ ///
+ /// In en, this message translates to:
+ /// **'When you\'re together, compare these two lines. If they match on both computers, no one has interfered.'**
+ String get friendSafetyHint;
+
+ /// No description provided for @friendWaitingPeer.
+ ///
+ /// In en, this message translates to:
+ /// **'Waiting for them to add you…'**
+ String get friendWaitingPeer;
+
+ /// No description provided for @friendAdded.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} was added to your contacts'**
+ String friendAdded(String name);
+
+ /// No description provided for @friendPeerCancelled.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} cancelled'**
+ String friendPeerCancelled(String name);
+
+ /// No description provided for @friendErrFriendCode.
+ ///
+ /// In en, this message translates to:
+ /// **'This is a contact code. Enter it in Add Contact on the Send Files page.'**
+ String get friendErrFriendCode;
+
+ /// No description provided for @friendErrDeviceCode.
+ ///
+ /// In en, this message translates to:
+ /// **'This is a pairing code. Enter it in Devices → Add Device.'**
+ String get friendErrDeviceCode;
+
+ /// No description provided for @friendErrOutdated.
+ ///
+ /// In en, this message translates to:
+ /// **'They need PasteFerry 2.6.0 or later.'**
+ String get friendErrOutdated;
+
+ /// No description provided for @friendErrAlreadyPaired.
+ ///
+ /// In en, this message translates to:
+ /// **'That computer is already one of your devices.'**
+ String get friendErrAlreadyPaired;
+
+ /// No description provided for @friendErrNoChannel.
+ ///
+ /// In en, this message translates to:
+ /// **'You\'re not on the same network. Turn on Service on both computers to add each other.'**
+ String get friendErrNoChannel;
+
+ /// No description provided for @openService.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn On Service…'**
+ String get openService;
+
+ /// No description provided for @noteLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Note (optional)'**
+ String get noteLabel;
+
+ /// No description provided for @noteHintEmpty.
+ ///
+ /// In en, this message translates to:
+ /// **'Choose files first'**
+ String get noteHintEmpty;
+
+ /// No description provided for @noteHint.
+ ///
+ /// In en, this message translates to:
+ /// **'For example: please sign page 3'**
+ String get noteHint;
+
+ /// No description provided for @noteLine.
+ ///
+ /// In en, this message translates to:
+ /// **'Note: {note}'**
+ String noteLine(String note);
+
+ /// No description provided for @sendAction.
+ ///
+ /// In en, this message translates to:
+ /// **'Send'**
+ String get sendAction;
+
+ /// No description provided for @sendItemsSummary.
+ ///
+ /// In en, this message translates to:
+ /// **'{count} items · {size}'**
+ String sendItemsSummary(String count, String size);
+
+ /// No description provided for @sendDropOrPaste.
+ ///
+ /// In en, this message translates to:
+ /// **'Drop files or images here, or paste ({key})'**
+ String sendDropOrPaste(String key);
+
+ /// No description provided for @sendDropMorePaste.
+ ///
+ /// In en, this message translates to:
+ /// **'Drop or paste more'**
+ String get sendDropMorePaste;
+
+ /// No description provided for @sendPasteNothing.
+ ///
+ /// In en, this message translates to:
+ /// **'Nothing to paste. Copy files or an image first.'**
+ String get sendPasteNothing;
+
+ /// No description provided for @sendRemoveItem.
+ ///
+ /// In en, this message translates to:
+ /// **'Remove'**
+ String get sendRemoveItem;
+
+ /// No description provided for @sendFriendSaved.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} accepts each batch before it\'s sent.'**
+ String sendFriendSaved(String name);
+
+ /// No description provided for @transferAskingOut.
+ ///
+ /// In en, this message translates to:
+ /// **'Waiting for {name} to accept…'**
+ String transferAskingOut(String name);
+
+ /// No description provided for @transferAskingIn.
+ ///
+ /// In en, this message translates to:
+ /// **'Waiting for you to accept'**
+ String get transferAskingIn;
+
+ /// No description provided for @reasonDeclined.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} declined'**
+ String reasonDeclined(String name);
+
+ /// No description provided for @reasonTimeout.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} didn\'t respond'**
+ String reasonTimeout(String name);
+
+ /// No description provided for @reasonNotAllowed.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} isn\'t accepting files'**
+ String reasonNotAllowed(String name);
+
+ /// No description provided for @reasonRateLimited.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} isn\'t accepting your files right now'**
+ String reasonRateLimited(String name);
+
+ /// No description provided for @reasonYouDeclined.
+ ///
+ /// In en, this message translates to:
+ /// **'Declined'**
+ String get reasonYouDeclined;
+
+ /// No description provided for @reasonYouIgnored.
+ ///
+ /// In en, this message translates to:
+ /// **'Ignored'**
+ String get reasonYouIgnored;
+
+ /// No description provided for @sendAgain.
+ ///
+ /// In en, this message translates to:
+ /// **'Send Again'**
+ String get sendAgain;
+
+ /// No description provided for @incomingTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} wants to send you files'**
+ String incomingTitle(String name);
+
+ /// No description provided for @incomingAlways.
+ ///
+ /// In en, this message translates to:
+ /// **'Always accept files from this contact'**
+ String get incomingAlways;
+
+ /// No description provided for @incomingDecline.
+ ///
+ /// In en, this message translates to:
+ /// **'Decline'**
+ String get incomingDecline;
+
+ /// No description provided for @incomingAccept.
+ ///
+ /// In en, this message translates to:
+ /// **'Accept'**
+ String get incomingAccept;
+
+ /// No description provided for @incomingCountdown.
+ ///
+ /// In en, this message translates to:
+ /// **'Declines automatically in {seconds} s'**
+ String incomingCountdown(String seconds);
+
+ /// No description provided for @incomingStranger.
+ ///
+ /// In en, this message translates to:
+ /// **'Nearby'**
+ String get incomingStranger;
+
+ /// No description provided for @friendsStrip.
+ ///
+ /// In en, this message translates to:
+ /// **'Contacts'**
+ String get friendsStrip;
+
+ /// No description provided for @strangersStrip.
+ ///
+ /// In en, this message translates to:
+ /// **'Nearby with Everyone on'**
+ String get strangersStrip;
+
+ /// No description provided for @strangerNearby.
+ ///
+ /// In en, this message translates to:
+ /// **'Nearby'**
+ String get strangerNearby;
+
+ /// No description provided for @friendNeedService.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on Service'**
+ String get friendNeedService;
+
+ /// No description provided for @friendCantReach.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t connect'**
+ String get friendCantReach;
+
+ /// No description provided for @reachSelfNoService.
+ ///
+ /// In en, this message translates to:
+ /// **'You and {name} aren\'t on the same network. Turn on Service to send files; if no direct connection is possible, they go through the Service relay.'**
+ String reachSelfNoService(String name);
+
+ /// No description provided for @reachPeerNoService.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} hasn\'t turned on Service, so you can only send files on the same network. Ask them to turn on Service in PasteFerry.'**
+ String reachPeerNoService(String name);
+
+ /// No description provided for @reachDifferentServer.
+ ///
+ /// In en, this message translates to:
+ /// **'You aren\'t using the same server. Turn on Service on both computers, or use the same server, to send files.'**
+ String get reachDifferentServer;
+
+ /// No description provided for @receiveFromLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Let these people send me files:'**
+ String get receiveFromLabel;
+
+ /// No description provided for @receiveFromOff.
+ ///
+ /// In en, this message translates to:
+ /// **'No One'**
+ String get receiveFromOff;
+
+ /// No description provided for @receiveFromFriends.
+ ///
+ /// In en, this message translates to:
+ /// **'Contacts Only'**
+ String get receiveFromFriends;
+
+ /// No description provided for @receiveFromEveryone.
+ ///
+ /// In en, this message translates to:
+ /// **'Everyone'**
+ String get receiveFromEveryone;
+
+ /// No description provided for @everyoneLeft.
+ ///
+ /// In en, this message translates to:
+ /// **'Everyone · {minutes} min left'**
+ String everyoneLeft(String minutes);
+
+ /// No description provided for @receiveFromOffDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Only your own paired computers can send you files.'**
+ String get receiveFromOffDesc;
+
+ /// No description provided for @receiveFromFriendsDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Your contacts can send you files. You accept each batch.'**
+ String get receiveFromFriendsDesc;
+
+ /// No description provided for @receiveFromEveryoneDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Anyone on the same network can send you files for 10 minutes. You accept each batch.'**
+ String get receiveFromEveryoneDesc;
+
+ /// No description provided for @everyoneEnded.
+ ///
+ /// In en, this message translates to:
+ /// **'Everyone is off; back to Contacts Only.'**
+ String get everyoneEnded;
+
+ /// No description provided for @friendsCountTooltip.
+ ///
+ /// In en, this message translates to:
+ /// **'Contacts'**
+ String get friendsCountTooltip;
+
+ /// No description provided for @waitingAccept.
+ ///
+ /// In en, this message translates to:
+ /// **'Waiting…'**
+ String get waitingAccept;
}
class _AppLocalizationsDelegate
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
index 6f0597c..289c712 100644
--- a/ui/lib/l10n/app_localizations_en.dart
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -1956,4 +1956,330 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get backgroundRunningBody =>
'Closing the window keeps sync and quick paste running. To stop everything, choose Quit PasteFerry in Settings or the app menu.';
+
+ @override
+ String get displayAs => 'Shown as';
+
+ @override
+ String get editName => 'Change Name';
+
+ @override
+ String get nameHint => 'The name your contacts see';
+
+ @override
+ String get nameDefaultHint => 'Leave empty to use your account name.';
+
+ @override
+ String get avatarTitle => 'Profile Picture';
+
+ @override
+ String get avatarChoose => 'Choose Image…';
+
+ @override
+ String get avatarPaste => 'Paste Image';
+
+ @override
+ String get avatarReset => 'Use Default Picture';
+
+ @override
+ String get avatarZoom => 'Zoom';
+
+ @override
+ String get avatarDragHint => 'Drag to move the picture.';
+
+ @override
+ String get avatarNoImage => 'There\'s no image on the clipboard.';
+
+ @override
+ String get avatarBad =>
+ 'This image can\'t be used. Choose a PNG, JPEG or GIF.';
+
+ @override
+ String get done => 'Done';
+
+ @override
+ String get friendsTitle => 'Contacts';
+
+ @override
+ String get addFriend => 'Add Contact';
+
+ @override
+ String get friendsEmpty => 'No contacts yet';
+
+ @override
+ String get friendsEmptyBody =>
+ 'Add someone who also uses PasteFerry to send each other files without pairing. Contacts can only send files; they never see your clipboard.';
+
+ @override
+ String get friendSendAction => 'Send…';
+
+ @override
+ String get friendHistory => 'Transfers';
+
+ @override
+ String friendHistoryTitle(String name) {
+ return 'Transfers with $name';
+ }
+
+ @override
+ String get friendHistoryEmpty => 'No transfers yet.';
+
+ @override
+ String get friendAutoAccept => 'Accept Files Automatically';
+
+ @override
+ String get friendRemove => 'Remove Contact';
+
+ @override
+ String friendRemoveTitle(String name) {
+ return 'Remove $name?';
+ }
+
+ @override
+ String get friendRemoveBody =>
+ 'You\'ll be removed from each other\'s contacts and can no longer send each other files. Past transfers stay on this computer.';
+
+ @override
+ String friendLastActivity(String time) {
+ return 'Last transfer $time';
+ }
+
+ @override
+ String get friendNoActivity => 'No transfers yet';
+
+ @override
+ String get friendCodeShare =>
+ 'Send this code to your contact. When they enter it in PasteFerry, you\'ll be added to each other\'s contacts.';
+
+ @override
+ String friendCodeExpires(String time) {
+ return 'Expires in $time';
+ }
+
+ @override
+ String get friendCodeOr => 'or';
+
+ @override
+ String get friendCodeEnter => 'Enter their contact code';
+
+ @override
+ String get friendCodeAdd => 'Add';
+
+ @override
+ String get friendCodeWaiting => 'Waiting for them to enter it…';
+
+ @override
+ String friendConfirmBody(String name) {
+ return 'Add $name to your contacts?';
+ }
+
+ @override
+ String get friendSafetyCode => 'Check safety code (optional)';
+
+ @override
+ String get friendSafetyHint =>
+ 'When you\'re together, compare these two lines. If they match on both computers, no one has interfered.';
+
+ @override
+ String get friendWaitingPeer => 'Waiting for them to add you…';
+
+ @override
+ String friendAdded(String name) {
+ return '$name was added to your contacts';
+ }
+
+ @override
+ String friendPeerCancelled(String name) {
+ return '$name cancelled';
+ }
+
+ @override
+ String get friendErrFriendCode =>
+ 'This is a contact code. Enter it in Add Contact on the Send Files page.';
+
+ @override
+ String get friendErrDeviceCode =>
+ 'This is a pairing code. Enter it in Devices → Add Device.';
+
+ @override
+ String get friendErrOutdated => 'They need PasteFerry 2.6.0 or later.';
+
+ @override
+ String get friendErrAlreadyPaired =>
+ 'That computer is already one of your devices.';
+
+ @override
+ String get friendErrNoChannel =>
+ 'You\'re not on the same network. Turn on Service on both computers to add each other.';
+
+ @override
+ String get openService => 'Turn On Service…';
+
+ @override
+ String get noteLabel => 'Note (optional)';
+
+ @override
+ String get noteHintEmpty => 'Choose files first';
+
+ @override
+ String get noteHint => 'For example: please sign page 3';
+
+ @override
+ String noteLine(String note) {
+ return 'Note: $note';
+ }
+
+ @override
+ String get sendAction => 'Send';
+
+ @override
+ String sendItemsSummary(String count, String size) {
+ return '$count items · $size';
+ }
+
+ @override
+ String sendDropOrPaste(String key) {
+ return 'Drop files or images here, or paste ($key)';
+ }
+
+ @override
+ String get sendDropMorePaste => 'Drop or paste more';
+
+ @override
+ String get sendPasteNothing =>
+ 'Nothing to paste. Copy files or an image first.';
+
+ @override
+ String get sendRemoveItem => 'Remove';
+
+ @override
+ String sendFriendSaved(String name) {
+ return '$name accepts each batch before it\'s sent.';
+ }
+
+ @override
+ String transferAskingOut(String name) {
+ return 'Waiting for $name to accept…';
+ }
+
+ @override
+ String get transferAskingIn => 'Waiting for you to accept';
+
+ @override
+ String reasonDeclined(String name) {
+ return '$name declined';
+ }
+
+ @override
+ String reasonTimeout(String name) {
+ return '$name didn\'t respond';
+ }
+
+ @override
+ String reasonNotAllowed(String name) {
+ return '$name isn\'t accepting files';
+ }
+
+ @override
+ String reasonRateLimited(String name) {
+ return '$name isn\'t accepting your files right now';
+ }
+
+ @override
+ String get reasonYouDeclined => 'Declined';
+
+ @override
+ String get reasonYouIgnored => 'Ignored';
+
+ @override
+ String get sendAgain => 'Send Again';
+
+ @override
+ String incomingTitle(String name) {
+ return '$name wants to send you files';
+ }
+
+ @override
+ String get incomingAlways => 'Always accept files from this contact';
+
+ @override
+ String get incomingDecline => 'Decline';
+
+ @override
+ String get incomingAccept => 'Accept';
+
+ @override
+ String incomingCountdown(String seconds) {
+ return 'Declines automatically in $seconds s';
+ }
+
+ @override
+ String get incomingStranger => 'Nearby';
+
+ @override
+ String get friendsStrip => 'Contacts';
+
+ @override
+ String get strangersStrip => 'Nearby with Everyone on';
+
+ @override
+ String get strangerNearby => 'Nearby';
+
+ @override
+ String get friendNeedService => 'Turn on Service';
+
+ @override
+ String get friendCantReach => 'Can\'t connect';
+
+ @override
+ String reachSelfNoService(String name) {
+ return 'You and $name aren\'t on the same network. Turn on Service to send files; if no direct connection is possible, they go through the Service relay.';
+ }
+
+ @override
+ String reachPeerNoService(String name) {
+ return '$name hasn\'t turned on Service, so you can only send files on the same network. Ask them to turn on Service in PasteFerry.';
+ }
+
+ @override
+ String get reachDifferentServer =>
+ 'You aren\'t using the same server. Turn on Service on both computers, or use the same server, to send files.';
+
+ @override
+ String get receiveFromLabel => 'Let these people send me files:';
+
+ @override
+ String get receiveFromOff => 'No One';
+
+ @override
+ String get receiveFromFriends => 'Contacts Only';
+
+ @override
+ String get receiveFromEveryone => 'Everyone';
+
+ @override
+ String everyoneLeft(String minutes) {
+ return 'Everyone · $minutes min left';
+ }
+
+ @override
+ String get receiveFromOffDesc =>
+ 'Only your own paired computers can send you files.';
+
+ @override
+ String get receiveFromFriendsDesc =>
+ 'Your contacts can send you files. You accept each batch.';
+
+ @override
+ String get receiveFromEveryoneDesc =>
+ 'Anyone on the same network can send you files for 10 minutes. You accept each batch.';
+
+ @override
+ String get everyoneEnded => 'Everyone is off; back to Contacts Only.';
+
+ @override
+ String get friendsCountTooltip => 'Contacts';
+
+ @override
+ String get waitingAccept => 'Waiting…';
}
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
index 030d1da..e6d73ea 100644
--- a/ui/lib/l10n/app_localizations_ja.dart
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -1797,4 +1797,321 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get backgroundRunningBody =>
'ウィンドウを閉じても同期とクイック貼り付けは続きます。完全に停止するには、設定またはアプリメニューの「PasteFerry を終了」を選んでください。';
+
+ @override
+ String get displayAs => '表示名';
+
+ @override
+ String get editName => '名前を変更';
+
+ @override
+ String get nameHint => '連絡先に表示される名前';
+
+ @override
+ String get nameDefaultHint => '空欄にするとアカウント名を使います。';
+
+ @override
+ String get avatarTitle => 'プロフィール画像';
+
+ @override
+ String get avatarChoose => '画像を選択…';
+
+ @override
+ String get avatarPaste => '画像をペースト';
+
+ @override
+ String get avatarReset => 'デフォルトの画像に戻す';
+
+ @override
+ String get avatarZoom => '拡大';
+
+ @override
+ String get avatarDragHint => 'ドラッグで位置を調整できます。';
+
+ @override
+ String get avatarNoImage => 'クリップボードに画像がありません。';
+
+ @override
+ String get avatarBad => 'この画像は使えません。PNG、JPEG、GIF を選んでください。';
+
+ @override
+ String get done => '完了';
+
+ @override
+ String get friendsTitle => '連絡先';
+
+ @override
+ String get addFriend => '連絡先を追加';
+
+ @override
+ String get friendsEmpty => '連絡先はまだありません';
+
+ @override
+ String get friendsEmptyBody =>
+ '連絡先に追加すると、ペアリングせずにファイルを送り合えます。連絡先はファイルを送れるだけで、クリップボードは見えません。';
+
+ @override
+ String get friendSendAction => '送信…';
+
+ @override
+ String get friendHistory => '転送履歴';
+
+ @override
+ String friendHistoryTitle(String name) {
+ return '$name との転送';
+ }
+
+ @override
+ String get friendHistoryEmpty => 'まだ転送していません。';
+
+ @override
+ String get friendAutoAccept => 'ファイルを自動で受け入れる';
+
+ @override
+ String get friendRemove => '連絡先を削除';
+
+ @override
+ String friendRemoveTitle(String name) {
+ return '$name を削除しますか?';
+ }
+
+ @override
+ String get friendRemoveBody =>
+ 'お互いの連絡先から削除され、ファイルを送り合えなくなります。これまでの転送履歴はこのパソコンに残ります。';
+
+ @override
+ String friendLastActivity(String time) {
+ return '最終転送 $time';
+ }
+
+ @override
+ String get friendNoActivity => 'まだ転送なし';
+
+ @override
+ String get friendCodeShare =>
+ 'このコードを相手に送ってください。相手が PasteFerry に入力すると、お互いの連絡先に追加されます。';
+
+ @override
+ String friendCodeExpires(String time) {
+ return 'あと $time で無効';
+ }
+
+ @override
+ String get friendCodeOr => 'または';
+
+ @override
+ String get friendCodeEnter => '相手のコードを入力';
+
+ @override
+ String get friendCodeAdd => '追加';
+
+ @override
+ String get friendCodeWaiting => '相手の入力を待っています…';
+
+ @override
+ String friendConfirmBody(String name) {
+ return '$name を連絡先に追加しますか?';
+ }
+
+ @override
+ String get friendSafetyCode => '安全コードを確認(任意)';
+
+ @override
+ String get friendSafetyHint =>
+ '対面のときに確認できます。両方のパソコンでこの 2 行が同じなら、誰にも割り込まれていません。';
+
+ @override
+ String get friendWaitingPeer => '相手の追加を待っています…';
+
+ @override
+ String friendAdded(String name) {
+ return '$name を連絡先に追加しました';
+ }
+
+ @override
+ String friendPeerCancelled(String name) {
+ return '$name がキャンセルしました';
+ }
+
+ @override
+ String get friendErrFriendCode => 'これは連絡先のコードです。ファイル送信ページの「連絡先を追加」で入力してください。';
+
+ @override
+ String get friendErrDeviceCode => 'これはペアリングコードです。「デバイス → デバイスを追加」で入力してください。';
+
+ @override
+ String get friendErrOutdated => '相手は PasteFerry 2.6.0 以降が必要です。';
+
+ @override
+ String get friendErrAlreadyPaired => 'そのパソコンはすでにあなたのデバイスです。';
+
+ @override
+ String get friendErrNoChannel => '同じネットワークにいません。両方のパソコンで「サービス」をオンにすると追加できます。';
+
+ @override
+ String get openService => 'サービスをオンにする…';
+
+ @override
+ String get noteLabel => 'メモ(任意)';
+
+ @override
+ String get noteHintEmpty => '先にファイルを選んでください';
+
+ @override
+ String get noteHint => '例:3 ページ目に署名してください';
+
+ @override
+ String noteLine(String note) {
+ return 'メモ:$note';
+ }
+
+ @override
+ String get sendAction => '送信';
+
+ @override
+ String sendItemsSummary(String count, String size) {
+ return '$count 項目 · $size';
+ }
+
+ @override
+ String sendDropOrPaste(String key) {
+ return 'ファイルや画像をここにドロップ、またはペースト($key)';
+ }
+
+ @override
+ String get sendDropMorePaste => 'さらにドロップまたはペースト';
+
+ @override
+ String get sendPasteNothing => 'ペーストできるファイルや画像がありません。';
+
+ @override
+ String get sendRemoveItem => '削除';
+
+ @override
+ String sendFriendSaved(String name) {
+ return '相手が受け入れると送信が始まります。';
+ }
+
+ @override
+ String transferAskingOut(String name) {
+ return '$name の受け入れを待っています…';
+ }
+
+ @override
+ String get transferAskingIn => '受け入れを待っています';
+
+ @override
+ String reasonDeclined(String name) {
+ return '$name が拒否しました';
+ }
+
+ @override
+ String reasonTimeout(String name) {
+ return '$name から応答がありません';
+ }
+
+ @override
+ String reasonNotAllowed(String name) {
+ return '$name はファイルを受け付けていません';
+ }
+
+ @override
+ String reasonRateLimited(String name) {
+ return '$name は現在あなたのファイルを受け付けていません';
+ }
+
+ @override
+ String get reasonYouDeclined => '拒否しました';
+
+ @override
+ String get reasonYouIgnored => '無視しました';
+
+ @override
+ String get sendAgain => 'もう一度送る';
+
+ @override
+ String incomingTitle(String name) {
+ return '$name からファイルが届いています';
+ }
+
+ @override
+ String get incomingAlways => '今後この連絡先のファイルを自動で受け入れる';
+
+ @override
+ String get incomingDecline => '拒否';
+
+ @override
+ String get incomingAccept => '受け入れる';
+
+ @override
+ String incomingCountdown(String seconds) {
+ return '$seconds 秒後に自動で拒否';
+ }
+
+ @override
+ String get incomingStranger => '近くのデバイス';
+
+ @override
+ String get friendsStrip => '連絡先';
+
+ @override
+ String get strangersStrip => '近くで「すべての人」がオンのデバイス';
+
+ @override
+ String get strangerNearby => '近く';
+
+ @override
+ String get friendNeedService => 'サービスが必要';
+
+ @override
+ String get friendCantReach => '接続できません';
+
+ @override
+ String reachSelfNoService(String name) {
+ return '$name と同じネットワークにいません。サービスをオンにするとファイルを送れます。直接接続できないときはサービスの中継を使います。';
+ }
+
+ @override
+ String reachPeerNoService(String name) {
+ return '$name はサービスをオンにしていないため、同じネットワークにいるときしか送れません。PasteFerry でサービスをオンにしてもらってください。';
+ }
+
+ @override
+ String get reachDifferentServer =>
+ '同じサーバーを使っていません。両方でサービスをオンにするか、同じサーバーを使うと送れます。';
+
+ @override
+ String get receiveFromLabel => 'ファイルの送信を許可:';
+
+ @override
+ String get receiveFromOff => '許可しない';
+
+ @override
+ String get receiveFromFriends => '連絡先のみ';
+
+ @override
+ String get receiveFromEveryone => 'すべての人';
+
+ @override
+ String everyoneLeft(String minutes) {
+ return 'すべての人 · 残り $minutes 分';
+ }
+
+ @override
+ String get receiveFromOffDesc => 'ペアリングした自分のパソコンだけが送れます。';
+
+ @override
+ String get receiveFromFriendsDesc => '連絡先が送れます。毎回あなたが受け入れます。';
+
+ @override
+ String get receiveFromEveryoneDesc => '同じネットワークの誰でも 10 分間送れます。毎回あなたが受け入れます。';
+
+ @override
+ String get everyoneEnded => '「すべての人」が終了し、「連絡先のみ」に戻りました。';
+
+ @override
+ String get friendsCountTooltip => '連絡先';
+
+ @override
+ String get waitingAccept => '承認待ち';
}
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
index 88ee9cc..ce4c0d0 100644
--- a/ui/lib/l10n/app_localizations_zh.dart
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -1777,6 +1777,318 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get backgroundRunningBody =>
'关闭窗口后,同步和快捷粘贴仍会运行。如需完全停止,请在设置或应用菜单选择「退出隔空贴」。';
+
+ @override
+ String get displayAs => '显示为';
+
+ @override
+ String get editName => '修改名字';
+
+ @override
+ String get nameHint => '好友看到的名字';
+
+ @override
+ String get nameDefaultHint => '留空则用系统的用户名。';
+
+ @override
+ String get avatarTitle => '设置头像';
+
+ @override
+ String get avatarChoose => '选择图片…';
+
+ @override
+ String get avatarPaste => '粘贴图片';
+
+ @override
+ String get avatarReset => '恢复默认头像';
+
+ @override
+ String get avatarZoom => '缩放';
+
+ @override
+ String get avatarDragHint => '拖动可以移动图片。';
+
+ @override
+ String get avatarNoImage => '剪贴板里没有图片。';
+
+ @override
+ String get avatarBad => '这张图片用不了,请换一张 PNG、JPEG 或 GIF。';
+
+ @override
+ String get done => '完成';
+
+ @override
+ String get friendsTitle => '好友';
+
+ @override
+ String get addFriend => '添加好友';
+
+ @override
+ String get friendsEmpty => '还没有好友';
+
+ @override
+ String get friendsEmptyBody => '加了好友,就能互相发文件,不用配对。好友只能发文件,看不到你的剪贴板。';
+
+ @override
+ String get friendSendAction => '发送…';
+
+ @override
+ String get friendHistory => '传输记录';
+
+ @override
+ String friendHistoryTitle(String name) {
+ return '和 $name 的传输';
+ }
+
+ @override
+ String get friendHistoryEmpty => '还没有传过文件。';
+
+ @override
+ String get friendAutoAccept => '自动接收此好友的文件';
+
+ @override
+ String get friendRemove => '删除好友';
+
+ @override
+ String friendRemoveTitle(String name) {
+ return '删除好友「$name」?';
+ }
+
+ @override
+ String get friendRemoveBody => '双方都会删除对方,之后互相发不了文件。以前的传输记录仍留在这台电脑上。';
+
+ @override
+ String friendLastActivity(String time) {
+ return '$time传过';
+ }
+
+ @override
+ String get friendNoActivity => '还没传过文件';
+
+ @override
+ String get friendCodeShare => '把这个码发给好友,对方在隔空贴里输入后,你们就成为好友。';
+
+ @override
+ String friendCodeExpires(String time) {
+ return '$time 后失效';
+ }
+
+ @override
+ String get friendCodeOr => '或者';
+
+ @override
+ String get friendCodeEnter => '输入对方的好友码';
+
+ @override
+ String get friendCodeAdd => '添加';
+
+ @override
+ String get friendCodeWaiting => '等待对方输入…';
+
+ @override
+ String friendConfirmBody(String name) {
+ return '添加 $name 为好友?';
+ }
+
+ @override
+ String get friendSafetyCode => '核对安全码(可选)';
+
+ @override
+ String get friendSafetyHint => '面对面时可以核对:两边显示的这两行一样,就没有被人调包。';
+
+ @override
+ String get friendWaitingPeer => '等待对方添加…';
+
+ @override
+ String friendAdded(String name) {
+ return '已添加 $name 为好友';
+ }
+
+ @override
+ String friendPeerCancelled(String name) {
+ return '$name 取消了';
+ }
+
+ @override
+ String get friendErrFriendCode => '这是好友码,请在隔空传送页的「添加好友」里输入。';
+
+ @override
+ String get friendErrDeviceCode => '这是配对码,请在「设备 → 添加设备」里输入。';
+
+ @override
+ String get friendErrOutdated => '对方需要更新到隔空贴 2.6.0 或更高版本。';
+
+ @override
+ String get friendErrAlreadyPaired => '这台电脑已经是你的设备。';
+
+ @override
+ String get friendErrNoChannel => '你们不在同一个局域网,双方都打开「服务」后才能添加。';
+
+ @override
+ String get openService => '打开服务…';
+
+ @override
+ String get noteLabel => '备注(可选)';
+
+ @override
+ String get noteHintEmpty => '先选择要发送的文件';
+
+ @override
+ String get noteHint => '比如:合同第 3 页要签字';
+
+ @override
+ String noteLine(String note) {
+ return '备注:$note';
+ }
+
+ @override
+ String get sendAction => '发送';
+
+ @override
+ String sendItemsSummary(String count, String size) {
+ return '共 $count 项 · $size';
+ }
+
+ @override
+ String sendDropOrPaste(String key) {
+ return '把文件或图片拖到这里,或粘贴($key)';
+ }
+
+ @override
+ String get sendDropMorePaste => '继续拖入或粘贴';
+
+ @override
+ String get sendPasteNothing => '剪贴板里没有文件或图片。';
+
+ @override
+ String get sendRemoveItem => '移除';
+
+ @override
+ String sendFriendSaved(String name) {
+ return '对方点「接受」后才开始发送。';
+ }
+
+ @override
+ String transferAskingOut(String name) {
+ return '等待 $name 接受…';
+ }
+
+ @override
+ String get transferAskingIn => '等你接受';
+
+ @override
+ String reasonDeclined(String name) {
+ return '$name 拒绝了';
+ }
+
+ @override
+ String reasonTimeout(String name) {
+ return '$name 没有回应';
+ }
+
+ @override
+ String reasonNotAllowed(String name) {
+ return '$name 不接收文件';
+ }
+
+ @override
+ String reasonRateLimited(String name) {
+ return '$name 暂时不接收你的文件';
+ }
+
+ @override
+ String get reasonYouDeclined => '已拒绝';
+
+ @override
+ String get reasonYouIgnored => '已忽略';
+
+ @override
+ String get sendAgain => '再发一次';
+
+ @override
+ String incomingTitle(String name) {
+ return '$name 想发给你文件';
+ }
+
+ @override
+ String get incomingAlways => '以后自动接收此好友的文件';
+
+ @override
+ String get incomingDecline => '拒绝';
+
+ @override
+ String get incomingAccept => '接受';
+
+ @override
+ String incomingCountdown(String seconds) {
+ return '$seconds 秒后自动拒绝';
+ }
+
+ @override
+ String get incomingStranger => '附近的设备';
+
+ @override
+ String get friendsStrip => '好友';
+
+ @override
+ String get strangersStrip => '附近开着「所有人」的设备';
+
+ @override
+ String get strangerNearby => '附近';
+
+ @override
+ String get friendNeedService => '需要打开服务';
+
+ @override
+ String get friendCantReach => '无法连接';
+
+ @override
+ String reachSelfNoService(String name) {
+ return '你和 $name 不在同一个局域网。打开服务后就能给对方发文件,直连不了时经服务中转。';
+ }
+
+ @override
+ String reachPeerNoService(String name) {
+ return '$name 没有打开服务,不在同一个局域网时发不了。请对方在隔空贴里打开服务。';
+ }
+
+ @override
+ String get reachDifferentServer => '你们用的不是同一台服务器。双方都打开服务,或者改用同一台服务器后就能发。';
+
+ @override
+ String get receiveFromLabel => '允许这些人给我发文件:';
+
+ @override
+ String get receiveFromOff => '均不允许';
+
+ @override
+ String get receiveFromFriends => '仅限好友';
+
+ @override
+ String get receiveFromEveryone => '所有人';
+
+ @override
+ String everyoneLeft(String minutes) {
+ return '所有人 · 还剩 $minutes 分钟';
+ }
+
+ @override
+ String get receiveFromOffDesc => '只有你配对的电脑能发。';
+
+ @override
+ String get receiveFromFriendsDesc => '好友能发,每次由你接受。';
+
+ @override
+ String get receiveFromEveryoneDesc => '同一局域网里的人都能发,每次由你接受;10 分钟后改回「仅限好友」。';
+
+ @override
+ String get everyoneEnded => '「所有人」已结束,改回「仅限好友」。';
+
+ @override
+ String get friendsCountTooltip => '好友';
+
+ @override
+ String get waitingAccept => '等待接受';
}
/// The translations for Chinese, as used in Hong Kong, using the Han script (`zh_Hant_HK`).
@@ -3436,122 +3748,434 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
String get transferCopyPath => '拷貝路徑';
@override
- String get transferPathCopied => '已拷貝路徑';
+ String get transferPathCopied => '已拷貝路徑';
+
+ @override
+ String sendingTo(String name, String percent) {
+ return '正在傳給 $name · $percent';
+ }
+
+ @override
+ String receivingFrom(String name, String percent) {
+ return '正在接收 $name 的檔案 · $percent';
+ }
+
+ @override
+ String get receiveFiles => '接收其他裝置傳來的檔案';
+
+ @override
+ String get saveTo => '儲存到';
+
+ @override
+ String get saveToChange => '更改…';
+
+ @override
+ String get saveToDefault => '下載(預設)';
+
+ @override
+ String get saveToUseDefault => '改回「下載」';
+
+ @override
+ String get receiveNotify => '收到檔案時通知';
+
+ @override
+ String receiveFootnote(String device) {
+ return '只有已配對的裝置能傳檔案給$device。傳輸期間$device不會自動睡眠。';
+ }
+
+ @override
+ String get saveDirNotFound => '這個資料夾不存在。';
+
+ @override
+ String get saveDirNotWritable => '隔空貼無法把檔案存到這個資料夾。';
+
+ @override
+ String get saveDirPermission =>
+ '隔空貼還沒有使用這個資料夾的權限。請在「系統設定 → 私隱與保安 → 檔案和資料夾」中允許。';
+
+ @override
+ String transferRenamed(int count) {
+ return '$count 個檔名含 Windows 不支援的字元,已換成相近的全形字元';
+ }
+
+ @override
+ String get sendRingLan => '同一網絡';
+
+ @override
+ String get sendRingOther => '其他網絡';
+
+ @override
+ String sendOfflineList(String names) {
+ return '離線:$names';
+ }
+
+ @override
+ String get listSeparator => '、';
+
+ @override
+ String get sendLayout => '傳輸列表';
+
+ @override
+ String get sendLayoutSide => '在雷達右邊';
+
+ @override
+ String get sendLayoutBelow => '在雷達下面';
+
+ @override
+ String get general => '一般';
+
+ @override
+ String get launchAtLogin => '開機啟動';
+
+ @override
+ String get launchAtLoginDesc => '登入電腦後在背景啟動,不開啟主視窗。更改此項不會停止目前的運作。';
+
+ @override
+ String get realtimeSync => '即時同步剪貼簿';
+
+ @override
+ String get realtimeSyncDesc => '自動與配對裝置同步新複製的內容。關閉後仍保留本機記錄,也可手動隔空傳送。';
+
+ @override
+ String get syncBacklog => '重新連線後補傳離線內容';
+
+ @override
+ String get syncBacklogDesc =>
+ '預設關閉:離線期間未送達的內容不再補傳。開啟後最多補傳 24 小時內的 20 筆記錄,不覆寫目前的剪貼簿。';
+
+ @override
+ String get peerRealtimeSync => '與這部電腦即時同步';
+
+ @override
+ String get syncPaused => '剪貼簿同步已暫停';
+
+ @override
+ String get quitApp => '退出隔空貼';
+
+ @override
+ String get quitAppDesc => '結束隔空貼的全部程序,保留開機啟動設定。';
+
+ @override
+ String get quitTransfersWarning => '還有檔案正在傳輸,要中斷傳輸並退出嗎?';
+
+ @override
+ String get backgroundRunningTitle => '隔空貼將繼續在背景運作';
+
+ @override
+ String get backgroundRunningBody =>
+ '關閉視窗後,同步和快速貼上仍會運作。如需完全停止,請在設定或應用程式選單選擇「退出隔空貼」。';
+
+ @override
+ String get displayAs => '顯示為';
+
+ @override
+ String get editName => '修改名稱';
+
+ @override
+ String get nameHint => '好友看到的名稱';
+
+ @override
+ String get nameDefaultHint => '留空則使用系統的用戶名稱。';
+
+ @override
+ String get avatarTitle => '設定頭像';
+
+ @override
+ String get avatarChoose => '選擇圖片…';
+
+ @override
+ String get avatarPaste => '貼上圖片';
+
+ @override
+ String get avatarReset => '恢復預設頭像';
+
+ @override
+ String get avatarZoom => '縮放';
+
+ @override
+ String get avatarDragHint => '拖曳可以移動圖片。';
+
+ @override
+ String get avatarNoImage => '剪貼簿裏沒有圖片。';
+
+ @override
+ String get avatarBad => '這張圖片無法使用,請換一張 PNG、JPEG 或 GIF。';
+
+ @override
+ String get done => '完成';
+
+ @override
+ String get friendsTitle => '好友';
+
+ @override
+ String get addFriend => '新增好友';
+
+ @override
+ String get friendsEmpty => '還沒有好友';
+
+ @override
+ String get friendsEmptyBody => '加了好友,就能互相傳檔案,不用配對。好友只能傳檔案,看不到你的剪貼簿。';
+
+ @override
+ String get friendSendAction => '傳送…';
+
+ @override
+ String get friendHistory => '傳輸記錄';
+
+ @override
+ String friendHistoryTitle(String name) {
+ return '和 $name 的傳輸';
+ }
+
+ @override
+ String get friendHistoryEmpty => '還沒有傳過檔案。';
+
+ @override
+ String get friendAutoAccept => '自動接收此好友的檔案';
+
+ @override
+ String get friendRemove => '刪除好友';
+
+ @override
+ String friendRemoveTitle(String name) {
+ return '刪除好友「$name」?';
+ }
+
+ @override
+ String get friendRemoveBody => '雙方都會刪除對方,之後互相傳不了檔案。以前的傳輸記錄仍留在這部電腦上。';
+
+ @override
+ String friendLastActivity(String time) {
+ return '$time傳過';
+ }
+
+ @override
+ String get friendNoActivity => '還沒傳過檔案';
+
+ @override
+ String get friendCodeShare => '把這個碼傳給好友,對方在隔空貼裏輸入後,你們就成為好友。';
+
+ @override
+ String friendCodeExpires(String time) {
+ return '$time 後失效';
+ }
+
+ @override
+ String get friendCodeOr => '或者';
+
+ @override
+ String get friendCodeEnter => '輸入對方的好友碼';
+
+ @override
+ String get friendCodeAdd => '新增';
+
+ @override
+ String get friendCodeWaiting => '等待對方輸入…';
+
+ @override
+ String friendConfirmBody(String name) {
+ return '新增 $name 為好友?';
+ }
+
+ @override
+ String get friendSafetyCode => '核對安全碼(可選)';
+
+ @override
+ String get friendSafetyHint => '面對面時可以核對:兩邊顯示的這兩行一樣,就沒有被人調包。';
+
+ @override
+ String get friendWaitingPeer => '等待對方新增…';
+
+ @override
+ String friendAdded(String name) {
+ return '已新增 $name 為好友';
+ }
+
+ @override
+ String friendPeerCancelled(String name) {
+ return '$name 取消了';
+ }
+
+ @override
+ String get friendErrFriendCode => '這是好友碼,請在隔空傳送頁的「新增好友」裏輸入。';
+
+ @override
+ String get friendErrDeviceCode => '這是配對碼,請在「裝置 → 新增裝置」裏輸入。';
+
+ @override
+ String get friendErrOutdated => '對方需要更新到隔空貼 2.6.0 或更新版本。';
+
+ @override
+ String get friendErrAlreadyPaired => '這部電腦已經是你的裝置。';
+
+ @override
+ String get friendErrNoChannel => '你們不在同一個區域網絡,雙方都開啟「服務」後才能新增。';
+
+ @override
+ String get openService => '開啟服務…';
+
+ @override
+ String get noteLabel => '備註(可選)';
+
+ @override
+ String get noteHintEmpty => '先選擇要傳送的檔案';
+
+ @override
+ String get noteHint => '例如:合約第 3 頁要簽名';
+
+ @override
+ String noteLine(String note) {
+ return '備註:$note';
+ }
+
+ @override
+ String get sendAction => '傳送';
+
+ @override
+ String sendItemsSummary(String count, String size) {
+ return '共 $count 項 · $size';
+ }
+
+ @override
+ String sendDropOrPaste(String key) {
+ return '把檔案或圖片拖到這裏,或貼上($key)';
+ }
+
+ @override
+ String get sendDropMorePaste => '繼續拖入或貼上';
+
+ @override
+ String get sendPasteNothing => '剪貼簿裏沒有檔案或圖片。';
+
+ @override
+ String get sendRemoveItem => '移除';
+
+ @override
+ String sendFriendSaved(String name) {
+ return '對方按「接受」後才開始傳送。';
+ }
+
+ @override
+ String transferAskingOut(String name) {
+ return '等待 $name 接受…';
+ }
@override
- String sendingTo(String name, String percent) {
- return '正在傳給 $name · $percent';
- }
+ String get transferAskingIn => '等你接受';
@override
- String receivingFrom(String name, String percent) {
- return '正在接收 $name 的檔案 · $percent';
+ String reasonDeclined(String name) {
+ return '$name 拒絕了';
}
@override
- String get receiveFiles => '接收其他裝置傳來的檔案';
+ String reasonTimeout(String name) {
+ return '$name 沒有回應';
+ }
@override
- String get saveTo => '儲存到';
+ String reasonNotAllowed(String name) {
+ return '$name 不接收檔案';
+ }
@override
- String get saveToChange => '更改…';
+ String reasonRateLimited(String name) {
+ return '$name 暫時不接收你的檔案';
+ }
@override
- String get saveToDefault => '下載(預設)';
+ String get reasonYouDeclined => '已拒絕';
@override
- String get saveToUseDefault => '改回「下載」';
+ String get reasonYouIgnored => '已忽略';
@override
- String get receiveNotify => '收到檔案時通知';
+ String get sendAgain => '再傳一次';
@override
- String receiveFootnote(String device) {
- return '只有已配對的裝置能傳檔案給$device。傳輸期間$device不會自動睡眠。';
+ String incomingTitle(String name) {
+ return '$name 想傳檔案給你';
}
@override
- String get saveDirNotFound => '這個資料夾不存在。';
+ String get incomingAlways => '以後自動接收此好友的檔案';
@override
- String get saveDirNotWritable => '隔空貼無法把檔案存到這個資料夾。';
+ String get incomingDecline => '拒絕';
@override
- String get saveDirPermission =>
- '隔空貼還沒有使用這個資料夾的權限。請在「系統設定 → 私隱與保安 → 檔案和資料夾」中允許。';
+ String get incomingAccept => '接受';
@override
- String transferRenamed(int count) {
- return '$count 個檔名含 Windows 不支援的字元,已換成相近的全形字元';
+ String incomingCountdown(String seconds) {
+ return '$seconds 秒後自動拒絕';
}
@override
- String get sendRingLan => '同一網絡';
-
- @override
- String get sendRingOther => '其他網絡';
+ String get incomingStranger => '附近的裝置';
@override
- String sendOfflineList(String names) {
- return '離線:$names';
- }
+ String get friendsStrip => '好友';
@override
- String get listSeparator => '、';
+ String get strangersStrip => '附近開著「所有人」的裝置';
@override
- String get sendLayout => '傳輸列表';
+ String get strangerNearby => '附近';
@override
- String get sendLayoutSide => '在雷達右邊';
+ String get friendNeedService => '需要開啟服務';
@override
- String get sendLayoutBelow => '在雷達下面';
+ String get friendCantReach => '無法連線';
@override
- String get general => '一般';
+ String reachSelfNoService(String name) {
+ return '你和 $name 不在同一個區域網絡。開啟服務後就能傳檔案給對方,直連不了時經服務中轉。';
+ }
@override
- String get launchAtLogin => '開機啟動';
+ String reachPeerNoService(String name) {
+ return '$name 沒有開啟服務,不在同一個區域網絡時傳不了。請對方在隔空貼裏開啟服務。';
+ }
@override
- String get launchAtLoginDesc => '登入電腦後在背景啟動,不開啟主視窗。更改此項不會停止目前的運作。';
+ String get reachDifferentServer => '你們用的不是同一部伺服器。雙方都開啟服務,或者改用同一部伺服器後就能傳。';
@override
- String get realtimeSync => '即時同步剪貼簿';
+ String get receiveFromLabel => '允許這些人傳檔案給我:';
@override
- String get realtimeSyncDesc => '自動與配對裝置同步新複製的內容。關閉後仍保留本機記錄,也可手動隔空傳送。';
+ String get receiveFromOff => '均不允許';
@override
- String get syncBacklog => '重新連線後補傳離線內容';
+ String get receiveFromFriends => '只限好友';
@override
- String get syncBacklogDesc =>
- '預設關閉:離線期間未送達的內容不再補傳。開啟後最多補傳 24 小時內的 20 筆記錄,不覆寫目前的剪貼簿。';
+ String get receiveFromEveryone => '所有人';
@override
- String get peerRealtimeSync => '與這部電腦即時同步';
+ String everyoneLeft(String minutes) {
+ return '所有人 · 還剩 $minutes 分鐘';
+ }
@override
- String get syncPaused => '剪貼簿同步已暫停';
+ String get receiveFromOffDesc => '只有你配對的電腦能傳。';
@override
- String get quitApp => '退出隔空貼';
+ String get receiveFromFriendsDesc => '好友能傳,每次由你接受。';
@override
- String get quitAppDesc => '結束隔空貼的全部程序,保留開機啟動設定。';
+ String get receiveFromEveryoneDesc => '同一區域網絡裏的人都能傳,每次由你接受;10 分鐘後改回「只限好友」。';
@override
- String get quitTransfersWarning => '還有檔案正在傳輸,要中斷傳輸並退出嗎?';
+ String get everyoneEnded => '「所有人」已結束,改回「只限好友」。';
@override
- String get backgroundRunningTitle => '隔空貼將繼續在背景運作';
+ String get friendsCountTooltip => '好友';
@override
- String get backgroundRunningBody =>
- '關閉視窗後,同步和快速貼上仍會運作。如需完全停止,請在設定或應用程式選單選擇「退出隔空貼」。';
+ String get waitingAccept => '等待接受';
}
/// The translations for Chinese, as used in Taiwan, using the Han script (`zh_Hant_TW`).
@@ -5327,4 +5951,316 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
@override
String get backgroundRunningBody =>
'關閉視窗後,同步和快速貼上仍會執行。如需完全停止,請在設定或應用程式選單選擇「結束隔空貼」。';
+
+ @override
+ String get displayAs => '顯示為';
+
+ @override
+ String get editName => '修改名稱';
+
+ @override
+ String get nameHint => '好友看到的名稱';
+
+ @override
+ String get nameDefaultHint => '留空則使用系統的使用者名稱。';
+
+ @override
+ String get avatarTitle => '設定頭像';
+
+ @override
+ String get avatarChoose => '選擇圖片…';
+
+ @override
+ String get avatarPaste => '貼上圖片';
+
+ @override
+ String get avatarReset => '恢復預設頭像';
+
+ @override
+ String get avatarZoom => '縮放';
+
+ @override
+ String get avatarDragHint => '拖曳可以移動圖片。';
+
+ @override
+ String get avatarNoImage => '剪貼簿裡沒有圖片。';
+
+ @override
+ String get avatarBad => '這張圖片無法使用,請換一張 PNG、JPEG 或 GIF。';
+
+ @override
+ String get done => '完成';
+
+ @override
+ String get friendsTitle => '好友';
+
+ @override
+ String get addFriend => '新增好友';
+
+ @override
+ String get friendsEmpty => '還沒有好友';
+
+ @override
+ String get friendsEmptyBody => '加了好友,就能互相傳檔案,不用配對。好友只能傳檔案,看不到你的剪貼簿。';
+
+ @override
+ String get friendSendAction => '傳送…';
+
+ @override
+ String get friendHistory => '傳輸記錄';
+
+ @override
+ String friendHistoryTitle(String name) {
+ return '和 $name 的傳輸';
+ }
+
+ @override
+ String get friendHistoryEmpty => '還沒有傳過檔案。';
+
+ @override
+ String get friendAutoAccept => '自動接收此好友的檔案';
+
+ @override
+ String get friendRemove => '刪除好友';
+
+ @override
+ String friendRemoveTitle(String name) {
+ return '刪除好友「$name」?';
+ }
+
+ @override
+ String get friendRemoveBody => '雙方都會刪除對方,之後互相傳不了檔案。以前的傳輸記錄仍留在這台電腦上。';
+
+ @override
+ String friendLastActivity(String time) {
+ return '$time傳過';
+ }
+
+ @override
+ String get friendNoActivity => '還沒傳過檔案';
+
+ @override
+ String get friendCodeShare => '把這個碼傳給好友,對方在隔空貼裡輸入後,你們就成為好友。';
+
+ @override
+ String friendCodeExpires(String time) {
+ return '$time 後失效';
+ }
+
+ @override
+ String get friendCodeOr => '或者';
+
+ @override
+ String get friendCodeEnter => '輸入對方的好友碼';
+
+ @override
+ String get friendCodeAdd => '新增';
+
+ @override
+ String get friendCodeWaiting => '等待對方輸入…';
+
+ @override
+ String friendConfirmBody(String name) {
+ return '新增 $name 為好友?';
+ }
+
+ @override
+ String get friendSafetyCode => '核對安全碼(選填)';
+
+ @override
+ String get friendSafetyHint => '面對面時可以核對:兩邊顯示的這兩行一樣,就沒有被人調包。';
+
+ @override
+ String get friendWaitingPeer => '等待對方新增…';
+
+ @override
+ String friendAdded(String name) {
+ return '已新增 $name 為好友';
+ }
+
+ @override
+ String friendPeerCancelled(String name) {
+ return '$name 取消了';
+ }
+
+ @override
+ String get friendErrFriendCode => '這是好友碼,請在隔空傳送頁的「新增好友」裡輸入。';
+
+ @override
+ String get friendErrDeviceCode => '這是配對碼,請在「裝置 → 新增裝置」裡輸入。';
+
+ @override
+ String get friendErrOutdated => '對方需要更新到隔空貼 2.6.0 或更新版本。';
+
+ @override
+ String get friendErrAlreadyPaired => '這台電腦已經是你的裝置。';
+
+ @override
+ String get friendErrNoChannel => '你們不在同一個區域網路,雙方都開啟「服務」後才能新增。';
+
+ @override
+ String get openService => '開啟服務…';
+
+ @override
+ String get noteLabel => '備註(選填)';
+
+ @override
+ String get noteHintEmpty => '先選擇要傳送的檔案';
+
+ @override
+ String get noteHint => '例如:合約第 3 頁要簽名';
+
+ @override
+ String noteLine(String note) {
+ return '備註:$note';
+ }
+
+ @override
+ String get sendAction => '傳送';
+
+ @override
+ String sendItemsSummary(String count, String size) {
+ return '共 $count 項 · $size';
+ }
+
+ @override
+ String sendDropOrPaste(String key) {
+ return '把檔案或圖片拖到這裡,或貼上($key)';
+ }
+
+ @override
+ String get sendDropMorePaste => '繼續拖入或貼上';
+
+ @override
+ String get sendPasteNothing => '剪貼簿裡沒有檔案或圖片。';
+
+ @override
+ String get sendRemoveItem => '移除';
+
+ @override
+ String sendFriendSaved(String name) {
+ return '對方按「接受」後才開始傳送。';
+ }
+
+ @override
+ String transferAskingOut(String name) {
+ return '等待 $name 接受…';
+ }
+
+ @override
+ String get transferAskingIn => '等你接受';
+
+ @override
+ String reasonDeclined(String name) {
+ return '$name 拒絕了';
+ }
+
+ @override
+ String reasonTimeout(String name) {
+ return '$name 沒有回應';
+ }
+
+ @override
+ String reasonNotAllowed(String name) {
+ return '$name 不接收檔案';
+ }
+
+ @override
+ String reasonRateLimited(String name) {
+ return '$name 暫時不接收你的檔案';
+ }
+
+ @override
+ String get reasonYouDeclined => '已拒絕';
+
+ @override
+ String get reasonYouIgnored => '已忽略';
+
+ @override
+ String get sendAgain => '再傳一次';
+
+ @override
+ String incomingTitle(String name) {
+ return '$name 想傳檔案給你';
+ }
+
+ @override
+ String get incomingAlways => '以後自動接收此好友的檔案';
+
+ @override
+ String get incomingDecline => '拒絕';
+
+ @override
+ String get incomingAccept => '接受';
+
+ @override
+ String incomingCountdown(String seconds) {
+ return '$seconds 秒後自動拒絕';
+ }
+
+ @override
+ String get incomingStranger => '附近的裝置';
+
+ @override
+ String get friendsStrip => '好友';
+
+ @override
+ String get strangersStrip => '附近開著「所有人」的裝置';
+
+ @override
+ String get strangerNearby => '附近';
+
+ @override
+ String get friendNeedService => '需要開啟服務';
+
+ @override
+ String get friendCantReach => '無法連線';
+
+ @override
+ String reachSelfNoService(String name) {
+ return '你和 $name 不在同一個區域網路。開啟服務後就能傳檔案給對方,直連不了時經服務中繼。';
+ }
+
+ @override
+ String reachPeerNoService(String name) {
+ return '$name 沒有開啟服務,不在同一個區域網路時傳不了。請對方在隔空貼裡開啟服務。';
+ }
+
+ @override
+ String get reachDifferentServer => '你們用的不是同一台伺服器。雙方都開啟服務,或者改用同一台伺服器後就能傳。';
+
+ @override
+ String get receiveFromLabel => '允許這些人傳檔案給我:';
+
+ @override
+ String get receiveFromOff => '均不允許';
+
+ @override
+ String get receiveFromFriends => '僅限好友';
+
+ @override
+ String get receiveFromEveryone => '所有人';
+
+ @override
+ String everyoneLeft(String minutes) {
+ return '所有人 · 還剩 $minutes 分鐘';
+ }
+
+ @override
+ String get receiveFromOffDesc => '只有你配對的電腦能傳。';
+
+ @override
+ String get receiveFromFriendsDesc => '好友能傳,每次由你接受。';
+
+ @override
+ String get receiveFromEveryoneDesc => '同一區域網路裡的人都能傳,每次由你接受;10 分鐘後改回「僅限好友」。';
+
+ @override
+ String get everyoneEnded => '「所有人」已結束,改回「僅限好友」。';
+
+ @override
+ String get friendsCountTooltip => '好友';
+
+ @override
+ String get waitingAccept => '等待接受';
}
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
index 8783d8d..c671863 100644
--- a/ui/lib/l10n/app_zh.arb
+++ b/ui/lib/l10n/app_zh.arb
@@ -513,5 +513,95 @@
"quitAppDesc": "结束隔空贴的全部进程,保留开机启动设置。",
"quitTransfersWarning": "还有文件正在传输,是否中断传输并退出?",
"backgroundRunningTitle": "隔空贴将继续在后台运行",
- "backgroundRunningBody": "关闭窗口后,同步和快捷粘贴仍会运行。如需完全停止,请在设置或应用菜单选择「退出隔空贴」。"
+ "backgroundRunningBody": "关闭窗口后,同步和快捷粘贴仍会运行。如需完全停止,请在设置或应用菜单选择「退出隔空贴」。",
+ "displayAs": "显示为",
+ "editName": "修改名字",
+ "nameHint": "好友看到的名字",
+ "nameDefaultHint": "留空则用系统的用户名。",
+ "avatarTitle": "设置头像",
+ "avatarChoose": "选择图片…",
+ "avatarPaste": "粘贴图片",
+ "avatarReset": "恢复默认头像",
+ "avatarZoom": "缩放",
+ "avatarDragHint": "拖动可以移动图片。",
+ "avatarNoImage": "剪贴板里没有图片。",
+ "avatarBad": "这张图片用不了,请换一张 PNG、JPEG 或 GIF。",
+ "done": "完成",
+ "friendsTitle": "好友",
+ "addFriend": "添加好友",
+ "friendsEmpty": "还没有好友",
+ "friendsEmptyBody": "加了好友,就能互相发文件,不用配对。好友只能发文件,看不到你的剪贴板。",
+ "friendSendAction": "发送…",
+ "friendHistory": "传输记录",
+ "friendHistoryTitle": "和 {name} 的传输",
+ "friendHistoryEmpty": "还没有传过文件。",
+ "friendAutoAccept": "自动接收此好友的文件",
+ "friendRemove": "删除好友",
+ "friendRemoveTitle": "删除好友「{name}」?",
+ "friendRemoveBody": "双方都会删除对方,之后互相发不了文件。以前的传输记录仍留在这台电脑上。",
+ "friendLastActivity": "{time}传过",
+ "friendNoActivity": "还没传过文件",
+ "friendCodeShare": "把这个码发给好友,对方在隔空贴里输入后,你们就成为好友。",
+ "friendCodeExpires": "{time} 后失效",
+ "friendCodeOr": "或者",
+ "friendCodeEnter": "输入对方的好友码",
+ "friendCodeAdd": "添加",
+ "friendCodeWaiting": "等待对方输入…",
+ "friendConfirmBody": "添加 {name} 为好友?",
+ "friendSafetyCode": "核对安全码(可选)",
+ "friendSafetyHint": "面对面时可以核对:两边显示的这两行一样,就没有被人调包。",
+ "friendWaitingPeer": "等待对方添加…",
+ "friendAdded": "已添加 {name} 为好友",
+ "friendPeerCancelled": "{name} 取消了",
+ "friendErrFriendCode": "这是好友码,请在隔空传送页的「添加好友」里输入。",
+ "friendErrDeviceCode": "这是配对码,请在「设备 → 添加设备」里输入。",
+ "friendErrOutdated": "对方需要更新到隔空贴 2.6.0 或更高版本。",
+ "friendErrAlreadyPaired": "这台电脑已经是你的设备。",
+ "friendErrNoChannel": "你们不在同一个局域网,双方都打开「服务」后才能添加。",
+ "openService": "打开服务…",
+ "noteLabel": "备注(可选)",
+ "noteHintEmpty": "先选择要发送的文件",
+ "noteHint": "比如:合同第 3 页要签字",
+ "noteLine": "备注:{note}",
+ "sendAction": "发送",
+ "sendItemsSummary": "共 {count} 项 · {size}",
+ "sendDropOrPaste": "把文件或图片拖到这里,或粘贴({key})",
+ "sendDropMorePaste": "继续拖入或粘贴",
+ "sendPasteNothing": "剪贴板里没有文件或图片。",
+ "sendRemoveItem": "移除",
+ "sendFriendSaved": "对方点「接受」后才开始发送。",
+ "transferAskingOut": "等待 {name} 接受…",
+ "transferAskingIn": "等你接受",
+ "reasonDeclined": "{name} 拒绝了",
+ "reasonTimeout": "{name} 没有回应",
+ "reasonNotAllowed": "{name} 不接收文件",
+ "reasonRateLimited": "{name} 暂时不接收你的文件",
+ "reasonYouDeclined": "已拒绝",
+ "reasonYouIgnored": "已忽略",
+ "sendAgain": "再发一次",
+ "incomingTitle": "{name} 想发给你文件",
+ "incomingAlways": "以后自动接收此好友的文件",
+ "incomingDecline": "拒绝",
+ "incomingAccept": "接受",
+ "incomingCountdown": "{seconds} 秒后自动拒绝",
+ "incomingStranger": "附近的设备",
+ "friendsStrip": "好友",
+ "strangersStrip": "附近开着「所有人」的设备",
+ "strangerNearby": "附近",
+ "friendNeedService": "需要打开服务",
+ "friendCantReach": "无法连接",
+ "reachSelfNoService": "你和 {name} 不在同一个局域网。打开服务后就能给对方发文件,直连不了时经服务中转。",
+ "reachPeerNoService": "{name} 没有打开服务,不在同一个局域网时发不了。请对方在隔空贴里打开服务。",
+ "reachDifferentServer": "你们用的不是同一台服务器。双方都打开服务,或者改用同一台服务器后就能发。",
+ "receiveFromLabel": "允许这些人给我发文件:",
+ "receiveFromOff": "均不允许",
+ "receiveFromFriends": "仅限好友",
+ "receiveFromEveryone": "所有人",
+ "everyoneLeft": "所有人 · 还剩 {minutes} 分钟",
+ "receiveFromOffDesc": "只有你配对的电脑能发。",
+ "receiveFromFriendsDesc": "好友能发,每次由你接受。",
+ "receiveFromEveryoneDesc": "同一局域网里的人都能发,每次由你接受;10 分钟后改回「仅限好友」。",
+ "everyoneEnded": "「所有人」已结束,改回「仅限好友」。",
+ "friendsCountTooltip": "好友",
+ "waitingAccept": "等待接受"
}
diff --git a/ui/lib/l10n/app_zh_Hant_HK.arb b/ui/lib/l10n/app_zh_Hant_HK.arb
index 66543ad..83ee96d 100644
--- a/ui/lib/l10n/app_zh_Hant_HK.arb
+++ b/ui/lib/l10n/app_zh_Hant_HK.arb
@@ -513,5 +513,95 @@
"quitAppDesc": "結束隔空貼的全部程序,保留開機啟動設定。",
"quitTransfersWarning": "還有檔案正在傳輸,要中斷傳輸並退出嗎?",
"backgroundRunningTitle": "隔空貼將繼續在背景運作",
- "backgroundRunningBody": "關閉視窗後,同步和快速貼上仍會運作。如需完全停止,請在設定或應用程式選單選擇「退出隔空貼」。"
+ "backgroundRunningBody": "關閉視窗後,同步和快速貼上仍會運作。如需完全停止,請在設定或應用程式選單選擇「退出隔空貼」。",
+ "displayAs": "顯示為",
+ "editName": "修改名稱",
+ "nameHint": "好友看到的名稱",
+ "nameDefaultHint": "留空則使用系統的用戶名稱。",
+ "avatarTitle": "設定頭像",
+ "avatarChoose": "選擇圖片…",
+ "avatarPaste": "貼上圖片",
+ "avatarReset": "恢復預設頭像",
+ "avatarZoom": "縮放",
+ "avatarDragHint": "拖曳可以移動圖片。",
+ "avatarNoImage": "剪貼簿裏沒有圖片。",
+ "avatarBad": "這張圖片無法使用,請換一張 PNG、JPEG 或 GIF。",
+ "done": "完成",
+ "friendsTitle": "好友",
+ "addFriend": "新增好友",
+ "friendsEmpty": "還沒有好友",
+ "friendsEmptyBody": "加了好友,就能互相傳檔案,不用配對。好友只能傳檔案,看不到你的剪貼簿。",
+ "friendSendAction": "傳送…",
+ "friendHistory": "傳輸記錄",
+ "friendHistoryTitle": "和 {name} 的傳輸",
+ "friendHistoryEmpty": "還沒有傳過檔案。",
+ "friendAutoAccept": "自動接收此好友的檔案",
+ "friendRemove": "刪除好友",
+ "friendRemoveTitle": "刪除好友「{name}」?",
+ "friendRemoveBody": "雙方都會刪除對方,之後互相傳不了檔案。以前的傳輸記錄仍留在這部電腦上。",
+ "friendLastActivity": "{time}傳過",
+ "friendNoActivity": "還沒傳過檔案",
+ "friendCodeShare": "把這個碼傳給好友,對方在隔空貼裏輸入後,你們就成為好友。",
+ "friendCodeExpires": "{time} 後失效",
+ "friendCodeOr": "或者",
+ "friendCodeEnter": "輸入對方的好友碼",
+ "friendCodeAdd": "新增",
+ "friendCodeWaiting": "等待對方輸入…",
+ "friendConfirmBody": "新增 {name} 為好友?",
+ "friendSafetyCode": "核對安全碼(可選)",
+ "friendSafetyHint": "面對面時可以核對:兩邊顯示的這兩行一樣,就沒有被人調包。",
+ "friendWaitingPeer": "等待對方新增…",
+ "friendAdded": "已新增 {name} 為好友",
+ "friendPeerCancelled": "{name} 取消了",
+ "friendErrFriendCode": "這是好友碼,請在隔空傳送頁的「新增好友」裏輸入。",
+ "friendErrDeviceCode": "這是配對碼,請在「裝置 → 新增裝置」裏輸入。",
+ "friendErrOutdated": "對方需要更新到隔空貼 2.6.0 或更新版本。",
+ "friendErrAlreadyPaired": "這部電腦已經是你的裝置。",
+ "friendErrNoChannel": "你們不在同一個區域網絡,雙方都開啟「服務」後才能新增。",
+ "openService": "開啟服務…",
+ "noteLabel": "備註(可選)",
+ "noteHintEmpty": "先選擇要傳送的檔案",
+ "noteHint": "例如:合約第 3 頁要簽名",
+ "noteLine": "備註:{note}",
+ "sendAction": "傳送",
+ "sendItemsSummary": "共 {count} 項 · {size}",
+ "sendDropOrPaste": "把檔案或圖片拖到這裏,或貼上({key})",
+ "sendDropMorePaste": "繼續拖入或貼上",
+ "sendPasteNothing": "剪貼簿裏沒有檔案或圖片。",
+ "sendRemoveItem": "移除",
+ "sendFriendSaved": "對方按「接受」後才開始傳送。",
+ "transferAskingOut": "等待 {name} 接受…",
+ "transferAskingIn": "等你接受",
+ "reasonDeclined": "{name} 拒絕了",
+ "reasonTimeout": "{name} 沒有回應",
+ "reasonNotAllowed": "{name} 不接收檔案",
+ "reasonRateLimited": "{name} 暫時不接收你的檔案",
+ "reasonYouDeclined": "已拒絕",
+ "reasonYouIgnored": "已忽略",
+ "sendAgain": "再傳一次",
+ "incomingTitle": "{name} 想傳檔案給你",
+ "incomingAlways": "以後自動接收此好友的檔案",
+ "incomingDecline": "拒絕",
+ "incomingAccept": "接受",
+ "incomingCountdown": "{seconds} 秒後自動拒絕",
+ "incomingStranger": "附近的裝置",
+ "friendsStrip": "好友",
+ "strangersStrip": "附近開著「所有人」的裝置",
+ "strangerNearby": "附近",
+ "friendNeedService": "需要開啟服務",
+ "friendCantReach": "無法連線",
+ "reachSelfNoService": "你和 {name} 不在同一個區域網絡。開啟服務後就能傳檔案給對方,直連不了時經服務中轉。",
+ "reachPeerNoService": "{name} 沒有開啟服務,不在同一個區域網絡時傳不了。請對方在隔空貼裏開啟服務。",
+ "reachDifferentServer": "你們用的不是同一部伺服器。雙方都開啟服務,或者改用同一部伺服器後就能傳。",
+ "receiveFromLabel": "允許這些人傳檔案給我:",
+ "receiveFromOff": "均不允許",
+ "receiveFromFriends": "只限好友",
+ "receiveFromEveryone": "所有人",
+ "everyoneLeft": "所有人 · 還剩 {minutes} 分鐘",
+ "receiveFromOffDesc": "只有你配對的電腦能傳。",
+ "receiveFromFriendsDesc": "好友能傳,每次由你接受。",
+ "receiveFromEveryoneDesc": "同一區域網絡裏的人都能傳,每次由你接受;10 分鐘後改回「只限好友」。",
+ "everyoneEnded": "「所有人」已結束,改回「只限好友」。",
+ "friendsCountTooltip": "好友",
+ "waitingAccept": "等待接受"
}
diff --git a/ui/lib/l10n/app_zh_Hant_TW.arb b/ui/lib/l10n/app_zh_Hant_TW.arb
index ae4b6f7..f79f529 100644
--- a/ui/lib/l10n/app_zh_Hant_TW.arb
+++ b/ui/lib/l10n/app_zh_Hant_TW.arb
@@ -513,5 +513,95 @@
"quitAppDesc": "結束隔空貼的全部程序,保留開機啟動設定。",
"quitTransfersWarning": "還有檔案正在傳輸,要中斷傳輸並結束嗎?",
"backgroundRunningTitle": "隔空貼將繼續在背景執行",
- "backgroundRunningBody": "關閉視窗後,同步和快速貼上仍會執行。如需完全停止,請在設定或應用程式選單選擇「結束隔空貼」。"
+ "backgroundRunningBody": "關閉視窗後,同步和快速貼上仍會執行。如需完全停止,請在設定或應用程式選單選擇「結束隔空貼」。",
+ "displayAs": "顯示為",
+ "editName": "修改名稱",
+ "nameHint": "好友看到的名稱",
+ "nameDefaultHint": "留空則使用系統的使用者名稱。",
+ "avatarTitle": "設定頭像",
+ "avatarChoose": "選擇圖片…",
+ "avatarPaste": "貼上圖片",
+ "avatarReset": "恢復預設頭像",
+ "avatarZoom": "縮放",
+ "avatarDragHint": "拖曳可以移動圖片。",
+ "avatarNoImage": "剪貼簿裡沒有圖片。",
+ "avatarBad": "這張圖片無法使用,請換一張 PNG、JPEG 或 GIF。",
+ "done": "完成",
+ "friendsTitle": "好友",
+ "addFriend": "新增好友",
+ "friendsEmpty": "還沒有好友",
+ "friendsEmptyBody": "加了好友,就能互相傳檔案,不用配對。好友只能傳檔案,看不到你的剪貼簿。",
+ "friendSendAction": "傳送…",
+ "friendHistory": "傳輸記錄",
+ "friendHistoryTitle": "和 {name} 的傳輸",
+ "friendHistoryEmpty": "還沒有傳過檔案。",
+ "friendAutoAccept": "自動接收此好友的檔案",
+ "friendRemove": "刪除好友",
+ "friendRemoveTitle": "刪除好友「{name}」?",
+ "friendRemoveBody": "雙方都會刪除對方,之後互相傳不了檔案。以前的傳輸記錄仍留在這台電腦上。",
+ "friendLastActivity": "{time}傳過",
+ "friendNoActivity": "還沒傳過檔案",
+ "friendCodeShare": "把這個碼傳給好友,對方在隔空貼裡輸入後,你們就成為好友。",
+ "friendCodeExpires": "{time} 後失效",
+ "friendCodeOr": "或者",
+ "friendCodeEnter": "輸入對方的好友碼",
+ "friendCodeAdd": "新增",
+ "friendCodeWaiting": "等待對方輸入…",
+ "friendConfirmBody": "新增 {name} 為好友?",
+ "friendSafetyCode": "核對安全碼(選填)",
+ "friendSafetyHint": "面對面時可以核對:兩邊顯示的這兩行一樣,就沒有被人調包。",
+ "friendWaitingPeer": "等待對方新增…",
+ "friendAdded": "已新增 {name} 為好友",
+ "friendPeerCancelled": "{name} 取消了",
+ "friendErrFriendCode": "這是好友碼,請在隔空傳送頁的「新增好友」裡輸入。",
+ "friendErrDeviceCode": "這是配對碼,請在「裝置 → 新增裝置」裡輸入。",
+ "friendErrOutdated": "對方需要更新到隔空貼 2.6.0 或更新版本。",
+ "friendErrAlreadyPaired": "這台電腦已經是你的裝置。",
+ "friendErrNoChannel": "你們不在同一個區域網路,雙方都開啟「服務」後才能新增。",
+ "openService": "開啟服務…",
+ "noteLabel": "備註(選填)",
+ "noteHintEmpty": "先選擇要傳送的檔案",
+ "noteHint": "例如:合約第 3 頁要簽名",
+ "noteLine": "備註:{note}",
+ "sendAction": "傳送",
+ "sendItemsSummary": "共 {count} 項 · {size}",
+ "sendDropOrPaste": "把檔案或圖片拖到這裡,或貼上({key})",
+ "sendDropMorePaste": "繼續拖入或貼上",
+ "sendPasteNothing": "剪貼簿裡沒有檔案或圖片。",
+ "sendRemoveItem": "移除",
+ "sendFriendSaved": "對方按「接受」後才開始傳送。",
+ "transferAskingOut": "等待 {name} 接受…",
+ "transferAskingIn": "等你接受",
+ "reasonDeclined": "{name} 拒絕了",
+ "reasonTimeout": "{name} 沒有回應",
+ "reasonNotAllowed": "{name} 不接收檔案",
+ "reasonRateLimited": "{name} 暫時不接收你的檔案",
+ "reasonYouDeclined": "已拒絕",
+ "reasonYouIgnored": "已忽略",
+ "sendAgain": "再傳一次",
+ "incomingTitle": "{name} 想傳檔案給你",
+ "incomingAlways": "以後自動接收此好友的檔案",
+ "incomingDecline": "拒絕",
+ "incomingAccept": "接受",
+ "incomingCountdown": "{seconds} 秒後自動拒絕",
+ "incomingStranger": "附近的裝置",
+ "friendsStrip": "好友",
+ "strangersStrip": "附近開著「所有人」的裝置",
+ "strangerNearby": "附近",
+ "friendNeedService": "需要開啟服務",
+ "friendCantReach": "無法連線",
+ "reachSelfNoService": "你和 {name} 不在同一個區域網路。開啟服務後就能傳檔案給對方,直連不了時經服務中繼。",
+ "reachPeerNoService": "{name} 沒有開啟服務,不在同一個區域網路時傳不了。請對方在隔空貼裡開啟服務。",
+ "reachDifferentServer": "你們用的不是同一台伺服器。雙方都開啟服務,或者改用同一台伺服器後就能傳。",
+ "receiveFromLabel": "允許這些人傳檔案給我:",
+ "receiveFromOff": "均不允許",
+ "receiveFromFriends": "僅限好友",
+ "receiveFromEveryone": "所有人",
+ "everyoneLeft": "所有人 · 還剩 {minutes} 分鐘",
+ "receiveFromOffDesc": "只有你配對的電腦能傳。",
+ "receiveFromFriendsDesc": "好友能傳,每次由你接受。",
+ "receiveFromEveryoneDesc": "同一區域網路裡的人都能傳,每次由你接受;10 分鐘後改回「僅限好友」。",
+ "everyoneEnded": "「所有人」已結束,改回「僅限好友」。",
+ "friendsCountTooltip": "好友",
+ "waitingAccept": "等待接受"
}
diff --git a/ui/lib/main.dart b/ui/lib/main.dart
index 738f344..63ceae6 100644
--- a/ui/lib/main.dart
+++ b/ui/lib/main.dart
@@ -18,6 +18,8 @@ import 'picker/picker_main.dart';
import 'theme.dart';
import 'widgets/common.dart';
import 'widgets/pairing_dialog.dart';
+import 'widgets/friends_dialog.dart';
+import 'widgets/incoming_dialog.dart';
import 'widgets/update_dialog.dart';
import 'icons.dart';
@@ -139,6 +141,9 @@ class _ShellState extends State<Shell> with WidgetsBindingObserver {
late Section _section = widget.initialSection;
bool _pairingDialogOpen = false;
bool _officialDialogOpen = false;
+ // 加好友的确认框、别人发来文件等接受的弹窗(2.6.0)
+ bool _friendDialogOpen = false;
+ bool _incomingDialogOpen = false;
int _seenOfficialNavigation = 0;
int _seenPageRequest = 0;
String? _shownUpdateResult;
@@ -174,6 +179,7 @@ class _ShellState extends State<Shell> with WidgetsBindingObserver {
if (state.pageRequestSerial != _seenPageRequest) {
_seenPageRequest = state.pageRequestSerial;
if (state.pageRequest == 'send') _section = Section.send;
+ if (state.pageRequest == 'settings') _section = Section.settings;
}
if (!state.officialEnabled && _section == Section.official) {
_section = Section.settings;
@@ -193,6 +199,34 @@ class _ShellState extends State<Shell> with WidgetsBindingObserver {
if (mounted) setState(() => _pairingDialogOpen = false);
});
}
+ // 有人兑换了本机的好友码:弹出确认框
+ final friendRequest = state.pendingFriendRequest;
+ if (friendRequest != null && pending == null && !_pairingDialogOpen && !_friendDialogOpen) {
+ _friendDialogOpen = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
+ if (!mounted) return;
+ if (state.pendingFriendRequest?.session != friendRequest.session) {
+ setState(() => _friendDialogOpen = false);
+ return;
+ }
+ // 「添加好友」窗口还开着:先关掉,确认框接着它
+ Navigator.of(context).popUntil((r) => r.isFirst);
+ state.dismissPendingFriend();
+ await showFriendConfirmDialog(context, friendRequest);
+ if (mounted) setState(() => _friendDialogOpen = false);
+ });
+ }
+ // 好友或附近的陌生设备发来文件,等用户接受
+ final asking = state.askingIncoming.firstOrNull;
+ if (asking != null && pending == null && !_pairingDialogOpen && !_friendDialogOpen && !_incomingDialogOpen) {
+ _incomingDialogOpen = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
+ if (!mounted) return;
+ await showIncomingDialog(context, asking);
+ state.dismissAsk(asking.id);
+ if (mounted) setState(() => _incomingDialogOpen = false);
+ });
+ }
final notice = state.officialNoticeKey;
if (notice != null &&
pending == null &&
diff --git a/ui/lib/pages/send_page.dart b/ui/lib/pages/send_page.dart
index 3f1357a..11650a5 100644
--- a/ui/lib/pages/send_page.dart
+++ b/ui/lib/pages/send_page.dart
@@ -13,7 +13,10 @@ import '../icons.dart';
import '../main.dart';
import '../platform.dart';
import '../theme.dart';
+import '../widgets/avatar.dart';
import '../widgets/common.dart';
+import '../widgets/friend_send_dialog.dart';
+import '../widgets/friends_dialog.dart';
import '../widgets/nearby_dialog.dart';
import '../widgets/pairing_dialog.dart';
import '../widgets/radar.dart';
@@ -64,10 +67,42 @@ class _SendPageState extends State<SendPage> with SingleTickerProviderStateMixin
CheckReceiveDirResponse? _dirCheck;
Timer? _deliveredTimer;
+ /// 附近开着「所有人」的陌生设备(2.6.0),页面打开期间订阅
+ List<Stranger> _strangers = const [];
+ StreamSubscription<List<Stranger>>? _strangerSub;
+ Timer? _strangerRetry;
+
@override
void initState() {
super.initState();
- WidgetsBinding.instance.addPostFrameCallback((_) => _checkReceiveDir());
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _checkReceiveDir();
+ _watchStrangers();
+ });
+ }
+
+ void _watchStrangers() {
+ if (!mounted) return;
+ final state = AppScope.read(context);
+ _strangerSub?.cancel();
+ if (!state.isOnline) {
+ _strangerRetry = Timer(const Duration(seconds: 3), _watchStrangers);
+ return;
+ }
+ try {
+ _strangerSub = state.watchStrangers().listen(
+ (list) {
+ if (mounted) setState(() => _strangers = list);
+ },
+ onError: (_) {
+ // 旧版后台服务没有这个接口,或者连接断了:过一会儿再试
+ _strangerRetry = Timer(const Duration(seconds: 10), _watchStrangers);
+ },
+ cancelOnError: true,
+ );
+ } catch (_) {
+ _strangerRetry = Timer(const Duration(seconds: 10), _watchStrangers);
+ }
}
@override
@@ -83,6 +118,8 @@ class _SendPageState extends State<SendPage> with SingleTickerProviderStateMixin
@override
void dispose() {
_deliveredTimer?.cancel();
+ _strangerSub?.cancel();
+ _strangerRetry?.cancel();
_pulse.dispose();
super.dispose();
}
@@ -129,7 +166,7 @@ class _SendPageState extends State<SendPage> with SingleTickerProviderStateMixin
Widget _body(BuildContext context, AppState state, Size size) {
final l = context.l10n;
final wide = !(state.config?.sendLayoutStacked ?? false);
- final radar = state.peers.isEmpty
+ final ownRadar = state.peers.isEmpty
? EmptyState(
icon: AppIcons.send,
title: l.sendNoDevicesTitle,
@@ -144,13 +181,47 @@ class _SendPageState extends State<SendPage> with SingleTickerProviderStateMixin
),
)
: _radar(context, state);
+ // 雷达下面是好友和附近开着「所有人」的设备(2.6.0)
+ final radar = Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(child: ownRadar),
+ if (state.friends.isNotEmpty)
+ _PeopleStrip(
+ title: l.friendsStrip,
+ people: [for (final f in _sortedFriends(state)) _Person.friend(f)],
+ ),
+ if (_strangers.isNotEmpty)
+ _PeopleStrip(
+ title: l.strangersStrip,
+ people: [for (final st in _strangers) _Person.stranger(st)],
+ ),
+ ],
+ );
final listWidth = (size.width * 0.45).clamp(260.0, 460.0);
final list = _TransferList(
direction: _tab, onDirection: (d) => setState(() => _tab = d), compact: wide, narrow: wide && listWidth < 340);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- PageHeader(title: l.navSend, subtitle: l.sendSubtitle),
+ PageHeader(
+ title: l.navSend,
+ subtitle: l.sendSubtitle,
+ actions: [
+ if (state.profile != null) const _ProfileChip(),
+ if (state.profile != null)
+ Tooltip(
+ message: l.friendsTitle,
+ child: TextButton.icon(
+ onPressed: () => showFriendsDialog(context),
+ icon: Icon(AppIcons.people, size: 16),
+ label: Text(state.friends.isEmpty ? l.friendsTitle : '${l.friendsTitle} ${state.friends.length}'),
+ ),
+ ),
+ if (state.profile != null)
+ IconAction(icon: AppIcons.personAdd, tooltip: l.addFriend, onTap: () => showAddFriendDialog(context)),
+ ],
+ ),
if (_dirCheck != null && !_dirCheck!.ok)
Padding(
padding: const EdgeInsets.fromLTRB(Insets.xl, 0, Insets.xl, Insets.md),
@@ -182,10 +253,19 @@ class _SendPageState extends State<SendPage> with SingleTickerProviderStateMixin
],
),
),
+ if (state.profile != null) const _ReceiveFromBar(),
],
);
}
+ List<Friend> _sortedFriends(AppState state) => [...state.friends]
+ ..sort((a, b) {
+ final ca = friendCanSend(a), cb = friendCanSend(b);
+ if (ca != cb) return ca ? -1 : 1;
+ if (a.online != b.online) return a.online ? -1 : 1;
+ return a.displayName.toLowerCase().compareTo(b.displayName.toLowerCase());
+ });
+
/// 刚送达的设备在雷达上显示 3 秒「已送达」,到时间刷新一次
void _scheduleDeliveredRefresh(AppState state) {
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
@@ -882,7 +962,7 @@ class _TransferRowState extends State<_TransferRow> {
children: [
Icon(_out ? AppIcons.arrowUp : AppIcons.arrowDown, size: 12, color: p.textFaint),
const SizedBox(width: Insets.xs),
- Icon(transferIcon(t), size: 18, color: p.textDim),
+ _thumb(context) ?? Icon(transferIcon(t), size: 18, color: p.textDim),
const SizedBox(width: Insets.md),
Expanded(
child: Column(
@@ -906,6 +986,9 @@ class _TransferRowState extends State<_TransferRow> {
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
+ // 好友、陌生设备的备注
+ if (t.note.isNotEmpty)
+ Text(l.noteLine(t.note), style: context.text.bodySmall, maxLines: 2, overflow: TextOverflow.ellipsis),
// Windows 上改过的文件名:只换了名字里不允许的字符,内容不变
if (!_out && t.status == 'done' && t.renamedFiles > 0)
Text(l.transferRenamed(t.renamedFiles.toInt()), style: context.text.bodySmall),
@@ -937,6 +1020,16 @@ class _TransferRowState extends State<_TransferRow> {
);
}
+ /// 收到的图片的缩略图(后台服务重新编码过的),没有时为 null
+ Widget? _thumb(BuildContext context) {
+ final path = t.thumbs.where((x) => x.isNotEmpty).firstOrNull;
+ if (path == null || !File(path).existsSync()) return null;
+ return ClipRRect(
+ borderRadius: BorderRadius.circular(Radii.sm),
+ child: Image.file(File(path), width: 36, height: 36, fit: BoxFit.cover, cacheWidth: 72),
+ );
+ }
+
Widget _trailing(BuildContext context) {
final l = context.l10n;
final state = AppScope.read(context);
@@ -948,6 +1041,12 @@ class _TransferRowState extends State<_TransferRow> {
if (!_out && t.status == 'done' && _present.isNotEmpty) {
buttons.add(button(AppIcons.folder, revealLabel(l), () => revealFile(_present.first)));
}
+ // 好友、陌生设备发来的,等本机用户接受:弹窗关掉了也能在这里处理
+ if (!_out && t.status == 'asking') {
+ buttons.add(button(AppIcons.xmark, l.incomingDecline, () => _run(() => state.answerIncoming(t.id, false))));
+ buttons.add(button(AppIcons.checkmark, l.incomingAccept, () => _run(() => state.answerIncoming(t.id, true))));
+ return Row(mainAxisSize: MainAxisSize.min, children: [buttons[0], const SizedBox(width: Insets.xs), buttons[1]]);
+ }
if (_out && (t.status == 'interrupted' || t.status == 'paused')) {
buttons.add(button(AppIcons.arrowClockwise, l.continueAction, () => _run(() => state.resumeTransfer(t.id))));
}
@@ -966,9 +1065,15 @@ class _TransferRowState extends State<_TransferRow> {
}
Future<void> _resend() async {
- final d = AppScope.read(context).peers.where((x) => x.id == t.deviceId).firstOrNull;
- if (d == null) return;
- await sendFilesTo(context, d, t.paths.toList());
+ final state = AppScope.read(context);
+ final d = state.peers.where((x) => x.id == t.deviceId).firstOrNull;
+ if (d != null) {
+ await sendFilesTo(context, d, t.paths.toList());
+ return;
+ }
+ // 好友:带上原来的备注再发一次
+ final f = state.friendById(t.deviceId);
+ if (f != null) await sendFilesById(context, f.id, f.displayName, t.paths.toList(), note: t.note);
}
Future<void> _run(Future<void> Function() action) async {
@@ -1019,3 +1124,343 @@ class _TransferDetails implements RecordDetails {
Future<GetImagePreviewResponse> imagePreview(String clipId, {int index = 0}) async =>
GetImagePreviewResponse(count: 0);
}
+
+
+// ─────────────────────────── 好友(2.6.0) ───────────────────────────
+
+/// 页面右上角:本机的头像和好友看到的名字。点头像换头像,点名字改名
+class _ProfileChip extends StatelessWidget {
+ const _ProfileChip();
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final name = state.profile?.displayName ?? '';
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SelfAvatarButton(size: 30),
+ const SizedBox(width: Insets.sm),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(l.displayAs, style: context.text.labelSmall),
+ InkWell(
+ onTap: () => _editName(context, name),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 140),
+ child: Text(name, style: context.text.labelLarge, maxLines: 1, overflow: TextOverflow.ellipsis),
+ ),
+ const SizedBox(width: 4),
+ Icon(AppIcons.pencil, size: 12, color: context.palette.textFaint),
+ ],
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(width: Insets.sm),
+ ],
+ );
+ }
+
+ Future<void> _editName(BuildContext context, String current) async {
+ final l = context.l10n;
+ final c = TextEditingController(text: current);
+ final next = await showDialog<String>(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text(l.editName),
+ content: SizedBox(
+ width: 360,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TextField(
+ controller: c,
+ autofocus: true,
+ maxLength: 32,
+ decoration: InputDecoration(hintText: l.nameHint),
+ onSubmitted: (v) => Navigator.pop(ctx, v),
+ ),
+ Text(l.nameDefaultHint, style: ctx.text.bodySmall),
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(onPressed: () => Navigator.pop(ctx), child: Text(l.cancel)),
+ FilledButton(onPressed: () => Navigator.pop(ctx, c.text), child: Text(l.save)),
+ ],
+ ),
+ );
+ c.dispose();
+ if (next == null || !context.mounted) return;
+ try {
+ await AppScope.read(context).setDisplayName(next.trim());
+ } catch (e) {
+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ }
+}
+
+/// 雷达下面的一排人:好友,或者附近开着「所有人」的陌生设备
+class _Person {
+ _Person.friend(Friend f) : friend = f, stranger = null;
+ _Person.stranger(Stranger s) : friend = null, stranger = s;
+
+ final Friend? friend;
+ final Stranger? stranger;
+
+ String get id => friend?.id ?? stranger!.id;
+ String get name => friend?.displayName ?? stranger!.displayName;
+}
+
+class _PeopleStrip extends StatelessWidget {
+ const _PeopleStrip({required this.title, required this.people});
+
+ final String title;
+ final List<_Person> people;
+
+ @override
+ Widget build(BuildContext context) {
+ final p = context.palette;
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.sm, Insets.xl, Insets.sm),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ children: [
+ Text(title, style: context.text.labelSmall?.copyWith(color: p.textFaint)),
+ const SizedBox(width: Insets.sm),
+ Expanded(child: Divider(color: p.separator, height: 1)),
+ ],
+ ),
+ const SizedBox(height: Insets.sm),
+ SizedBox(
+ height: 92,
+ child: ListView.separated(
+ scrollDirection: Axis.horizontal,
+ itemCount: people.length,
+ separatorBuilder: (_, _) => const SizedBox(width: Insets.sm),
+ itemBuilder: (_, i) => _PersonNode(person: people[i]),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+class _PersonNode extends StatefulWidget {
+ const _PersonNode({required this.person});
+
+ final _Person person;
+
+ @override
+ State<_PersonNode> createState() => _PersonNodeState();
+}
+
+class _PersonNodeState extends State<_PersonNode> {
+ bool _dropping = false;
+ bool _hover = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final f = widget.person.friend;
+ final st = widget.person.stranger;
+ final canSend = f != null ? friendCanSend(f) : (st?.receivesFiles ?? false);
+ final sending = state.sendingTo(widget.person.id);
+ final status = f != null ? friendStatus(l, state, f) : l.strangerNearby;
+ final highlight = canSend && (_hover || _dropping);
+ return Tooltip(
+ message: f != null ? (reachabilityText(l, f) ?? friendTitle(f)) : widget.person.name,
+ waitDuration: const Duration(milliseconds: 400),
+ child: DropTarget(
+ enable: canSend,
+ onDragEntered: (_) => setState(() => _dropping = true),
+ onDragExited: (_) => setState(() => _dropping = false),
+ onDragDone: (details) {
+ setState(() => _dropping = false);
+ final paths = droppedPaths(details);
+ // 拖到头像上直接发,不带备注
+ sendFilesById(context, widget.person.id, widget.person.name, paths);
+ },
+ child: MouseRegion(
+ cursor: SystemMouseCursors.click,
+ onEnter: (_) => setState(() => _hover = true),
+ onExit: (_) => setState(() => _hover = false),
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => f != null
+ ? openFriendSend(context, f)
+ : showFriendSendDialog(context, SendTarget.stranger(st!)),
+ child: SizedBox(
+ width: 84,
+ child: Opacity(
+ opacity: canSend || (f != null && !f.featuresKnown && f.online) ? 1 : 0.55,
+ child: Column(
+ children: [
+ AnimatedScale(
+ scale: _dropping ? 1.08 : 1,
+ duration: const Duration(milliseconds: 120),
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ DecoratedBox(
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(color: highlight ? p.accent : Colors.transparent, width: 2),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(2),
+ child: PersonAvatar(
+ deviceId: widget.person.id,
+ name: widget.person.name,
+ hash: f?.avatarHash ?? const [],
+ size: 44,
+ dashed: st != null,
+ ),
+ ),
+ ),
+ if (sending != null)
+ SizedBox.square(
+ dimension: 52,
+ child: CircularProgressIndicator(
+ strokeWidth: 2,
+ value: sending.status == 'active' && sending.totalBytes > 0
+ ? sending.doneBytes.toInt() / sending.totalBytes.toInt()
+ : null,
+ ),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: 4),
+ Text(widget.person.name,
+ style: context.text.labelMedium?.copyWith(color: p.text),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis),
+ Text(
+ sending?.status == 'asking'
+ ? l.waitingAccept
+ : sending?.status == 'active' && sending!.totalBytes > 0
+ ? '${(sending.doneBytes.toInt() * 100 / sending.totalBytes.toInt()).floor()}%'
+ : status,
+ style: context.text.labelSmall,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// 页面底部:谁可以给我发文件(均不允许 / 仅限好友 / 所有人)。「所有人」显示还剩几分钟
+class _ReceiveFromBar extends StatefulWidget {
+ const _ReceiveFromBar();
+
+ @override
+ State<_ReceiveFromBar> createState() => _ReceiveFromBarState();
+}
+
+class _ReceiveFromBarState extends State<_ReceiveFromBar> {
+ Timer? _tick;
+
+ @override
+ void initState() {
+ super.initState();
+ _tick = Timer.periodic(const Duration(seconds: 20), (_) {
+ if (mounted) setState(() {});
+ });
+ }
+
+ @override
+ void dispose() {
+ _tick?.cancel();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final v = state.receiveFrom;
+ final until = state.everyoneUntil;
+ final label = switch (v) {
+ 'off' => l.receiveFromOff,
+ 'everyone' when until != null =>
+ l.everyoneLeft('${math.max(1, (until.difference(DateTime.now()).inSeconds / 60).ceil())}'),
+ 'everyone' => l.receiveFromEveryone,
+ _ => l.receiveFromFriends,
+ };
+ return Container(
+ decoration: BoxDecoration(border: Border(top: BorderSide(color: p.border))),
+ padding: const EdgeInsets.symmetric(horizontal: Insets.xl, vertical: Insets.sm),
+ child: Row(
+ children: [
+ Text(l.receiveFromLabel, style: context.text.bodySmall),
+ PopupMenuButton<String>(
+ tooltip: '',
+ position: PopupMenuPosition.over,
+ onSelected: (next) async {
+ try {
+ await state.setReceiveFrom(next);
+ } catch (e) {
+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ },
+ itemBuilder: (_) => [
+ for (final (value, title, desc) in [
+ ('off', l.receiveFromOff, l.receiveFromOffDesc),
+ ('friends', l.receiveFromFriends, l.receiveFromFriendsDesc),
+ ('everyone', l.receiveFromEveryone, l.receiveFromEveryoneDesc),
+ ])
+ CheckedPopupMenuItem(
+ value: value,
+ checked: v == value,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(title),
+ SizedBox(
+ width: 280,
+ child: Text(desc, style: context.text.bodySmall),
+ ),
+ ],
+ ),
+ ),
+ ],
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Insets.xs, vertical: 4),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(label, style: context.text.bodySmall?.copyWith(color: p.accent)),
+ const SizedBox(width: 2),
+ Icon(AppIcons.chevronDown, size: 12, color: p.accent),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/ui/lib/widgets/avatar.dart b/ui/lib/widgets/avatar.dart
new file mode 100644
index 0000000..505a83d
--- /dev/null
+++ b/ui/lib/widgets/avatar.dart
@@ -0,0 +1,381 @@
+import 'dart:io';
+import 'dart:math' as math;
+import 'dart:typed_data';
+import 'dart:ui' as ui;
+
+import 'package:desktop_drop/desktop_drop.dart';
+import 'package:file_selector/file_selector.dart';
+import 'package:flutter/material.dart';
+
+import '../app_state.dart';
+import '../i18n.dart';
+import '../main.dart';
+import '../theme.dart';
+import 'common.dart';
+
+// 头像:好友看到的本机头像、好友的头像,见 design/friends-send.md 第 4.4 节。
+// 没有设置头像时是圆形色块加名字的第一个字,颜色由设备 ID 算出,固定不变。
+
+/// 默认头像的颜色:柔和、在亮暗两种外观下都看得清白字
+const _avatarColors = [
+ Color(0xFF5B8DEF),
+ Color(0xFF4FA88A),
+ Color(0xFFD98B4B),
+ Color(0xFFA77BD3),
+ Color(0xFFD9707A),
+ Color(0xFF4FA3B5),
+ Color(0xFF7D8590),
+];
+
+Color avatarColor(String seed) {
+ var h = 0;
+ for (final c in seed.codeUnits) {
+ h = (h * 31 + c) & 0x7fffffff;
+ }
+ return _avatarColors[h % _avatarColors.length];
+}
+
+/// 名字的第一个字;英文取首字母大写
+String avatarInitial(String name) {
+ final t = name.trim();
+ if (t.isEmpty) return '?';
+ final first = String.fromCharCodes(t.runes.take(1));
+ return first.toUpperCase();
+}
+
+/// 圆形头像。[deviceId] 为空字符串表示本机;[hash] 为空表示用默认头像。
+/// [dashed] 是「所有人」模式下的陌生设备:虚线圈、不显示图片。
+class PersonAvatar extends StatelessWidget {
+ const PersonAvatar({
+ super.key,
+ required this.deviceId,
+ required this.name,
+ this.hash = const [],
+ this.size = 40,
+ this.dashed = false,
+ });
+
+ final String deviceId;
+ final String name;
+ final List<int> hash;
+ final double size;
+ final bool dashed;
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final p = context.palette;
+ final image = dashed ? null : state.avatarOf(deviceId, hash);
+ if (dashed) {
+ return CustomPaint(
+ painter: _DashedCircle(color: p.textFaint),
+ child: SizedBox(
+ width: size,
+ height: size,
+ child: Center(
+ child: Text(
+ avatarInitial(name),
+ style: TextStyle(fontSize: size * 0.42, fontWeight: FontWeight.w600, color: p.textDim, height: 1),
+ ),
+ ),
+ ),
+ );
+ }
+ return ClipOval(
+ child: SizedBox(
+ width: size,
+ height: size,
+ child: image != null
+ ? Image.memory(image, fit: BoxFit.cover, gaplessPlayback: true)
+ : ColoredBox(
+ color: avatarColor(deviceId.isEmpty ? (state.self?.id ?? name) : deviceId),
+ child: Center(
+ child: Text(
+ avatarInitial(name),
+ style: TextStyle(
+ fontSize: size * 0.42,
+ fontWeight: FontWeight.w600,
+ color: Colors.white,
+ height: 1,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _DashedCircle extends CustomPainter {
+ _DashedCircle({required this.color});
+
+ final Color color;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final paint = Paint()
+ ..color = color
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1.2;
+ final r = size.width / 2 - 1;
+ final c = size.center(Offset.zero);
+ const n = 18;
+ for (var i = 0; i < n; i++) {
+ final a = i * 2 * math.pi / n;
+ canvas.drawArc(Rect.fromCircle(center: c, radius: r), a, math.pi / n, false, paint);
+ }
+ }
+
+ @override
+ bool shouldRepaint(_DashedCircle old) => old.color != color;
+}
+
+/// 本机的头像:点一下弹出菜单(选择图片、粘贴图片、恢复默认),也可以把图片拖上来。
+class SelfAvatarButton extends StatefulWidget {
+ const SelfAvatarButton({super.key, this.size = 40});
+
+ final double size;
+
+ @override
+ State<SelfAvatarButton> createState() => _SelfAvatarButtonState();
+}
+
+class _SelfAvatarButtonState extends State<SelfAvatarButton> {
+ bool _dragging = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final profile = state.profile;
+ final avatar = PersonAvatar(
+ deviceId: '',
+ name: profile?.displayName ?? state.self?.name ?? '',
+ hash: profile?.avatarHash ?? const [],
+ size: widget.size,
+ );
+ return DropTarget(
+ onDragEntered: (_) => setState(() => _dragging = true),
+ onDragExited: (_) => setState(() => _dragging = false),
+ onDragDone: (d) {
+ setState(() => _dragging = false);
+ final path = d.files.where((f) => f.path.isNotEmpty).firstOrNull?.path;
+ if (path != null) editAvatarFromFile(context, path);
+ },
+ child: PopupMenuButton<String>(
+ tooltip: l.avatarTitle,
+ position: PopupMenuPosition.under,
+ onSelected: (v) => switch (v) {
+ 'choose' => chooseAvatar(context),
+ 'paste' => pasteAvatar(context),
+ _ => _reset(context),
+ },
+ itemBuilder: (_) => [
+ PopupMenuItem(value: 'choose', child: Text(l.avatarChoose)),
+ PopupMenuItem(value: 'paste', child: Text(l.avatarPaste)),
+ if (profile?.hasAvatar ?? false) PopupMenuItem(value: 'reset', child: Text(l.avatarReset)),
+ ],
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(color: _dragging ? context.palette.accent : Colors.transparent, width: 2),
+ ),
+ child: avatar,
+ ),
+ ),
+ );
+ }
+
+ Future<void> _reset(BuildContext context) async {
+ try {
+ await AppScope.read(context).resetAvatar();
+ } catch (e) {
+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ }
+}
+
+Future<void> chooseAvatar(BuildContext context) async {
+ final file = await openFile(acceptedTypeGroups: [
+ const XTypeGroup(label: 'images', extensions: ['png', 'jpg', 'jpeg', 'gif', 'heic', 'heif', 'webp', 'bmp']),
+ ]);
+ if (file == null || !context.mounted) return;
+ await editAvatarFromFile(context, file.path);
+}
+
+Future<void> pasteAvatar(BuildContext context) async {
+ final l = context.l10n;
+ try {
+ final r = await AppScope.read(context).pasteFiles();
+ if (!context.mounted) return;
+ if (r.paths.isEmpty) {
+ showToast(context, l.avatarNoImage, error: true);
+ return;
+ }
+ await editAvatarFromFile(context, r.paths.first);
+ } catch (_) {
+ if (context.mounted) showToast(context, l.avatarNoImage, error: true);
+ }
+}
+
+/// 读出图片后弹出裁剪窗口;界面解不了的格式(HEIC 等)交给后台服务,取中间的正方形
+Future<void> editAvatarFromFile(BuildContext context, String path) async {
+ final l = context.l10n;
+ final state = AppScope.read(context);
+ Uint8List? bytes;
+ ui.Image? decoded;
+ try {
+ final f = File(path);
+ if (await f.length() <= 64 << 20) bytes = await f.readAsBytes();
+ if (bytes != null) decoded = await decodeImageFromList(bytes);
+ } catch (_) {
+ decoded = null;
+ }
+ if (!context.mounted) return;
+ try {
+ if (decoded == null || bytes == null) {
+ await state.setAvatar(path: path);
+ return;
+ }
+ final crop = await showDialog<Rect>(
+ context: context,
+ builder: (_) => _CropDialog(bytes: bytes!, width: decoded!.width, height: decoded.height),
+ );
+ if (crop == null) return;
+ await state.setAvatar(path: path, x: crop.left, y: crop.top, size: crop.width);
+ } catch (_) {
+ if (context.mounted) showToast(context, l.avatarBad, error: true);
+ }
+}
+
+/// 裁剪:方形取景框,可以拖动、缩放,旁边是圆形的预览。返回裁剪区域(按原图比例:left、top 是位置,width 是边长占长边的比例)
+class _CropDialog extends StatefulWidget {
+ const _CropDialog({required this.bytes, required this.width, required this.height});
+
+ final Uint8List bytes;
+ final int width, height;
+
+ @override
+ State<_CropDialog> createState() => _CropDialogState();
+}
+
+class _CropDialogState extends State<_CropDialog> {
+ static const _view = 240.0;
+ double _zoom = 1;
+ Offset _offset = Offset.zero; // 图片左上角相对取景框的位置
+
+ double get _scale => _view / math.min(widget.width, widget.height) * _zoom;
+
+ void _clamp() {
+ final w = widget.width * _scale, h = widget.height * _scale;
+ _offset = Offset(_offset.dx.clamp(_view - w, 0), _offset.dy.clamp(_view - h, 0));
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ // 一开始居中
+ final w = widget.width * _scale, h = widget.height * _scale;
+ _offset = Offset((_view - w) / 2, (_view - h) / 2);
+ }
+
+ Rect get _crop {
+ final side = _view / _scale;
+ final x = -_offset.dx / _scale, y = -_offset.dy / _scale;
+ return Rect.fromLTWH(x / widget.width, y / widget.height, side / math.max(widget.width, widget.height), 0);
+ }
+
+ Widget _image(double viewSize) {
+ final k = viewSize / _view;
+ return ClipRect(
+ child: SizedBox(
+ width: viewSize,
+ height: viewSize,
+ child: Stack(
+ children: [
+ Positioned(
+ left: _offset.dx * k,
+ top: _offset.dy * k,
+ width: widget.width * _scale * k,
+ height: widget.height * _scale * k,
+ child: Image.memory(widget.bytes, fit: BoxFit.fill, gaplessPlayback: true),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final l = context.l10n;
+ final p = context.palette;
+ return AlertDialog(
+ title: Text(l.avatarTitle),
+ content: Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ GestureDetector(
+ onPanUpdate: (d) => setState(() {
+ _offset += d.delta;
+ _clamp();
+ }),
+ child: MouseRegion(
+ cursor: SystemMouseCursors.grab,
+ child: DecoratedBox(
+ decoration: BoxDecoration(border: Border.all(color: p.border)),
+ child: _image(_view),
+ ),
+ ),
+ ),
+ const SizedBox(height: Insets.sm),
+ Text(l.avatarDragHint, style: context.text.bodySmall),
+ SizedBox(
+ width: _view,
+ child: Row(
+ children: [
+ Text(l.avatarZoom, style: context.text.bodySmall),
+ Expanded(
+ child: Slider(
+ value: _zoom,
+ min: 1,
+ max: 4,
+ onChanged: (v) => setState(() {
+ // 以取景框中心为准缩放
+ final c = const Offset(_view / 2, _view / 2);
+ final before = _scale;
+ _zoom = v;
+ _offset = c - (c - _offset) * (_scale / before);
+ _clamp();
+ }),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(width: Insets.xl),
+ Padding(
+ padding: const EdgeInsets.only(top: Insets.xl),
+ child: ClipOval(child: _image(96)),
+ ),
+ ],
+ ),
+ actions: [
+ TextButton(onPressed: () => Navigator.pop(context), child: Text(l.cancel)),
+ FilledButton(
+ onPressed: () {
+ final c = _crop;
+ Navigator.pop(context, Rect.fromLTWH(c.left, c.top, c.width, c.width));
+ },
+ child: Text(l.done),
+ ),
+ ],
+ );
+ }
+}
diff --git a/ui/lib/widgets/friend_send_dialog.dart b/ui/lib/widgets/friend_send_dialog.dart
new file mode 100644
index 0000000..f37f6c8
--- /dev/null
+++ b/ui/lib/widgets/friend_send_dialog.dart
@@ -0,0 +1,332 @@
+import 'dart:io';
+
+import 'package:desktop_drop/desktop_drop.dart';
+import 'package:file_selector/file_selector.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+import '../gen/pasteferry/v1/daemon.pb.dart';
+import '../i18n.dart';
+import '../icons.dart';
+import '../main.dart';
+import '../theme.dart';
+import 'avatar.dart';
+import 'common.dart';
+import 'friends_dialog.dart';
+import 'send_dialog.dart';
+
+// 发给好友或「所有人」模式下附近的陌生设备:先选好文件(拖入、选择、粘贴),可以写一句备注,点「发送」。
+// 对方点「接受」后才开始传。见 design/friends-send.md 第 6 节。
+
+/// 发送的对象:好友,或者附近开着「所有人」的陌生设备(ID 是 lan:实例名)
+class SendTarget {
+ const SendTarget({
+ required this.id,
+ required this.name,
+ this.deviceName = '',
+ this.avatarHash = const [],
+ this.stranger = false,
+ });
+
+ factory SendTarget.friend(Friend f) =>
+ SendTarget(id: f.id, name: f.displayName, deviceName: f.deviceName, avatarHash: f.avatarHash);
+
+ factory SendTarget.stranger(Stranger s) => SendTarget(id: s.id, name: s.displayName, stranger: true);
+
+ final String id;
+ final String name;
+ final String deviceName;
+ final List<int> avatarHash;
+ final bool stranger;
+
+ String get title => deviceName.isEmpty ? name : '$name · $deviceName';
+}
+
+Future<void> showFriendSendDialog(BuildContext context, SendTarget target, {List<String> paths = const []}) =>
+ showDialog<void>(context: context, builder: (_) => FriendSendDialog(target: target, initial: paths));
+
+class FriendSendDialog extends StatefulWidget {
+ const FriendSendDialog({super.key, required this.target, this.initial = const []});
+
+ final SendTarget target;
+ final List<String> initial;
+
+ @override
+ State<FriendSendDialog> createState() => _FriendSendDialogState();
+}
+
+class _FriendSendDialogState extends State<FriendSendDialog> {
+ final List<String> _staged = [];
+ final Map<String, int?> _sizes = {};
+ final _note = TextEditingController();
+ final _focus = FocusNode();
+ bool _dragging = false;
+ bool _sending = false;
+
+ /// 这个窗口里发出的批次
+ final List<String> _sent = [];
+
+ @override
+ void initState() {
+ super.initState();
+ _add(widget.initial);
+ }
+
+ @override
+ void dispose() {
+ _note.dispose();
+ _focus.dispose();
+ super.dispose();
+ }
+
+ void _add(Iterable<String> paths) {
+ for (final p in paths) {
+ if (p.isEmpty || _staged.contains(p)) continue;
+ _staged.add(p);
+ estimateSize([p]).then((n) {
+ if (mounted) setState(() => _sizes[p] = n);
+ });
+ }
+ if (mounted) setState(() {});
+ }
+
+ Future<void> _paste() async {
+ final l = context.l10n;
+ try {
+ final r = await AppScope.read(context).pasteFiles();
+ if (!mounted) return;
+ if (r.paths.isEmpty) {
+ showToast(context, l.sendPasteNothing, error: true);
+ return;
+ }
+ _add(r.paths);
+ } catch (_) {
+ if (mounted) showToast(context, l.sendPasteNothing, error: true);
+ }
+ }
+
+ Future<void> _send() async {
+ if (_staged.isEmpty || _sending) return;
+ setState(() => _sending = true);
+ final t = await sendFilesById(context, widget.target.id, widget.target.name, List.of(_staged), note: _note.text);
+ if (!mounted) return;
+ setState(() {
+ _sending = false;
+ if (t != null) {
+ _sent.add(t.id);
+ _staged.clear();
+ _note.clear();
+ }
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final target = widget.target;
+ final friend = target.stranger ? null : state.friendById(target.id);
+ if (!target.stranger && friend == null) {
+ // 好友在窗口开着时被删了
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) Navigator.pop(context);
+ });
+ return const SizedBox.shrink();
+ }
+ final batches = [
+ for (final id in _sent)
+ ?state.transfers(TransferDirection.TRANSFER_DIRECTION_OUTGOING).where((t) => t.id == id).firstOrNull,
+ ];
+ final route = friend != null ? friendStatus(l, state, friend) : l.strangerNearby;
+ final pasteKey = Platform.isMacOS ? '⌘V' : 'Ctrl+V';
+ final total = _staged.fold<int>(0, (n, path) => n + (_sizes[path] ?? 0));
+
+ return CallbackShortcuts(
+ bindings: {
+ SingleActivator(LogicalKeyboardKey.keyV, meta: Platform.isMacOS, control: !Platform.isMacOS): _paste,
+ },
+ child: Focus(
+ autofocus: true,
+ focusNode: _focus,
+ child: Dialog(
+ child: SizedBox(
+ width: 540,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, Insets.xl),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ children: [
+ PersonAvatar(
+ deviceId: target.id,
+ name: target.name,
+ hash: target.avatarHash,
+ size: 36,
+ dashed: target.stranger,
+ ),
+ const SizedBox(width: Insets.md),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(l.sendToTitle(target.title), style: context.text.titleMedium),
+ Text(route, style: context.text.bodySmall),
+ ],
+ ),
+ ),
+ IconAction(icon: AppIcons.xmark, tooltip: l.close, onTap: () => Navigator.pop(context)),
+ ],
+ ),
+ Padding(
+ padding: const EdgeInsets.only(right: Insets.md),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (batches.isNotEmpty) ...[
+ const SizedBox(height: Insets.lg),
+ for (final t in batches.reversed) TransferBatchRow(transfer: t),
+ ],
+ const SizedBox(height: Insets.lg),
+ if (_staged.isNotEmpty) ...[
+ for (final path in _staged) _StagedRow(
+ path: path,
+ size: _sizes[path],
+ onRemove: () => setState(() => _staged.remove(path)),
+ ),
+ const SizedBox(height: Insets.sm),
+ ],
+ DropTarget(
+ onDragEntered: (_) => setState(() => _dragging = true),
+ onDragExited: (_) => setState(() => _dragging = false),
+ onDragDone: (details) {
+ setState(() => _dragging = false);
+ _add(droppedPaths(details));
+ },
+ child: CustomPaint(
+ painter: DropZonePainter(
+ color: _dragging ? p.accent : p.textFaint,
+ dashed: !_dragging,
+ fill: _dragging ? p.accent.withValues(alpha: 0.06) : Colors.transparent,
+ ),
+ child: Padding(
+ padding: EdgeInsets.symmetric(
+ horizontal: Insets.xl,
+ vertical: _staged.isEmpty ? 32 : Insets.md,
+ ),
+ child: Column(
+ children: [
+ Text(
+ _staged.isEmpty ? l.sendDropOrPaste(pasteKey) : l.sendDropMorePaste,
+ style: context.text.titleSmall?.copyWith(color: _dragging ? p.accent : null),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: Insets.md),
+ Wrap(
+ spacing: Insets.sm,
+ alignment: WrapAlignment.center,
+ children: [
+ OutlinedButton(
+ onPressed: () async {
+ final files = await openFiles();
+ _add([for (final f in files) f.path]);
+ },
+ child: Text(l.sendChooseFiles),
+ ),
+ OutlinedButton(
+ onPressed: () async {
+ final dir = await getDirectoryPath();
+ if (dir != null) _add([dir]);
+ },
+ child: Text(l.sendChooseFolder),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: Insets.lg),
+ Text(l.noteLabel, style: context.text.labelLarge),
+ const SizedBox(height: Insets.xs),
+ TextField(
+ controller: _note,
+ enabled: _staged.isNotEmpty,
+ maxLength: 200,
+ maxLines: 1,
+ inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r'[\r\n\t]'))],
+ decoration: InputDecoration(
+ hintText: _staged.isEmpty ? l.noteHintEmpty : l.noteHint,
+ isDense: true,
+ ),
+ onSubmitted: (_) => _send(),
+ ),
+ const SizedBox(height: Insets.sm),
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ batches.isEmpty ? l.sendFriendSaved(target.name) : l.sendCloseKeeps,
+ style: context.text.bodySmall,
+ ),
+ ),
+ if (_staged.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.only(right: Insets.md),
+ child: Text(
+ l.sendItemsSummary('${_staged.length}', humanBytes(total)),
+ style: context.text.bodySmall,
+ ),
+ ),
+ FilledButton(
+ onPressed: _staged.isEmpty || _sending ? null : _send,
+ child: _sending
+ ? const SizedBox(width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 2))
+ : Text(l.sendAction),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _StagedRow extends StatelessWidget {
+ const _StagedRow({required this.path, required this.size, required this.onRemove});
+
+ final String path;
+ final int? size;
+ final VoidCallback onRemove;
+
+ @override
+ Widget build(BuildContext context) {
+ final p = context.palette;
+ final l = context.l10n;
+ final isDir = FileSystemEntity.isDirectorySync(path);
+ final name = path.split(Platform.pathSeparator).where((s) => s.isNotEmpty).lastOrNull ?? path;
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 3),
+ child: Row(
+ children: [
+ Icon(isDir ? AppIcons.folder : AppIcons.doc, size: 16, color: p.textDim),
+ const SizedBox(width: Insets.sm),
+ Expanded(child: Text(name, style: context.text.bodyMedium, maxLines: 1, overflow: TextOverflow.ellipsis)),
+ if (size != null) Text(humanBytes(size!), style: context.text.bodySmall),
+ const SizedBox(width: Insets.sm),
+ IconAction(icon: AppIcons.xmark, tooltip: l.sendRemoveItem, onTap: onRemove),
+ ],
+ ),
+ );
+ }
+}
diff --git a/ui/lib/widgets/friends_dialog.dart b/ui/lib/widgets/friends_dialog.dart
new file mode 100644
index 0000000..505824d
--- /dev/null
+++ b/ui/lib/widgets/friends_dialog.dart
@@ -0,0 +1,731 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+import '../app_state.dart';
+import '../gen/pasteferry/v1/daemon.pb.dart';
+import '../i18n.dart';
+import '../icons.dart';
+import '../main.dart';
+import '../platform.dart';
+import '../theme.dart';
+import 'avatar.dart';
+import 'common.dart';
+import 'friend_send_dialog.dart';
+import 'send_dialog.dart';
+
+// 好友:列表、加好友、确认框、和某个好友的传输记录、连不上时的提示。见 design/friends-send.md 第 5、8、9.2 节。
+
+/// 好友的名字一行:「小明 · MacBook Air」
+String friendTitle(Friend f) => f.deviceName.isEmpty ? f.displayName : '${f.displayName} · ${f.deviceName}';
+
+/// 好友此刻能不能收文件
+bool friendCanSend(Friend f) => f.online && f.receivesFiles && !f.receiveDisabled;
+
+/// 雷达和列表上好友名字下面的小字
+String friendStatus(AppLocalizations l, AppState state, Friend f) {
+ if (!f.online) {
+ return switch (f.reachability) {
+ 'self_no_service' || 'peer_no_service' => l.friendNeedService,
+ 'different_server' => l.friendCantReach,
+ _ => l.offline,
+ };
+ }
+ if (!f.featuresKnown && !f.receivesFiles) return l.reconnecting;
+ if (f.receiveDisabled) return l.sendNotReceiving;
+ if (!f.receivesFiles) return l.sendNeedsUpdate;
+ return switch (f.connection) {
+ ConnectionKind.CONNECTION_KIND_RELAY => l.relay,
+ _ => f.lanReachable ? l.sendLan : l.direct,
+ };
+}
+
+/// 好友连不上时的说明(第 9.2 节);在线、或者两边同一种服务只是没开机时为 null
+String? reachabilityText(AppLocalizations l, Friend f) => switch (f.reachability) {
+ 'self_no_service' => l.reachSelfNoService(f.displayName),
+ 'peer_no_service' => l.reachPeerNoService(f.displayName),
+ 'different_server' => l.reachDifferentServer,
+ _ => null,
+};
+
+/// 连不上的好友:说明原因,本机没开服务时给出「打开服务…」
+Future<void> showReachabilityHint(BuildContext context, Friend f) async {
+ final l = context.l10n;
+ final text = reachabilityText(l, f);
+ if (text == null) return;
+ final open = await showDialog<bool>(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ content: SizedBox(width: 380, child: Text(text)),
+ actions: [
+ TextButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.officialAcknowledge)),
+ if (f.reachability == 'self_no_service')
+ FilledButton(onPressed: () => Navigator.pop(ctx, true), child: Text(l.openService)),
+ ],
+ ),
+ );
+ if (open == true && context.mounted) AppScope.read(context).requestPage('settings');
+}
+
+// ─────────────────────────── 好友列表 ───────────────────────────
+
+Future<void> showFriendsDialog(BuildContext context) =>
+ showDialog<void>(context: context, builder: (_) => const FriendsDialog());
+
+class FriendsDialog extends StatelessWidget {
+ const FriendsDialog({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final friends = [...state.friends]
+ ..sort((a, b) {
+ if (a.online != b.online) return a.online ? -1 : 1;
+ return a.displayName.toLowerCase().compareTo(b.displayName.toLowerCase());
+ });
+ return Dialog(
+ child: SizedBox(
+ width: 480,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, Insets.lg),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ children: [
+ Expanded(child: Text(l.friendsTitle, style: context.text.titleMedium)),
+ TextButton.icon(
+ onPressed: () => showAddFriendDialog(context),
+ icon: Icon(AppIcons.plus, size: 16),
+ label: Text(l.addFriend),
+ ),
+ IconAction(icon: AppIcons.xmark, tooltip: l.close, onTap: () => Navigator.pop(context)),
+ ],
+ ),
+ const SizedBox(height: Insets.md),
+ if (friends.isEmpty)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(0, Insets.xl, Insets.md, Insets.xl),
+ child: Column(
+ children: [
+ Text(l.friendsEmpty, style: context.text.titleSmall),
+ const SizedBox(height: Insets.sm),
+ Text(l.friendsEmptyBody, style: context.text.bodySmall, textAlign: TextAlign.center),
+ ],
+ ),
+ )
+ else
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxHeight: 420),
+ child: ListView.separated(
+ shrinkWrap: true,
+ padding: const EdgeInsets.only(right: Insets.md),
+ itemCount: friends.length,
+ separatorBuilder: (_, _) => Divider(height: 1, color: p.separator),
+ itemBuilder: (_, i) => _FriendRow(friend: friends[i]),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _FriendRow extends StatelessWidget {
+ const _FriendRow({required this.friend});
+
+ final Friend friend;
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final f = friend;
+ final last = f.lastActivityUnix.toInt();
+ final sub = [
+ friendStatus(l, state, f),
+ last > 0
+ ? l.friendLastActivity(relativeTime(DateTime.fromMillisecondsSinceEpoch(last * 1000)))
+ : l.friendNoActivity,
+ if (f.autoAccept) l.friendAutoAccept,
+ ].join(' · ');
+ return GestureDetector(
+ onSecondaryTapUp: (d) => _menu(context, d.globalPosition),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: Insets.sm),
+ child: Row(
+ children: [
+ Opacity(
+ opacity: f.online ? 1 : 0.55,
+ child: PersonAvatar(deviceId: f.id, name: f.displayName, hash: f.avatarHash, size: 36),
+ ),
+ const SizedBox(width: Insets.md),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(friendTitle(f), style: context.text.labelLarge, maxLines: 1, overflow: TextOverflow.ellipsis),
+ Text(sub, style: context.text.bodySmall?.copyWith(color: p.textDim), maxLines: 1, overflow: TextOverflow.ellipsis),
+ ],
+ ),
+ ),
+ TextButton(onPressed: () => openFriendSend(context, f), child: Text(l.friendSendAction)),
+ Builder(
+ builder: (bctx) => IconAction(
+ icon: AppIcons.ellipsis,
+ tooltip: l.friendsTitle,
+ onTap: () {
+ final box = bctx.findRenderObject() as RenderBox;
+ _menu(context, box.localToGlobal(box.size.bottomLeft(Offset.zero)));
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Future<void> _menu(BuildContext context, Offset at) async {
+ final l = context.l10n;
+ final state = AppScope.read(context);
+ final overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
+ final v = await showMenu<String>(
+ context: context,
+ position: RelativeRect.fromRect(at & const Size(1, 1), Offset.zero & overlay.size),
+ items: [
+ PopupMenuItem(value: 'send', child: Text(l.friendSendAction)),
+ PopupMenuItem(value: 'history', child: Text(l.friendHistory)),
+ CheckedPopupMenuItem(value: 'auto', checked: friend.autoAccept, child: Text(l.friendAutoAccept)),
+ const PopupMenuDivider(),
+ PopupMenuItem(value: 'remove', child: Text(l.friendRemove, style: TextStyle(color: context.palette.danger))),
+ ],
+ );
+ if (!context.mounted) return;
+ try {
+ switch (v) {
+ case 'send':
+ await openFriendSend(context, friend);
+ case 'history':
+ await showFriendHistory(context, friend);
+ case 'auto':
+ await state.setFriendAutoAccept(friend.id, !friend.autoAccept);
+ case 'remove':
+ final ok = await showDialog<bool>(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text(l.friendRemoveTitle(friend.displayName)),
+ content: SizedBox(width: 380, child: Text(l.friendRemoveBody)),
+ actions: [
+ TextButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.cancel)),
+ FilledButton(
+ style: FilledButton.styleFrom(backgroundColor: context.palette.danger),
+ onPressed: () => Navigator.pop(ctx, true),
+ child: Text(l.friendRemove),
+ ),
+ ],
+ ),
+ );
+ if (ok == true) await state.removeFriend(friend.id);
+ }
+ } catch (e) {
+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ }
+}
+
+/// 点一个好友:能发就打开发送窗口;连不上时说明原因
+Future<void> openFriendSend(BuildContext context, Friend f) async {
+ final l = context.l10n;
+ if (!f.online && reachabilityText(l, f) != null) {
+ await showReachabilityHint(context, f);
+ return;
+ }
+ if (!f.online) {
+ showToast(context, l.sendErrOffline(f.displayName), error: true);
+ return;
+ }
+ if (!f.featuresKnown && !f.receivesFiles) {
+ unawaited(AppScope.read(context).reconnect(f.id).catchError((_) => ConnectionKind.CONNECTION_KIND_UNSPECIFIED));
+ }
+ await showFriendSendDialog(context, SendTarget.friend(f));
+}
+
+// ─────────────────────────── 加好友 ───────────────────────────
+
+Future<void> showAddFriendDialog(BuildContext context) =>
+ showDialog<void>(context: context, builder: (_) => const AddFriendDialog());
+
+/// 加好友:上面显示本机的好友码,下面可以输入对方的。别人兑换了本机的码,由主窗口弹出确认框
+class AddFriendDialog extends StatefulWidget {
+ const AddFriendDialog({super.key});
+
+ @override
+ State<AddFriendDialog> createState() => _AddFriendDialogState();
+}
+
+class _AddFriendDialogState extends State<AddFriendDialog> {
+ String? _code;
+ DateTime? _expires;
+ String? _error;
+ bool _loading = true;
+ bool _redeeming = false;
+ String? _redeemError;
+ final _input = TextEditingController();
+ Timer? _tick;
+
+ @override
+ void initState() {
+ super.initState();
+ _generate();
+ _tick = Timer.periodic(const Duration(seconds: 1), (_) {
+ if (mounted) setState(() {});
+ });
+ }
+
+ @override
+ void dispose() {
+ _tick?.cancel();
+ _input.dispose();
+ super.dispose();
+ }
+
+ Future<void> _generate() async {
+ setState(() {
+ _loading = true;
+ _error = null;
+ });
+ try {
+ final got = await AppScope.read(context).createFriendCode();
+ if (mounted) {
+ setState(() {
+ _code = got.code;
+ _expires = DateTime.now().add(const Duration(minutes: 5));
+ });
+ }
+ } catch (e) {
+ if (mounted) setState(() => _error = friendErrorText(context.l10n, e));
+ } finally {
+ if (mounted) setState(() => _loading = false);
+ }
+ }
+
+ Future<void> _redeem() async {
+ final code = _input.text.trim();
+ if (code.isEmpty || _redeeming) return;
+ setState(() {
+ _redeeming = true;
+ _redeemError = null;
+ });
+ try {
+ final r = await AppScope.read(context).redeemFriendCode(code);
+ if (!mounted) return;
+ Navigator.pop(context);
+ await showFriendConfirmDialog(context, r);
+ } catch (e) {
+ if (mounted) setState(() => _redeemError = friendErrorText(context.l10n, e));
+ } finally {
+ if (mounted) setState(() => _redeeming = false);
+ }
+ }
+
+ String _formatCode(String c) => c.length == 7 ? '${c[0]}-${c.substring(1)}' : c;
+
+ @override
+ Widget build(BuildContext context) {
+ final l = context.l10n;
+ final p = context.palette;
+ final left = _expires?.difference(DateTime.now());
+ final expired = left != null && left.isNegative;
+ return Dialog(
+ child: SizedBox(
+ width: 440,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, Insets.xl),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ children: [
+ Expanded(child: Text(l.addFriend, style: context.text.titleMedium)),
+ IconAction(icon: AppIcons.xmark, tooltip: l.close, onTap: () => Navigator.pop(context)),
+ ],
+ ),
+ Padding(
+ padding: const EdgeInsets.only(right: Insets.md),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SizedBox(height: Insets.lg),
+ if (_loading)
+ const Padding(
+ padding: EdgeInsets.all(Insets.xl),
+ child: Center(child: CircularProgressIndicator(strokeWidth: 2)),
+ )
+ else if (_error != null)
+ Notice(title: l.codeFailedTitle, message: _error!)
+ else ...[
+ MouseRegion(
+ cursor: SystemMouseCursors.click,
+ child: GestureDetector(
+ onTap: () async {
+ await Clipboard.setData(ClipboardData(text: _code ?? ''));
+ if (context.mounted) showToast(context, l.codeCopied);
+ },
+ child: Container(
+ padding: const EdgeInsets.symmetric(vertical: Insets.lg),
+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),
+ child: Text(
+ expired ? '—' : _formatCode(_code ?? ''),
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 30,
+ fontWeight: FontWeight.w600,
+ fontFamily: monoFamily,
+ letterSpacing: 6,
+ color: p.text,
+ ),
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: Insets.sm),
+ if (expired)
+ Center(child: TextButton(onPressed: _generate, child: Text(l.retry)))
+ else if (left != null)
+ Text(
+ l.friendCodeExpires('${left.inMinutes}:${(left.inSeconds % 60).toString().padLeft(2, '0')}'),
+ textAlign: TextAlign.center,
+ style: context.text.labelSmall,
+ ),
+ const SizedBox(height: Insets.md),
+ Text(l.friendCodeShare, style: context.text.bodySmall),
+ const SizedBox(height: Insets.xs),
+ Text(l.friendCodeWaiting, style: context.text.bodySmall?.copyWith(color: p.textFaint)),
+ ],
+ const SizedBox(height: Insets.xl),
+ Row(
+ children: [
+ Expanded(child: Divider(color: p.separator)),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Insets.md),
+ child: Text(l.friendCodeOr, style: context.text.bodySmall),
+ ),
+ Expanded(child: Divider(color: p.separator)),
+ ],
+ ),
+ const SizedBox(height: Insets.lg),
+ Text(l.friendCodeEnter, style: context.text.labelLarge),
+ const SizedBox(height: Insets.sm),
+ Row(
+ children: [
+ Expanded(
+ child: TextField(
+ controller: _input,
+ enabled: !_redeeming,
+ textCapitalization: TextCapitalization.characters,
+ decoration: const InputDecoration(hintText: 'F-XXXXXX', isDense: true),
+ onSubmitted: (_) => _redeem(),
+ ),
+ ),
+ const SizedBox(width: Insets.sm),
+ FilledButton(
+ onPressed: _redeeming ? null : _redeem,
+ child: _redeeming
+ ? const SizedBox(width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 2))
+ : Text(l.friendCodeAdd),
+ ),
+ ],
+ ),
+ if (_redeemError != null) ...[
+ const SizedBox(height: Insets.sm),
+ Text(_redeemError!, style: context.text.bodySmall?.copyWith(color: p.danger)),
+ ],
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// 加好友出错时给用户看的话
+String friendErrorText(AppLocalizations l, Object e) => switch (AppState.pairingFailure(e)) {
+ PairingFailure.friendCode => l.friendErrFriendCode,
+ PairingFailure.deviceCode => l.friendErrDeviceCode,
+ PairingFailure.peerOutdated => l.friendErrOutdated,
+ PairingFailure.alreadyPaired => l.friendErrAlreadyPaired,
+ PairingFailure.noChannel || PairingFailure.notFound => l.friendErrNoChannel,
+ PairingFailure.wrongCode => l.codeWrong,
+ PairingFailure.codeExpired => l.codeExpired,
+ _ => AppState.describeError(e),
+};
+
+/// 加好友的确认框:对方的名字和电脑,可展开的安全码。点了「添加」后等对方也添加
+Future<void> showFriendConfirmDialog(BuildContext context, FriendRequest r) => showDialog<void>(
+ context: context,
+ barrierDismissible: false,
+ builder: (_) => FriendConfirmDialog(request: r),
+);
+
+class FriendConfirmDialog extends StatefulWidget {
+ const FriendConfirmDialog({super.key, required this.request});
+
+ final FriendRequest request;
+
+ @override
+ State<FriendConfirmDialog> createState() => _FriendConfirmDialogState();
+}
+
+class _FriendConfirmDialogState extends State<FriendConfirmDialog> {
+ bool _showCode = false;
+ bool _waiting = false;
+ bool _closing = false;
+
+ Future<void> _respond(bool accept) async {
+ final state = AppScope.read(context);
+ try {
+ await state.confirmFriend(widget.request.session, accept);
+ if (!mounted) return;
+ if (!accept) {
+ Navigator.pop(context);
+ return;
+ }
+ setState(() => _waiting = true);
+ } catch (e) {
+ if (!mounted) return;
+ Navigator.pop(context);
+ showToast(context, friendErrorText(context.l10n, e), error: true);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final r = widget.request;
+ final name = r.displayName.isEmpty ? r.deviceName : r.displayName;
+ // 两边都添加了,或者对方取消了:关掉并提示
+ if (_waiting && !_closing) {
+ final added = state.friendById(r.deviceId) != null;
+ final cancelled = state.friendCancelled(r.deviceId);
+ if (added || cancelled) {
+ _closing = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted) return;
+ Navigator.pop(context);
+ showToast(context, added ? l.friendAdded(name) : l.friendPeerCancelled(name), error: !added);
+ });
+ }
+ }
+ return Dialog(
+ child: SizedBox(
+ width: 420,
+ child: Padding(
+ padding: const EdgeInsets.all(Insets.xl),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(l.addFriend, style: context.text.titleMedium),
+ const SizedBox(height: Insets.lg),
+ Row(
+ children: [
+ PersonAvatar(deviceId: r.deviceId, name: name, size: 44),
+ const SizedBox(width: Insets.md),
+ Expanded(
+ child: Text(
+ l.friendConfirmBody(r.deviceName.isEmpty ? name : '$name · ${r.deviceName}'),
+ style: context.text.bodyLarge,
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: Insets.lg),
+ InkWell(
+ onTap: () => setState(() => _showCode = !_showCode),
+ child: Row(
+ children: [
+ Icon(_showCode ? AppIcons.chevronDown : AppIcons.chevronRight, size: 14, color: p.textDim),
+ const SizedBox(width: Insets.xs),
+ Text(l.friendSafetyCode, style: context.text.bodySmall),
+ ],
+ ),
+ ),
+ if (_showCode) ...[
+ const SizedBox(height: Insets.sm),
+ Container(
+ padding: const EdgeInsets.all(Insets.md),
+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ for (final fp in ([r.fingerprint, r.selfFingerprint]..sort()))
+ Text(fp, style: TextStyle(fontFamily: monoFamily, fontSize: 18, letterSpacing: 2, color: p.text)),
+ const SizedBox(height: Insets.sm),
+ Text(l.friendSafetyHint, style: context.text.bodySmall),
+ ],
+ ),
+ ),
+ ],
+ const SizedBox(height: Insets.xl),
+ if (_waiting)
+ Row(
+ children: [
+ const SizedBox(width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 2)),
+ const SizedBox(width: Insets.sm),
+ Expanded(child: Text(l.friendWaitingPeer, style: context.text.bodySmall)),
+ TextButton(onPressed: () => Navigator.pop(context), child: Text(l.close)),
+ ],
+ )
+ else
+ Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ TextButton(onPressed: () => _respond(false), child: Text(l.cancel)),
+ const SizedBox(width: Insets.sm),
+ FilledButton(onPressed: () => _respond(true), child: Text(l.friendCodeAdd)),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+// ─────────────────────────── 传输记录 ───────────────────────────
+
+Future<void> showFriendHistory(BuildContext context, Friend f) =>
+ showDialog<void>(context: context, builder: (_) => _FriendHistoryDialog(friendId: f.id));
+
+class _FriendHistoryDialog extends StatelessWidget {
+ const _FriendHistoryDialog({required this.friendId});
+
+ final String friendId;
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final f = state.friendById(friendId);
+ if (f == null) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (context.mounted) Navigator.pop(context);
+ });
+ return const SizedBox.shrink();
+ }
+ final list = [
+ ...state.transfers(TransferDirection.TRANSFER_DIRECTION_INCOMING),
+ ...state.transfers(TransferDirection.TRANSFER_DIRECTION_OUTGOING),
+ ].where((t) => t.deviceId == friendId).toList()
+ ..sort((a, b) => b.createdAtUnix.compareTo(a.createdAtUnix));
+ return Dialog(
+ child: SizedBox(
+ width: 520,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, Insets.lg),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ children: [
+ PersonAvatar(deviceId: f.id, name: f.displayName, hash: f.avatarHash, size: 32),
+ 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)),
+ IconAction(icon: AppIcons.xmark, tooltip: l.close, onTap: () => Navigator.pop(context)),
+ ],
+ ),
+ const SizedBox(height: Insets.md),
+ if (list.isEmpty)
+ Padding(
+ padding: const EdgeInsets.all(Insets.xl),
+ child: Text(l.friendHistoryEmpty, textAlign: TextAlign.center, style: context.text.bodySmall),
+ )
+ else
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxHeight: 440),
+ child: ListView.separated(
+ shrinkWrap: true,
+ padding: const EdgeInsets.only(right: Insets.md),
+ itemCount: list.length,
+ separatorBuilder: (_, _) => Divider(height: 1, color: p.separator),
+ itemBuilder: (_, i) => _HistoryRow(transfer: list[i]),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _HistoryRow extends StatelessWidget {
+ const _HistoryRow({required this.transfer});
+
+ final Transfer transfer;
+
+ @override
+ Widget build(BuildContext context) {
+ final l = context.l10n;
+ final p = context.palette;
+ final t = transfer;
+ final out = t.direction == TransferDirection.TRANSFER_DIRECTION_OUTGOING;
+ final when = DateTime.fromMillisecondsSinceEpoch(t.createdAtUnix.toInt() * 1000);
+ final status = t.status == 'active' ? progressLabel(l, t) : transferStatusText(l, t);
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: Insets.sm),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: 18,
+ child: Text(out ? '↑' : '↓', style: context.text.labelLarge?.copyWith(color: p.textDim)),
+ ),
+ SizedBox(width: 76, child: Text(relativeTime(when), style: context.text.bodySmall)),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ [transferTitle(l, t), if (t.totalBytes > 0) humanBytes(t.totalBytes.toInt())].join(' · '),
+ style: context.text.labelLarge,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ if (t.note.isNotEmpty)
+ Text(l.noteLine(t.note), style: context.text.bodySmall, maxLines: 2, overflow: TextOverflow.ellipsis),
+ if (status.isNotEmpty)
+ Text(
+ status,
+ style: context.text.bodySmall?.copyWith(
+ color: t.status == 'failed' || t.status == 'declined' ? p.danger : p.textDim,
+ ),
+ ),
+ ],
+ ),
+ ),
+ if (!out && t.status == 'done' && t.paths.isNotEmpty)
+ TextButton(onPressed: () => revealFile(t.paths.first), child: Text(revealLabel(l))),
+ ],
+ ),
+ );
+ }
+}
diff --git a/ui/lib/widgets/incoming_dialog.dart b/ui/lib/widgets/incoming_dialog.dart
new file mode 100644
index 0000000..0935301
--- /dev/null
+++ b/ui/lib/widgets/incoming_dialog.dart
@@ -0,0 +1,158 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../app_state.dart';
+import '../gen/pasteferry/v1/daemon.pb.dart';
+import '../i18n.dart';
+import '../main.dart';
+import '../theme.dart';
+import 'avatar.dart';
+import 'common.dart';
+import 'send_dialog.dart';
+
+// 好友或「所有人」模式下的陌生设备发来文件,等用户接受。见 design/friends-send.md 第 7 节。
+// 60 秒不处理由后台服务算作拒绝;这里的倒计时只是提示。
+
+const _askSeconds = 60;
+
+Future<void> showIncomingDialog(BuildContext context, Transfer t) => showDialog<void>(
+ context: context,
+ barrierDismissible: false,
+ builder: (_) => IncomingDialog(transferId: t.id),
+);
+
+class IncomingDialog extends StatefulWidget {
+ const IncomingDialog({super.key, required this.transferId});
+
+ final String transferId;
+
+ @override
+ State<IncomingDialog> createState() => _IncomingDialogState();
+}
+
+class _IncomingDialogState extends State<IncomingDialog> {
+ bool _always = false;
+ bool _busy = false;
+ late final Timer _tick;
+
+ @override
+ void initState() {
+ super.initState();
+ _tick = Timer.periodic(const Duration(seconds: 1), (_) {
+ if (mounted) setState(() {});
+ });
+ }
+
+ @override
+ void dispose() {
+ _tick.cancel();
+ super.dispose();
+ }
+
+ Future<void> _answer(bool accept) async {
+ if (_busy) return;
+ setState(() => _busy = true);
+ try {
+ await AppScope.read(context).answerIncoming(widget.transferId, accept, always: _always && accept);
+ } catch (e) {
+ if (mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ if (mounted) Navigator.pop(context);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context);
+ final l = context.l10n;
+ final p = context.palette;
+ final t = state.transfers(TransferDirection.TRANSFER_DIRECTION_INCOMING).where((x) => x.id == widget.transferId).firstOrNull;
+ if (t == null || t.status != 'asking') {
+ // 对方取消了、超时了,或者在别处处理过了
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted && !_busy) Navigator.pop(context);
+ });
+ return const SizedBox.shrink();
+ }
+ final friend = t.peerRole == 'friend' ? state.friendById(t.deviceId) : null;
+ final stranger = t.peerRole == 'stranger';
+ final name = friend?.displayName ?? t.deviceName;
+ final left = _askSeconds - (DateTime.now().millisecondsSinceEpoch ~/ 1000 - t.createdAtUnix.toInt());
+ return Dialog(
+ child: SizedBox(
+ width: 420,
+ child: Padding(
+ padding: const EdgeInsets.all(Insets.xl),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ PersonAvatar(
+ deviceId: t.deviceId,
+ name: name,
+ hash: friend?.avatarHash ?? const [],
+ size: 44,
+ dashed: stranger,
+ ),
+ const SizedBox(width: Insets.md),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ l.incomingTitle(friend != null && friend.deviceName.isNotEmpty
+ ? '$name · ${friend.deviceName}'
+ : name),
+ style: context.text.titleMedium,
+ ),
+ if (stranger) Text(l.incomingStranger, style: context.text.bodySmall),
+ const SizedBox(height: Insets.sm),
+ Text(
+ [transferTitle(l, t), if (t.totalBytes > 0) humanBytes(t.totalBytes.toInt())].join(' · '),
+ style: context.text.bodyMedium,
+ ),
+ if (t.note.isNotEmpty) ...[
+ const SizedBox(height: Insets.xs),
+ Text(l.noteLine(t.note), style: context.text.bodyMedium?.copyWith(color: p.textDim)),
+ ],
+ ],
+ ),
+ ),
+ ],
+ ),
+ if (friend != null) ...[
+ const SizedBox(height: Insets.lg),
+ InkWell(
+ onTap: () => setState(() => _always = !_always),
+ child: Row(
+ children: [
+ Checkbox(value: _always, onChanged: (v) => setState(() => _always = v ?? false)),
+ Expanded(child: Text(l.incomingAlways, style: context.text.bodyMedium)),
+ ],
+ ),
+ ),
+ ],
+ const SizedBox(height: Insets.lg),
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ left > 0 ? l.incomingCountdown('$left') : '',
+ style: context.text.bodySmall?.copyWith(color: p.textFaint),
+ ),
+ ),
+ TextButton(onPressed: _busy ? null : () => _answer(false), child: Text(l.incomingDecline)),
+ const SizedBox(width: Insets.sm),
+ FilledButton(onPressed: _busy ? null : () => _answer(true), child: Text(l.incomingAccept)),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/ui/lib/widgets/pairing_dialog.dart b/ui/lib/widgets/pairing_dialog.dart
index ae573bb..3343229 100644
--- a/ui/lib/widgets/pairing_dialog.dart
+++ b/ui/lib/widgets/pairing_dialog.dart
@@ -300,6 +300,10 @@ class _JoinTabState extends State<_JoinTab> {
PairingFailure.codeExpired => l.codeExpired,
PairingFailure.badAddress => l.addressInvalid,
PairingFailure.noChannel => l.pairNoChannel,
+ PairingFailure.friendCode => l.friendErrFriendCode,
+ PairingFailure.deviceCode => l.friendErrDeviceCode,
+ PairingFailure.peerOutdated => l.friendErrOutdated,
+ PairingFailure.alreadyPaired => l.friendErrAlreadyPaired,
PairingFailure.other => AppState.describeError(e),
};
});
@@ -455,7 +459,14 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {
state.dismissPendingPairing(widget.peer.pairingSession);
if (!mounted) return;
Navigator.pop(context);
- showToast(context, AppState.describeError(e), error: true);
+ // 对方开放的是好友码:说清楚,别只显示一串错误
+ showToast(
+ context,
+ AppState.pairingFailure(e) == PairingFailure.friendCode
+ ? context.l10n.friendErrFriendCode
+ : AppState.describeError(e),
+ error: true,
+ );
}
}
diff --git a/ui/lib/widgets/send_dialog.dart b/ui/lib/widgets/send_dialog.dart
index a8fbeab..4a2f711 100644
--- a/ui/lib/widgets/send_dialog.dart
+++ b/ui/lib/widgets/send_dialog.dart
@@ -26,30 +26,36 @@ String _today() {
}
/// 把 [paths] 发给 [device]。要经官方服务中转时先问一次;出错时弹出提示。成功返回这一批。
-Future<Transfer?> sendFilesTo(BuildContext context, Device device, List<String> paths) async {
+Future<Transfer?> sendFilesTo(BuildContext context, Device device, List<String> paths) =>
+ sendFilesById(context, device.id, device.name, paths);
+
+/// 与 [sendFilesTo] 相同,按设备 ID 发:自己的设备、好友,或者「所有人」模式下的陌生设备(lan:实例名)。
+/// [note] 是备注(只给好友、陌生设备)
+Future<Transfer?> sendFilesById(BuildContext context, String id, String name, List<String> paths,
+ {String note = ''}) async {
final l = context.l10n;
final state = AppScope.read(context);
if (paths.isEmpty) {
showToast(context, l.sendCannotDrop, error: true);
return null;
}
- var allowRelay = _relayConsent[device.id] == _today();
+ var allowRelay = _relayConsent[id] == _today();
for (;;) {
try {
- return await state.sendFiles(device.id, paths, allowRelay: allowRelay);
+ return await state.sendFiles(id, paths, allowRelay: allowRelay, note: note);
} on GrpcError catch (e) {
if (!context.mounted) return null;
switch (AppState.sendFailure(e)) {
case SendFailure.needRelayConsent when !allowRelay:
- if (!await confirmRelay(context, device, paths)) return null;
+ if (!await confirmRelay(context, id, name, paths)) return null;
allowRelay = true;
continue;
case SendFailure.offline:
- showToast(context, l.sendErrOffline(device.name), error: true);
+ showToast(context, l.sendErrOffline(name), error: true);
case SendFailure.unsupported:
- showToast(context, l.sendNeedsUpdateTip(device.name), error: true);
+ showToast(context, l.sendNeedsUpdateTip(name), error: true);
case SendFailure.disabled:
- showToast(context, l.sendErrDisabled(device.name), error: true);
+ showToast(context, l.sendErrDisabled(name), error: true);
case SendFailure.noPaths:
showToast(context, l.sendErrMissing, error: true);
default:
@@ -64,7 +70,7 @@ Future<Transfer?> sendFilesTo(BuildContext context, Device device, List<String>
}
/// 经官方服务中转之前问一次:速度、今天剩下的额度,这些文件会不会超出。
-Future<bool> confirmRelay(BuildContext context, Device device, List<String> paths) async {
+Future<bool> confirmRelay(BuildContext context, String id, String name, List<String> paths) async {
final l = context.l10n;
final usage = AppScope.read(context).officialUsage;
final left = usage?.remainingBytes.toInt() ?? 0;
@@ -86,7 +92,7 @@ Future<bool> confirmRelay(BuildContext context, Device device, List<String> path
if (exhausted)
Text(l.relayExhausted)
else ...[
- Text(l.relayConfirmBody(device.name, humanBytes(left))),
+ Text(l.relayConfirmBody(name, humanBytes(left))),
const SizedBox(height: Insets.md),
// 经中转的加密数据比文件本身大约多 6%
if (size != null && size * 1.06 > left)
@@ -115,11 +121,13 @@ Future<bool> confirmRelay(BuildContext context, Device device, List<String> path
),
),
);
- if (ok == true && dontAsk) _relayConsent[device.id] = _today();
+ if (ok == true && dontAsk) _relayConsent[id] = _today();
return ok == true;
}
/// 估算要发的总大小,最多花 0.8 秒;大文件夹数不完时返回 null,确认框里就不比较额度。
+Future<int?> estimateSize(List<String> paths) => _estimateSize(paths);
+
Future<int?> _estimateSize(List<String> paths) async {
final watch = Stopwatch()..start();
var total = 0;
@@ -278,7 +286,7 @@ class _SendDialogState extends State<SendDialog> {
children: [
if (batches.isNotEmpty) ...[
const SizedBox(height: Insets.lg),
- for (final t in batches.reversed) _BatchRow(transfer: t),
+ for (final t in batches.reversed) TransferBatchRow(transfer: t),
],
const SizedBox(height: Insets.lg),
DropTarget(
@@ -345,8 +353,8 @@ class _SendDialogState extends State<SendDialog> {
}
/// 发送窗口里的一批:名称、大小,进度或结果。
-class _BatchRow extends StatelessWidget {
- const _BatchRow({required this.transfer});
+class TransferBatchRow extends StatelessWidget {
+ const TransferBatchRow({super.key, required this.transfer});
final Transfer transfer;
@@ -356,7 +364,8 @@ class _BatchRow extends StatelessWidget {
final p = context.palette;
final t = transfer;
final active = t.status == 'active';
- final cancellable = const {'scanning', 'queued', 'waiting', 'active', 'paused', 'interrupted'}.contains(t.status);
+ final cancellable =
+ const {'scanning', 'queued', 'waiting', 'asking', 'active', 'paused', 'interrupted'}.contains(t.status);
final status = switch (t.status) {
'done' => l.sendDelivered,
'active' => null,
@@ -427,7 +436,19 @@ class _BatchRow extends StatelessWidget {
/// 一批现在的状态说明(进行中的进度另外显示)。
String transferStatusText(AppLocalizations l, Transfer t) {
final out = t.direction == TransferDirection.TRANSFER_DIRECTION_OUTGOING;
+ // 好友、陌生设备:对方(或本机用户)拒绝、没有回应、不接收,直接说原因
+ if (t.status == 'declined') {
+ final direct = switch (t.error) {
+ 'declined' => out ? l.reasonDeclined(t.deviceName) : l.reasonYouDeclined,
+ 'timeout' => out ? l.reasonTimeout(t.deviceName) : l.reasonYouIgnored,
+ 'not_allowed' => l.reasonNotAllowed(t.deviceName),
+ 'rate_limited' => l.reasonRateLimited(t.deviceName),
+ _ => null,
+ };
+ if (direct != null) return direct;
+ }
return switch (t.status) {
+ 'asking' => out ? l.transferAskingOut(t.deviceName) : l.transferAskingIn,
'scanning' => l.transferScanning('${t.scannedFiles}'),
'queued' => l.transferQueued,
'waiting' => out ? l.transferWaitingPeer(t.deviceName) : l.transferReceiving,
diff --git a/ui/test/friends_test.dart b/ui/test/friends_test.dart
new file mode 100644
index 0000000..cfe37b0
--- /dev/null
+++ b/ui/test/friends_test.dart
@@ -0,0 +1,181 @@
+import 'package:fixnum/fixnum.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:pasteferry_ui/app_state.dart';
+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/friends_dialog.dart';
+
+/// 记下界面调了哪些好友相关的操作,不连后台服务
+class _FriendsState extends AppState {
+ final answers = <(String, bool, bool)>[];
+ final receiveFromCalls = <String>[];
+
+ @override
+ Future<void> answerIncoming(String transferId, bool accept, {bool always = false}) async {
+ answers.add((transferId, accept, always));
+ await super.answerIncomingLocally(transferId);
+ }
+
+ @override
+ Future<void> setReceiveFrom(String v) async {
+ receiveFromCalls.add(v);
+ debugSeed(
+ status: status!,
+ config: config!.deepCopy()..receiveFrom = v,
+ self: self!,
+ peers: peers,
+ friends: friends,
+ profile: profile,
+ );
+ }
+}
+
+/// 隔空传送页的雷达一直在动,pumpAndSettle 等不到停:按时间推进几帧
+Future<void> _settle(WidgetTester tester) async {
+ for (var i = 0; i < 4; i++) {
+ await tester.pump(const Duration(milliseconds: 200));
+ }
+}
+
+Int64 _now([int ago = 0]) => Int64(DateTime.now().millisecondsSinceEpoch ~/ 1000 - ago);
+
+final _xiaoming = Friend(
+ id: 'xm',
+ displayName: '小明',
+ deviceName: 'MacBook Air',
+ platform: 'darwin',
+ online: true,
+ lanReachable: true,
+ connection: ConnectionKind.CONNECTION_KIND_DIRECT,
+ featuresKnown: true,
+ receivesFiles: true,
+ addedAtUnix: _now(3600),
+);
+
+final _ajie = Friend(
+ id: 'aj',
+ displayName: '阿杰',
+ deviceName: 'Win 台式机',
+ platform: 'windows',
+ reachability: 'peer_no_service',
+ addedAtUnix: _now(7200),
+);
+
+_FriendsState _demo({List<Transfer> transfers = const []}) => _FriendsState()
+ ..debugSeed(
+ status: Status(version: '2.6.0'),
+ config: Config(language: 'zh-Hans', deviceName: 'MacBook Pro', receiveFrom: 'friends'),
+ self: Device(id: 'self', name: 'MacBook Pro', platform: 'darwin'),
+ peers: [
+ Device(id: 'air', name: 'iMac', platform: 'darwin', online: true, lanReachable: true,
+ connection: ConnectionKind.CONNECTION_KIND_DIRECT, receivesFiles: true, featuresKnown: true),
+ ],
+ friends: [_xiaoming, _ajie],
+ profile: Profile(displayName: '光光', deviceId: 'self'),
+ transfers: transfers,
+ );
+
+void main() {
+ setUp(() {
+ final view = TestWidgetsFlutterBinding.instance.platformDispatcher.views.first;
+ view.physicalSize = const Size(1180, 760);
+ view.devicePixelRatio = 1;
+ });
+ tearDown(() => TestWidgetsFlutterBinding.instance.platformDispatcher.views.first.reset());
+
+ Future<AppLocalizations> openSend(WidgetTester tester, AppState state) async {
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ await tester.pump();
+ final l = AppLocalizations.of(tester.element(find.byType(Shell)));
+ await tester.tap(find.text(l.navSend).first);
+ await tester.pump();
+ return l;
+ }
+
+ testWidgets('隔空传送页:本机名片、好友、谁可以给我发文件', (tester) async {
+ final state = _demo();
+ final l = await openSend(tester, state);
+ expect(find.text('光光'), findsOneWidget);
+ expect(find.text('${l.friendsTitle} 2'), findsOneWidget);
+ // 雷达下面一排好友:能发的写连接方式,连不上的写原因
+ expect(find.text('小明'), findsOneWidget);
+ expect(find.text('阿杰'), findsOneWidget);
+ expect(find.text(l.friendNeedService), findsOneWidget);
+ expect(find.text(l.receiveFromFriends), findsOneWidget);
+
+ await tester.tap(find.text(l.receiveFromFriends));
+ await _settle(tester);
+ await tester.tap(find.widgetWithText(CheckedPopupMenuItem<String>, l.receiveFromEveryone));
+ await _settle(tester);
+ expect(state.receiveFromCalls, ['everyone']);
+ });
+
+ testWidgets('点连不上的好友:说明原因,不打开发送窗口', (tester) async {
+ final state = _demo();
+ final l = await openSend(tester, state);
+ await tester.tap(find.text('阿杰'));
+ await _settle(tester);
+ expect(find.text(l.reachPeerNoService('阿杰')), findsOneWidget);
+ expect(find.byType(FriendSendDialog), findsNothing);
+ });
+
+ testWidgets('发给好友:选好文件之前不能写备注、不能发', (tester) async {
+ final state = _demo();
+ final l = await openSend(tester, state);
+ await tester.tap(find.text('小明'));
+ await _settle(tester);
+ expect(find.byType(FriendSendDialog), findsOneWidget);
+ expect(find.text(l.sendToTitle('小明 · MacBook Air')), findsOneWidget);
+ final note = tester.widget<TextField>(find.byType(TextField));
+ expect(note.enabled, isFalse);
+ final send = tester.widget<FilledButton>(find.widgetWithText(FilledButton, l.sendAction));
+ expect(send.onPressed, isNull);
+ });
+
+ testWidgets('好友发来文件:弹出接收框,显示备注,勾选以后自动接收', (tester) async {
+ final asking = Transfer(
+ id: 't1',
+ direction: TransferDirection.TRANSFER_DIRECTION_INCOMING,
+ deviceId: 'xm',
+ deviceName: '小明 · MacBook Air',
+ status: 'asking',
+ peerRole: 'friend',
+ note: '合同第 3 页要签字',
+ items: [ClipItem(name: '合同扫描件.pdf', size: Int64(18 << 20))],
+ totalBytes: Int64(18 << 20),
+ createdAtUnix: _now(2),
+ );
+ final state = _demo(transfers: [asking]);
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ await tester.pump();
+ await tester.pump();
+ final l = AppLocalizations.of(tester.element(find.byType(Shell)));
+ expect(find.text(l.incomingTitle('小明 · MacBook Air')), findsOneWidget);
+ expect(find.text(l.noteLine('合同第 3 页要签字')), findsOneWidget);
+ await tester.tap(find.text(l.incomingAlways));
+ await tester.pump();
+ await tester.tap(find.text(l.incomingAccept));
+ await _settle(tester);
+ expect(state.answers, [('t1', true, true)]);
+ expect(find.text(l.incomingTitle('小明 · MacBook Air')), findsNothing);
+ });
+
+ 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);
+ expect(find.text('小明 · MacBook Air'), findsOneWidget);
+ expect(find.text('阿杰 · Win 台式机'), findsOneWidget);
+ expect(friendStatus(l, state, _xiaoming), l.sendLan);
+ expect(friendStatus(l, state, _ajie), l.friendNeedService);
+ expect(friendCanSend(_xiaoming), isTrue);
+ expect(friendCanSend(_ajie), isFalse);
+ });
+}
diff --git a/ui/tool/screenshots/screenshots_test.dart b/ui/tool/screenshots/screenshots_test.dart
index ae751dc..9c2717a 100644
--- a/ui/tool/screenshots/screenshots_test.dart
+++ b/ui/tool/screenshots/screenshots_test.dart
@@ -18,6 +18,8 @@ import 'package:pasteferry_ui/picker/picker_host.dart';
import 'package:pasteferry_ui/picker/picker_state.dart';
import 'package:pasteferry_ui/picker/picker_view.dart';
import 'package:pasteferry_ui/theme.dart';
+import 'package:pasteferry_ui/widgets/friend_send_dialog.dart';
+import 'package:pasteferry_ui/widgets/friends_dialog.dart';
import 'package:pasteferry_ui/widgets/nearby_dialog.dart';
import 'package:pasteferry_ui/widgets/pairing_dialog.dart';
import 'package:pasteferry_ui/widgets/send_dialog.dart';
@@ -48,6 +50,13 @@ class _DemoState extends AppState {
@override
Future<PairingCode> createPairingCode() async => (code: 'K7MP2X', addresses: ['192.168.1.20']);
+ @override
+ Future<PairingCode> createFriendCode() async => (code: 'F7K3QXM', addresses: ['192.168.1.20']);
+
+ // 「所有人」模式下附近的陌生设备:截图里不放
+ @override
+ Stream<List<Stranger>> watchStrangers() => StreamController<List<Stranger>>().stream;
+
@override
Future<ListHistoryResponse> requestSearch(String query) async =>
ListHistoryResponse(records: records.where((r) => matchesSearch(r, query)), searched: true);
@@ -316,6 +325,55 @@ AppState _sendDemo() {
return base;
}
+/// 好友(2.6.0)的演示数据:本机的名字,三个好友(局域网、需要对方打开服务、离线),
+/// 与好友之间的传输带备注。人名都是演示用的,不对应真实的人
+AppState _friendsDemo() {
+ final base = _sendDemo();
+ final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
+ Int64 ago(int s) => Int64(now - s);
+ const incoming = TransferDirection.TRANSFER_DIRECTION_INCOMING;
+ const outgoing = TransferDirection.TRANSFER_DIRECTION_OUTGOING;
+ final xm = _t('小明', 'Alex', '佐藤', tw: '小明', hk: '小明');
+ final aj = _t('阿杰', 'Jordan', '田中', tw: '阿傑', hk: '阿傑');
+ final wj = _t('王姐', 'Sam', '鈴木', tw: '王姐', hk: '王姐');
+ final contract = _t('合同扫描件.pdf', 'signed-contract.pdf', '契約書_署名済み.pdf', tw: '合約掃描檔.pdf', hk: '合約掃描本.pdf');
+ final note = _t('合同第 3 页要签字', 'Please sign page 3', '3 ページ目に署名してください', tw: '合約第 3 頁要簽名', hk: '合約第 3 頁要簽名');
+ final quote = _t('报价单.png', 'quote.png', '見積書.png', tw: '報價單.png', hk: '報價單.png');
+ final quoteNote = _t('看下这个价格', 'Does this price work?', 'この価格で大丈夫?', tw: '看一下這個價格', hk: '看看這個價錢');
+ final winDesk = _t('Win 台式机', 'Windows PC', 'Windows PC', tw: 'Win 桌機', hk: 'Win 桌面電腦');
+ final friends = [
+ Friend(id: 'f-xm', displayName: xm, deviceName: 'MacBook Air', platform: 'darwin', online: true, lanReachable: true,
+ connection: ConnectionKind.CONNECTION_KIND_DIRECT, featuresKnown: true, receivesFiles: true,
+ addedAtUnix: ago(86400 * 3), lastActivityUnix: ago(300)),
+ Friend(id: 'f-aj', displayName: aj, deviceName: winDesk, platform: 'windows', reachability: 'peer_no_service',
+ featuresKnown: true, receivesFiles: true, addedAtUnix: ago(86400 * 9), lastActivityUnix: ago(86400)),
+ Friend(id: 'f-wj', displayName: wj, deviceName: 'MacBook Pro', platform: 'darwin', featuresKnown: true,
+ receivesFiles: true, addedAtUnix: ago(86400 * 20), lastActivityUnix: ago(86400 * 6)),
+ ];
+ final transfers = [
+ Transfer(id: 'fr1', direction: incoming, deviceId: 'f-xm', deviceName: '$xm · MacBook Air', status: 'done',
+ peerRole: 'friend', note: quoteNote, items: [ClipItem(name: quote, size: Int64(640 * 1024))],
+ paths: ['/q'], present: [true], totalBytes: Int64(640 * 1024), fileCount: Int64(1),
+ createdAtUnix: ago(320), finishedAtUnix: ago(300)),
+ Transfer(id: 'fs1', direction: outgoing, deviceId: 'f-xm', deviceName: '$xm · MacBook Air', status: 'done',
+ peerRole: 'friend', note: note, items: [ClipItem(name: contract), ClipItem(name: 'notes.txt')],
+ paths: ['/c'], totalBytes: Int64((18.4 * _mb).round()), fileCount: Int64(2),
+ createdAtUnix: ago(120), finishedAtUnix: ago(110)),
+ ...base.transfers(incoming),
+ ...base.transfers(outgoing),
+ ]..sort((a, b) => b.createdAtUnix.compareTo(a.createdAtUnix));
+ base.debugSeed(
+ status: base.status!,
+ config: base.config!..receiveFrom = 'friends',
+ self: base.self!,
+ peers: base.peers,
+ friends: friends,
+ profile: Profile(displayName: _t('光光', 'Robin', '高橋', tw: '光光', hk: '光光'), deviceId: 'self'),
+ transfers: transfers,
+ );
+ return base;
+}
+
final _boundary = GlobalKey();
Future<void> _shoot(
@@ -482,6 +540,93 @@ void main() {
});
});
+ testWidgets('friends-send-dark', (tester) async {
+ await _shoot(tester, 'friends-send-dark', state: _friendsDemo(), section: Section.send, settle: false,
+ brightness: Brightness.dark, window: const Size(1180, 720));
+ });
+
+ testWidgets('friends-list-dark', (tester) async {
+ await _shoot(tester, 'friends-list-dark', state: _friendsDemo(), section: Section.send, settle: false,
+ brightness: Brightness.dark, window: const Size(1180, 720), arrange: () async {
+ showFriendsDialog(tester.element(find.byType(Shell)));
+ 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 {
+ showAddFriendDialog(tester.element(find.byType(Shell)));
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 400));
+ });
+ });
+
+ testWidgets('friend-send-dialog-dark', (tester) async {
+ final dir = Directory.systemTemp.createTempSync('pf-shot');
+ final files = <String>[];
+ for (final (name, size) in [
+ (_t('合同扫描件.pdf', 'signed-contract.pdf', '契約書_署名済み.pdf', tw: '合約掃描檔.pdf', hk: '合約掃描本.pdf'), 2400000),
+ (_t('附件', 'attachments', '添付ファイル', tw: '附件', hk: '附件'), 0),
+ ]) {
+ final path = '${dir.path}/$name';
+ if (size == 0) {
+ Directory(path).createSync();
+ File('$path/a.bin').writeAsBytesSync(List.filled(1500000, 0));
+ } else {
+ File(path).writeAsBytesSync(List.filled(size, 0));
+ }
+ files.add(path);
+ }
+ final state = _friendsDemo();
+ await _shoot(tester, 'friend-send-dialog-dark', state: state, section: Section.send, settle: false,
+ brightness: Brightness.dark, window: const Size(1180, 720), arrange: () async {
+ final f = state.friends.first;
+ showDialog<void>(
+ context: tester.element(find.byType(Shell)),
+ builder: (_) => FriendSendDialog(target: SendTarget.friend(f), initial: files),
+ );
+ await tester.pump();
+ await tester.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 200)));
+ await tester.pump(const Duration(milliseconds: 400));
+ await tester.enterText(find.byType(TextField),
+ _t('合同第 3 页要签字', 'Please sign page 3', '3 ページ目に署名してください', tw: '合約第 3 頁要簽名', hk: '合約第 3 頁要簽名'));
+ await tester.pump();
+ });
+ });
+
+ testWidgets('incoming-dark', (tester) async {
+ final state = _friendsDemo();
+ final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
+ final xm = state.friends.first;
+ state.debugSeed(
+ status: state.status!,
+ config: state.config!,
+ self: state.self!,
+ peers: state.peers,
+ friends: state.friends,
+ profile: state.profile,
+ transfers: [
+ Transfer(id: 'ask', direction: TransferDirection.TRANSFER_DIRECTION_INCOMING, deviceId: xm.id,
+ deviceName: '${xm.displayName} · ${xm.deviceName}', status: 'asking', peerRole: 'friend',
+ note: _t('合同第 3 页要签字', 'Please sign page 3', '3 ページ目に署名してください', tw: '合約第 3 頁要簽名', hk: '合約第 3 頁要簽名'),
+ items: [
+ ClipItem(name: _t('合同扫描件.pdf', 'signed-contract.pdf', '契約書_署名済み.pdf', tw: '合約掃描檔.pdf', hk: '合約掃描本.pdf')),
+ ClipItem(name: 'notes.txt'),
+ ClipItem(name: 'IMG_2042.HEIC'),
+ ],
+ totalBytes: Int64((18.4 * _mb).round()), createdAtUnix: Int64(now - 3)),
+ ...state.transfers(TransferDirection.TRANSFER_DIRECTION_INCOMING),
+ ],
+ );
+ await _shoot(tester, 'incoming-dark', state: state, section: Section.send, settle: false,
+ brightness: Brightness.dark, window: const Size(1180, 720), arrange: () async {
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 400));
+ });
+ });
+
testWidgets('devices', (tester) async {
await _shoot(tester, 'devices', state: _demo(), section: Section.devices);
});