@@ -22,13 +22,15 @@ import 'package:twitee/Screens/Navigation/friendship_screen.dart';
22
22
import 'package:twitee/Utils/app_provider.dart' ;
23
23
import 'package:twitee/Utils/asset_util.dart' ;
24
24
import 'package:twitee/Utils/enums.dart' ;
25
+ import 'package:twitee/Utils/hive_util.dart' ;
25
26
import 'package:twitee/Utils/itoast.dart' ;
26
27
import 'package:twitee/Utils/tweet_util.dart' ;
27
28
import 'package:twitee/Widgets/BottomSheet/bottom_sheet_builder.dart' ;
28
29
import 'package:twitee/Widgets/Item/item_builder.dart' ;
29
30
30
31
import '../../Api/user_api.dart' ;
31
32
import '../../Models/tab_item_data.dart' ;
33
+ import '../../Models/user_info.dart' ;
32
34
import '../../Utils/responsive_util.dart' ;
33
35
import '../../Utils/uri_util.dart' ;
34
36
import '../../Utils/utils.dart' ;
@@ -71,6 +73,10 @@ class _UserDetailScreenState extends State<UserDetailScreen>
71
73
72
74
ScrollController ? primaryController;
73
75
76
+ UserInfo ? myInfo;
77
+
78
+ bool get isMyself => myInfo? .idStr == user! .restId! ;
79
+
74
80
initTab () {
75
81
primaryController = PrimaryScrollController .of (context);
76
82
tabDataList.addAll ([
@@ -107,6 +113,7 @@ class _UserDetailScreenState extends State<UserDetailScreen>
107
113
}
108
114
109
115
fetchUserInfo () async {
116
+ myInfo = HiveUtil .getUserInfo ();
110
117
_initPhase = InitPhase .connecting;
111
118
var res = await UserApi .getUserInfo (widget.screenName);
112
119
if (res.success) {
@@ -256,90 +263,93 @@ class _UserDetailScreenState extends State<UserDetailScreen>
256
263
String url = userLegacy? .url ?? "https://twitter.com/$screenName " ;
257
264
return GenericContextMenu (
258
265
buttonConfigs: [
259
- ContextMenuButtonConfig (
260
- "${userLegacy ?.blocking ?? false ? "取消屏蔽" : "屏蔽" } @$screenName " ,
261
- icon: Container (
262
- margin: const EdgeInsets .only (right: 8 ),
263
- child: Icon (
264
- userLegacy? .blocking ?? false
265
- ? Icons .favorite_border_rounded
266
- : Icons .heart_broken_outlined,
267
- size: 20 )),
268
- onPressed: () async {
269
- if (userLegacy? .blocking ?? false ) {
270
- var res = await UserApi .unblock (userId: user! .restId! );
271
- if (res.success) {
272
- userLegacy? .blocking = false ;
273
- if (mounted) setState (() {});
274
- IToast .showTop ("已取消屏蔽@$screenName " );
266
+ if (! isMyself)
267
+ ContextMenuButtonConfig (
268
+ "${userLegacy ?.blocking ?? false ? "取消屏蔽" : "屏蔽" } @$screenName " ,
269
+ icon: Container (
270
+ margin: const EdgeInsets .only (right: 8 ),
271
+ child: Icon (
272
+ userLegacy? .blocking ?? false
273
+ ? Icons .favorite_border_rounded
274
+ : Icons .heart_broken_outlined,
275
+ size: 20 )),
276
+ onPressed: () async {
277
+ if (userLegacy? .blocking ?? false ) {
278
+ var res = await UserApi .unblock (userId: user! .restId! );
279
+ if (res.success) {
280
+ userLegacy? .blocking = false ;
281
+ if (mounted) setState (() {});
282
+ IToast .showTop ("已取消屏蔽@$screenName " );
283
+ } else {
284
+ IToast .showTop ("取消屏蔽@$screenName 失败" );
285
+ }
275
286
} else {
276
- IToast .showTop ("取消屏蔽@$screenName 失败" );
287
+ DialogBuilder .showConfirmDialog (
288
+ context,
289
+ title: "屏蔽 @$screenName ?" ,
290
+ message: "他们将无法关注你或查看你的帖子,而你也将无法看到 @$screenName 的帖子或通知。" ,
291
+ onTapConfirm: () async {
292
+ var res = await UserApi .block (userId: user! .restId! );
293
+ if (res.success) {
294
+ userLegacy? .blocking = true ;
295
+ if (mounted) setState (() {});
296
+ IToast .showTop ("已屏蔽@$screenName " );
297
+ } else {
298
+ IToast .showTop ("屏蔽@$screenName 失败" );
299
+ }
300
+ },
301
+ );
277
302
}
278
- } else {
279
- DialogBuilder .showConfirmDialog (
280
- context,
281
- title: "屏蔽 @$screenName ?" ,
282
- message: "他们将无法关注你或查看你的帖子,而你也将无法看到 @$screenName 的帖子或通知。" ,
283
- onTapConfirm: () async {
284
- var res = await UserApi .block (userId: user! .restId! );
285
- if (res.success) {
286
- userLegacy? .blocking = true ;
287
- if (mounted) setState (() {});
288
- IToast .showTop ("已屏蔽@$screenName " );
289
- } else {
290
- IToast .showTop ("屏蔽@$screenName 失败" );
291
- }
292
- },
293
- );
294
- }
295
- },
296
- ),
297
- ContextMenuButtonConfig (
298
- "${userLegacy ?.muting ?? false ? "取消隐藏" : "隐藏" } @$screenName " ,
299
- icon: Container (
300
- margin: const EdgeInsets .only (right: 8 ),
301
- child: Icon (
302
- userLegacy? .muting ?? false
303
- ? Icons .visibility_outlined
304
- : Icons .visibility_off_outlined,
305
- size: 20 )),
306
- onPressed: () async {
307
- if (userLegacy? .muting ?? false ) {
308
- var res = await UserApi .unmute (userId: user! .restId! );
309
- if (res.success) {
310
- userLegacy? .muting = false ;
311
- if (mounted) setState (() {});
312
- IToast .showTop ("已取消隐藏@$screenName " );
303
+ },
304
+ ),
305
+ if (! isMyself)
306
+ ContextMenuButtonConfig (
307
+ "${userLegacy ?.muting ?? false ? "取消隐藏" : "隐藏" } @$screenName " ,
308
+ icon: Container (
309
+ margin: const EdgeInsets .only (right: 8 ),
310
+ child: Icon (
311
+ userLegacy? .muting ?? false
312
+ ? Icons .visibility_outlined
313
+ : Icons .visibility_off_outlined,
314
+ size: 20 )),
315
+ onPressed: () async {
316
+ if (userLegacy? .muting ?? false ) {
317
+ var res = await UserApi .unmute (userId: user! .restId! );
318
+ if (res.success) {
319
+ userLegacy? .muting = false ;
320
+ if (mounted) setState (() {});
321
+ IToast .showTop ("已取消隐藏@$screenName " );
322
+ } else {
323
+ IToast .showTop ("取消隐藏@$screenName 失败" );
324
+ }
313
325
} else {
314
- IToast .showTop ("取消隐藏@$screenName 失败" );
326
+ DialogBuilder .showConfirmDialog (
327
+ context,
328
+ title: "隐藏 @$screenName ?" ,
329
+ message: "你将无法在为你推荐或已关注中看到 @$screenName 的帖子或通知。" ,
330
+ onTapConfirm: () async {
331
+ var res = await UserApi .mute (userId: user! .restId! );
332
+ if (res.success) {
333
+ userLegacy? .muting = true ;
334
+ if (mounted) setState (() {});
335
+ IToast .showTop ("已隐藏@$screenName " );
336
+ } else {
337
+ IToast .showTop ("隐藏@$screenName 失败" );
338
+ }
339
+ },
340
+ );
315
341
}
316
- } else {
317
- DialogBuilder .showConfirmDialog (
318
- context,
319
- title: "隐藏 @$screenName ?" ,
320
- message: "你将无法在为你推荐或已关注中看到 @$screenName 的帖子或通知。" ,
321
- onTapConfirm: () async {
322
- var res = await UserApi .mute (userId: user! .restId! );
323
- if (res.success) {
324
- userLegacy? .muting = true ;
325
- if (mounted) setState (() {});
326
- IToast .showTop ("已隐藏@$screenName " );
327
- } else {
328
- IToast .showTop ("隐藏@$screenName 失败" );
329
- }
330
- },
331
- );
332
- }
333
- },
334
- ),
335
- ContextMenuButtonConfig (
336
- "从列表添加或移除 @$screenName " ,
337
- icon: Container (
338
- margin: const EdgeInsets .only (right: 8 ),
339
- child: const Icon (Icons .playlist_add_rounded, size: 20 )),
340
- onPressed: () async {},
341
- ),
342
- ContextMenuButtonConfig .divider (),
342
+ },
343
+ ),
344
+ if (! isMyself)
345
+ ContextMenuButtonConfig (
346
+ "从列表添加或移除 @$screenName " ,
347
+ icon: Container (
348
+ margin: const EdgeInsets .only (right: 8 ),
349
+ child: const Icon (Icons .playlist_add_rounded, size: 20 )),
350
+ onPressed: () async {},
351
+ ),
352
+ if (! isMyself) ContextMenuButtonConfig .divider (),
343
353
ContextMenuButtonConfig (
344
354
"分享用户" ,
345
355
icon: Container (
@@ -451,53 +461,52 @@ class _UserDetailScreenState extends State<UserDetailScreen>
451
461
.bodySmall
452
462
? .apply (fontSizeDelta: 2 ),
453
463
),
454
- if (ResponsiveUtil .isLandscape ()) const SizedBox (height: 3 ),
455
- if (ResponsiveUtil .isLandscape ()) metaRow,
456
464
],
457
465
),
458
466
),
459
467
const SizedBox (width: 10 ),
460
- ItemBuilder .buildRoundButton (
461
- context,
462
- text: userLegacy! .isFriend
463
- ? "互相关注"
464
- : userLegacy! .following ?? false
465
- ? "正在关注"
466
- : "关注" ,
467
- background: userLegacy! .isFriend
468
- ? Colors .green
469
- : userLegacy! .following ?? false
470
- ? null
471
- : Theme .of (context).primaryColor,
472
- padding:
473
- const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 ),
474
- onTap: () async {
475
- if (userLegacy! .following ?? false ) {
476
- DialogBuilder .showConfirmDialog (context,
477
- title: "取消关注 @$screenName ?" ,
478
- message: "你将无法在已关注中看到 @$screenName 的帖子或通知。" ,
479
- onTapConfirm: () async {
480
- var res = await UserApi .unfollow (userId: screenName);
468
+ if (! isMyself)
469
+ ItemBuilder .buildRoundButton (
470
+ context,
471
+ text: userLegacy! .isFriend
472
+ ? "互相关注"
473
+ : userLegacy! .following ?? false
474
+ ? "正在关注"
475
+ : "关注" ,
476
+ background: userLegacy! .isFriend
477
+ ? Colors .green
478
+ : userLegacy! .following ?? false
479
+ ? null
480
+ : Theme .of (context).primaryColor,
481
+ padding:
482
+ const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 ),
483
+ onTap: () async {
484
+ if (userLegacy! .following ?? false ) {
485
+ DialogBuilder .showConfirmDialog (context,
486
+ title: "取消关注 @$screenName ?" ,
487
+ message: "你将无法在已关注中看到 @$screenName 的帖子或通知。" ,
488
+ onTapConfirm: () async {
489
+ var res = await UserApi .unfollow (userId: user! .restId! );
490
+ if (res.success) {
491
+ userLegacy! .following = false ;
492
+ if (mounted) setState (() {});
493
+ IToast .showTop ("已取消关注@$screenName " );
494
+ } else {
495
+ IToast .showTop ("取消关注@$screenName 失败" );
496
+ }
497
+ });
498
+ } else {
499
+ var res = await UserApi .follow (userId: user! .restId! );
481
500
if (res.success) {
482
- userLegacy! .following = false ;
501
+ userLegacy! .following = true ;
483
502
if (mounted) setState (() {});
484
- IToast .showTop ("已取消关注 @$screenName " );
503
+ IToast .showTop ("已关注 @$screenName " );
485
504
} else {
486
- IToast .showTop ("取消关注 @$screenName 失败" );
505
+ IToast .showTop ("关注 @$screenName 失败" );
487
506
}
488
- });
489
- } else {
490
- var res = await UserApi .follow (userId: screenName);
491
- if (res.success) {
492
- userLegacy! .following = true ;
493
- if (mounted) setState (() {});
494
- IToast .showTop ("已关注@$screenName " );
495
- } else {
496
- IToast .showTop ("关注@$screenName 失败" );
497
507
}
498
- }
499
- },
500
- ),
508
+ },
509
+ ),
501
510
const SizedBox (width: 10 ),
502
511
ItemBuilder .buildRoundButton (
503
512
context,
@@ -510,8 +519,8 @@ class _UserDetailScreenState extends State<UserDetailScreen>
510
519
),
511
520
],
512
521
),
513
- if ( ResponsiveUtil . isMobile ()) const SizedBox (height: 10 ),
514
- if ( ResponsiveUtil . isMobile ()) metaRow,
522
+ const SizedBox (height: 10 ),
523
+ metaRow,
515
524
const SizedBox (height: 10 ),
516
525
Wrap (
517
526
spacing: 20 ,
@@ -549,7 +558,7 @@ class _UserDetailScreenState extends State<UserDetailScreen>
549
558
),
550
559
],
551
560
),
552
- const SizedBox (height: 10 ),
561
+ if (friendList.isNotEmpty) const SizedBox (height: 10 ),
553
562
if (friendList.isNotEmpty)
554
563
_buildCountItem (
555
564
title: "关注了此账号" ,
0 commit comments