Skip to content

Commit 51b9ef8

Browse files
Fix video
1 parent a38c866 commit 51b9ef8

File tree

394 files changed

+7962
-4951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

394 files changed

+7962
-4951
lines changed

lib/Openapi/models/cover_cta.g.dart

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Screens/Detail/tweet_detail_screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class TweetDetailScreenState extends State<TweetDetailScreen>
110110
if (tweetDetailResponse == null || tweetEntry == null) {
111111
_initPhase = InitPhase.failed;
112112
}
113-
setState(() {});
113+
if (mounted) setState(() {});
114114
}
115115

116116
_processEntries(List<TimelineAddEntry> entries) {

lib/Screens/Detail/user_detail_screen.dart

+130-121
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ import 'package:twitee/Screens/Navigation/friendship_screen.dart';
2222
import 'package:twitee/Utils/app_provider.dart';
2323
import 'package:twitee/Utils/asset_util.dart';
2424
import 'package:twitee/Utils/enums.dart';
25+
import 'package:twitee/Utils/hive_util.dart';
2526
import 'package:twitee/Utils/itoast.dart';
2627
import 'package:twitee/Utils/tweet_util.dart';
2728
import 'package:twitee/Widgets/BottomSheet/bottom_sheet_builder.dart';
2829
import 'package:twitee/Widgets/Item/item_builder.dart';
2930

3031
import '../../Api/user_api.dart';
3132
import '../../Models/tab_item_data.dart';
33+
import '../../Models/user_info.dart';
3234
import '../../Utils/responsive_util.dart';
3335
import '../../Utils/uri_util.dart';
3436
import '../../Utils/utils.dart';
@@ -71,6 +73,10 @@ class _UserDetailScreenState extends State<UserDetailScreen>
7173

7274
ScrollController? primaryController;
7375

76+
UserInfo? myInfo;
77+
78+
bool get isMyself => myInfo?.idStr == user!.restId!;
79+
7480
initTab() {
7581
primaryController = PrimaryScrollController.of(context);
7682
tabDataList.addAll([
@@ -107,6 +113,7 @@ class _UserDetailScreenState extends State<UserDetailScreen>
107113
}
108114

109115
fetchUserInfo() async {
116+
myInfo = HiveUtil.getUserInfo();
110117
_initPhase = InitPhase.connecting;
111118
var res = await UserApi.getUserInfo(widget.screenName);
112119
if (res.success) {
@@ -256,90 +263,93 @@ class _UserDetailScreenState extends State<UserDetailScreen>
256263
String url = userLegacy?.url ?? "https://twitter.com/$screenName";
257264
return GenericContextMenu(
258265
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+
}
275286
} 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+
);
277302
}
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+
}
313325
} 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+
);
315341
}
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(),
343353
ContextMenuButtonConfig(
344354
"分享用户",
345355
icon: Container(
@@ -451,53 +461,52 @@ class _UserDetailScreenState extends State<UserDetailScreen>
451461
.bodySmall
452462
?.apply(fontSizeDelta: 2),
453463
),
454-
if (ResponsiveUtil.isLandscape()) const SizedBox(height: 3),
455-
if (ResponsiveUtil.isLandscape()) metaRow,
456464
],
457465
),
458466
),
459467
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!);
481500
if (res.success) {
482-
userLegacy!.following = false;
501+
userLegacy!.following = true;
483502
if (mounted) setState(() {});
484-
IToast.showTop("已取消关注@$screenName");
503+
IToast.showTop("已关注@$screenName");
485504
} else {
486-
IToast.showTop("取消关注@$screenName失败");
505+
IToast.showTop("关注@$screenName失败");
487506
}
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失败");
497507
}
498-
}
499-
},
500-
),
508+
},
509+
),
501510
const SizedBox(width: 10),
502511
ItemBuilder.buildRoundButton(
503512
context,
@@ -510,8 +519,8 @@ class _UserDetailScreenState extends State<UserDetailScreen>
510519
),
511520
],
512521
),
513-
if (ResponsiveUtil.isMobile()) const SizedBox(height: 10),
514-
if (ResponsiveUtil.isMobile()) metaRow,
522+
const SizedBox(height: 10),
523+
metaRow,
515524
const SizedBox(height: 10),
516525
Wrap(
517526
spacing: 20,
@@ -549,7 +558,7 @@ class _UserDetailScreenState extends State<UserDetailScreen>
549558
),
550559
],
551560
),
552-
const SizedBox(height: 10),
561+
if (friendList.isNotEmpty) const SizedBox(height: 10),
553562
if (friendList.isNotEmpty)
554563
_buildCountItem(
555564
title: "关注了此账号",

lib/Screens/Flow/search_result_flow_screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class _SearchResultFlowScreenState extends State<SearchResultFlowScreen>
272272
}
273273
}
274274
}
275-
gridTweets = tweets.where((e) => TweetUtil.hasMedia(e)).toList();
275+
gridTweets = tweets.where((e) => TweetUtil.hasMediaByTimelineTweet(e)).toList();
276276
}
277277

278278
@override

lib/Screens/Flow/user_flow_screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class _UserFlowScreenState extends State<UserFlowScreen>
260260
)
261261
: ItemBuilder.buildEmptyPlaceholder(
262262
context: context,
263-
text: "暂无内容",
263+
text: "暂无用户",
264264
scrollController: _scrollController,
265265
),
266266
),

lib/Screens/Flow/user_media_flow_screen.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class _UserMediaFlowScreenState extends State<UserMediaFlowScreen>
236236
TimelineTimelineModule module = entry.content as TimelineTimelineModule;
237237
tweets.addAll(filterTweet(module.items ?? []));
238238
}
239-
return tweets.where((e) => TweetUtil.hasMedia(e)).toList();
239+
return tweets.where((e) => TweetUtil.hasMediaByTimelineTweet(e)).toList();
240240
}
241241

242242
filterTweet(List<ModuleItem?> moduleItems) {
@@ -250,7 +250,7 @@ class _UserMediaFlowScreenState extends State<UserMediaFlowScreen>
250250
tweets.add(item.item.itemContent as TimelineTweet);
251251
}
252252
}
253-
return tweets.where((e) => TweetUtil.hasMedia(e)).toList();
253+
return tweets.where((e) => TweetUtil.hasMediaByTimelineTweet(e)).toList();
254254
}
255255

256256
@override

lib/Screens/Login/login_screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ class _LoginByPasswordScreenState extends State<LoginByPasswordScreen>
383383
children: [
384384
const SizedBox(height: 50),
385385
SizedBox(
386-
height: 230,
386+
height: 235,
387387
child: PageView.builder(
388388
controller: controller,
389389
itemCount: LoginPhase.phases.length,

0 commit comments

Comments
 (0)