Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit 27e40ae

Browse files
committed
fix: 弹出层返回异常黑屏
1 parent a881b6d commit 27e40ae

File tree

17 files changed

+1291
-1387
lines changed

17 files changed

+1291
-1387
lines changed

lib/common/widgets/list_sheet.dart

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
77
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
88

99
import '../../utils/storage.dart';
10+
import 'my_dialog.dart';
1011

1112
class ListSheet {
1213
ListSheet({
@@ -26,19 +27,16 @@ class ListSheet {
2627
final BuildContext context;
2728

2829
void buildShowBottomSheet() {
29-
SmartDialog.show(
30-
alignment: MediaQuery.of(context).orientation == Orientation.portrait
31-
? Alignment.bottomRight
32-
: Alignment.topRight,
33-
useSystem: true,
34-
builder: (BuildContext context) => ListSheetContent(
35-
episodes: episodes,
36-
bvid: bvid,
37-
aid: aid,
38-
currentCid: currentCid,
39-
changeFucCall: changeFucCall,
40-
// onClose: SmartDialog.dismiss,
41-
));
30+
MyDialog.showCorner(
31+
context,
32+
ListSheetContent(
33+
episodes: episodes,
34+
bvid: bvid,
35+
aid: aid,
36+
currentCid: currentCid,
37+
changeFucCall: changeFucCall,
38+
// onClose: SmartDialog.dismiss,
39+
));
4240
}
4341
}
4442

@@ -130,20 +128,22 @@ class _ListSheetContentState extends State<ListSheetContent> {
130128
// semanticLabel: "正在播放:",
131129
// )
132130
// : null,
133-
title: Text(
134-
title,
135-
style: TextStyle(
136-
fontSize: 14,
137-
color: isCurrentIndex
138-
? primary
139-
: Theme.of(context).colorScheme.onSurface,
140-
),
141-
semanticsLabel: isCurrentIndex ? "正在播放:$title" : title,
142-
),
143-
trailing: Row(
131+
title: Row(
144132
mainAxisSize: MainAxisSize.min,
145133
children: [
134+
Expanded(
135+
child: Text(
136+
title,
137+
style: TextStyle(
138+
fontSize: 14,
139+
color: isCurrentIndex
140+
? primary
141+
: Theme.of(context).colorScheme.onSurface,
142+
),
143+
semanticsLabel: isCurrentIndex ? "正在播放:$title" : title,
144+
)),
146145
if (episode.badge != null) ...[
146+
const SizedBox(width: 10),
147147
if (episode.badge == '会员')
148148
Image.asset(
149149
'assets/images/big-vip.png',
@@ -154,8 +154,13 @@ class _ListSheetContentState extends State<ListSheetContent> {
154154
const SizedBox(width: 10),
155155
],
156156
if (!(episode.runtimeType.toString() == 'EpisodeItem' &&
157-
(episode.longTitle != null && episode.longTitle != '')))
158-
Text('${index + 1}/${widget.episodes!.length}'),
157+
(episode.longTitle != null && episode.longTitle != ''))) ...[
158+
const SizedBox(width: 10),
159+
Text(
160+
'${index + 1}/${widget.episodes!.length}',
161+
style: const TextStyle(fontSize: 13),
162+
),
163+
]
159164
],
160165
),
161166
);
@@ -171,8 +176,8 @@ class _ListSheetContentState extends State<ListSheetContent> {
171176
color: Theme.of(context).colorScheme.surface,
172177
borderRadius: const BorderRadius.all(Radius.circular(12)),
173178
),
174-
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 30),
175-
padding: const EdgeInsets.all(6),
179+
// margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 30),
180+
padding: const EdgeInsets.only(left: 6, top: 3, bottom: 10),
176181
child: Column(
177182
children: [
178183
Container(
@@ -226,6 +231,8 @@ class _ListSheetContentState extends State<ListSheetContent> {
226231
),
227232
Divider(
228233
height: 1,
234+
indent: 10,
235+
endIndent: 20,
229236
color: Theme.of(context).dividerColor.withOpacity(0.1),
230237
),
231238
const SizedBox(height: 1),
@@ -245,6 +252,8 @@ class _ListSheetContentState extends State<ListSheetContent> {
245252
},
246253
itemScrollController: itemScrollController,
247254
separatorBuilder: (_, index) => Divider(
255+
indent: 18,
256+
endIndent: 25,
248257
height: 1,
249258
color: Theme.of(context).dividerColor.withOpacity(0.1),
250259
),

lib/common/widgets/my_dialog.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:PiliPalaX/common/constants.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_html/flutter_html.dart';
4+
5+
class MyDialog {
6+
static Future<void> show(BuildContext context, Widget child) {
7+
return showDialog(
8+
barrierDismissible: true,
9+
context: context,
10+
builder: (BuildContext context) => Dialog(
11+
insetPadding: const EdgeInsets.all(0),
12+
child: Material(
13+
clipBehavior: Clip.hardEdge,
14+
borderRadius: StyleString.mdRadius,
15+
child: child,
16+
)),
17+
);
18+
}
19+
20+
static Future<void> showCorner(BuildContext context, Widget child) {
21+
return showDialog(
22+
barrierDismissible: true,
23+
context: context,
24+
builder: (BuildContext context) => Align(
25+
alignment: MediaQuery.of(context).orientation == Orientation.portrait
26+
? Alignment.bottomRight
27+
: Alignment.topRight,
28+
child: Padding(
29+
padding: const EdgeInsets.all(8.0), // 设置外边距
30+
child: Material(
31+
clipBehavior: Clip.hardEdge,
32+
borderRadius: StyleString.mdRadius,
33+
child: child,
34+
)),
35+
),
36+
);
37+
}
38+
}

lib/common/widgets/overlay_pop.dart

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class OverlayPop extends StatelessWidget {
2929
mainAxisSize: MainAxisSize.min,
3030
crossAxisAlignment: CrossAxisAlignment.start,
3131
children: [
32+
const SizedBox(height: 8),
3233
Stack(
3334
children: [
3435
NetworkImgLayer(
@@ -69,7 +70,7 @@ class OverlayPop extends StatelessWidget {
6970
padding: const EdgeInsets.fromLTRB(12, 10, 8, 10),
7071
child: Row(
7172
children: [
72-
if (videoItem.title is String) ...[
73+
if (videoItem.title is String)
7374
Expanded(
7475
child: SelectableText(
7576
videoItem.title ?? '',
@@ -82,8 +83,8 @@ class OverlayPop extends StatelessWidget {
8283
),
8384
// overflow: TextOverflow.ellipsis,
8485
),
85-
),
86-
] else ...[
86+
)
87+
else
8788
Expanded(
8889
child: RichText(
8990
overflow: TextOverflow.ellipsis,
@@ -110,29 +111,33 @@ class OverlayPop extends StatelessWidget {
110111
),
111112
),
112113
),
113-
],
114114
if (videoItem.runtimeType.toString() != 'LiveItemModel')
115-
IconButton(
116-
tooltip: '稍后再看',
117-
icon: Icon(MdiIcons.clockTimeEightOutline, size: 20),
118-
onPressed: () async {
119-
var res = await UserHttp.toViewLater(
120-
bvid: videoItem.bvid as String);
121-
SmartDialog.showToast(res['msg']);
122-
},
115+
SizedBox(
116+
width: 30,
117+
child: IconButton(
118+
tooltip: '稍后再看',
119+
icon: Icon(MdiIcons.clockTimeEightOutline, size: 20),
120+
onPressed: () async {
121+
var res = await UserHttp.toViewLater(
122+
bvid: videoItem.bvid as String);
123+
SmartDialog.showToast(res['msg']);
124+
},
125+
),
123126
),
124127
const SizedBox(width: 4),
125-
IconButton(
126-
tooltip: '保存封面图',
127-
onPressed: () async {
128-
await DownloadUtils.downloadImg(
129-
context,
130-
videoItem.pic ?? videoItem.cover ?? '',
131-
);
132-
// closeFn!();
133-
},
134-
icon: const Icon(Icons.download_outlined, size: 20),
135-
)
128+
SizedBox(
129+
width: 30,
130+
child: IconButton(
131+
tooltip: '保存封面图',
132+
onPressed: () async {
133+
await DownloadUtils.downloadImg(
134+
context,
135+
videoItem.pic ?? videoItem.cover ?? '',
136+
);
137+
// closeFn!();
138+
},
139+
icon: const Icon(Icons.download_outlined, size: 20),
140+
))
136141
],
137142
),
138143
),

lib/common/widgets/video_card_h.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import '../../http/search.dart';
66
import '../../utils/utils.dart';
77
import '../constants.dart';
88
import 'badge.dart';
9+
import 'my_dialog.dart';
910
import 'network_img_layer.dart';
1011
import 'overlay_pop.dart';
1112
import 'stat/danmu.dart';
@@ -94,13 +95,7 @@ class VideoCardH extends StatelessWidget {
9495
GestureDetector(
9596
onLongPress: () {
9697
// 弹窗显示封面
97-
SmartDialog.show(
98-
useSystem: true,
99-
alignment: Alignment.center,
100-
builder: (BuildContext context) {
101-
return OverlayPop(videoItem: videoItem);
102-
},
103-
);
98+
MyDialog.show(context, OverlayPop(videoItem: videoItem));
10499
},
105100
behavior: HitTestBehavior.translucent,
106101
child: Hero(

lib/common/widgets/video_card_v.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
44
import 'package:get/get.dart';
55
import '../../models/home/rcmd/result.dart';
66
import '../../models/model_rec_video_item.dart';
7+
import 'my_dialog.dart';
78
import 'overlay_pop.dart';
89
import 'stat/danmu.dart';
910
import 'stat/view.dart';
@@ -170,13 +171,8 @@ class VideoCardV extends StatelessWidget {
170171
GestureDetector(
171172
onLongPress: () {
172173
// 弹窗显示封面
173-
SmartDialog.show(
174-
useSystem: true,
175-
alignment: Alignment.center,
176-
builder: (BuildContext context) {
177-
return OverlayPop(videoItem: videoItem);
178-
},
179-
);
174+
MyDialog.show(
175+
context, OverlayPop(videoItem: videoItem));
180176
},
181177
behavior: HitTestBehavior.translucent,
182178
child: Hero(

lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ class MyApp extends StatelessWidget {
237237
navigatorObservers: [
238238
VideoDetailPage.routeObserver,
239239
SearchPage.routeObserver,
240-
FlutterSmartDialog.observer,
241240
],
242241
);
243242
}),

lib/pages/dynamics/widgets/video_panel.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:PiliPalaX/common/widgets/badge.dart';
77
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
88
import 'package:PiliPalaX/utils/utils.dart';
99

10+
import '../../../common/widgets/my_dialog.dart';
1011
import '../../../common/widgets/overlay_pop.dart';
1112
import 'rich_node_panel.dart';
1213

@@ -91,13 +92,8 @@ Widget videoSeasonWidget(item, context, type, source, {floor = 1}) {
9192
behavior: HitTestBehavior.translucent,
9293
onLongPress: () {
9394
// 弹窗显示封面
94-
SmartDialog.show(
95-
useSystem: true,
96-
alignment: Alignment.center,
97-
builder: (BuildContext context) {
98-
return OverlayPop(videoItem: content);
99-
},
100-
);
95+
MyDialog.show(
96+
context, OverlayPop(videoItem: content));
10197
},
10298
child: Hero(
10399
tag: content.bvid,

lib/pages/follow/widgets/follow_item.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'package:PiliPalaX/pages/video/introduction/widgets/group_panel.dart';
77
import 'package:PiliPalaX/utils/feed_back.dart';
88
import 'package:PiliPalaX/utils/utils.dart';
99

10+
import '../../../common/widgets/my_dialog.dart';
11+
1012
class FollowItem extends StatelessWidget {
1113
final FollowItemModel item;
1214
final FollowController? ctr;
@@ -46,11 +48,8 @@ class FollowItem extends StatelessWidget {
4648
? SizedBox(
4749
height: 34,
4850
child: TextButton(
49-
onPressed: () async {
50-
await Get.bottomSheet(
51-
GroupPanel(mid: item.mid!),
52-
isScrollControlled: true,
53-
);
51+
onPressed: () {
52+
MyDialog.show(context, GroupPanel(mid: item.mid!));
5453
},
5554
style: TextButton.styleFrom(
5655
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),

lib/pages/live/widgets/live_item.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:PiliPalaX/models/live/item.dart';
66
import 'package:PiliPalaX/utils/utils.dart';
77
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
88

9+
import '../../../common/widgets/my_dialog.dart';
910
import '../../../common/widgets/overlay_pop.dart';
1011

1112
// 视频卡片 - 垂直布局
@@ -58,13 +59,8 @@ class LiveCardV extends StatelessWidget {
5859
behavior: HitTestBehavior.translucent,
5960
onLongPress: () {
6061
// 弹窗显示封面
61-
SmartDialog.show(
62-
useSystem: true,
63-
alignment: Alignment.center,
64-
builder: (BuildContext context) {
65-
return OverlayPop(videoItem: liveItem);
66-
},
67-
);
62+
MyDialog.show(
63+
context, OverlayPop(videoItem: liveItem));
6864
},
6965
child: Hero(
7066
tag: heroTag,

0 commit comments

Comments
 (0)