show_star_reward_dialog.dart
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import 'package:flutter/material.dart';
import '../../utils/log_util.dart';
import '../widgets/cheer_reward_widget.dart';
import '../widgets/star_reward_widget.dart';
Future<void> showStarRewardDialog(
BuildContext context, {
double width = 357.5,
double height = 165,
int starCount = 3,
VoidCallback? onDismiss,
}) async {
///showDialog 方法的返回值将是 Navigator.of(context).pop 传递给对话框的参数
await showDialog(
context: context,
barrierColor: Colors.transparent, // 设置透明背景
barrierDismissible: false, // 点击对话框外部不关闭对话框
builder: (BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
Log.d('WQF showStarRewardDialog onPopInvoked didPop=$didPop');
},
child: Dialog(
backgroundColor: Colors.transparent, // 设置对话框背景为透明
insetPadding: const EdgeInsets.all(0), // 去除对话框的内边距
child: StarRewardWidget(
width: width,
height: height,
isPlaying: true,
starCount: starCount,
onAnimationEnd: () {
Navigator.of(context).pop(); // 关闭对话框
},
),
),
);
},
);
onDismiss?.call();
}
Future<void> showCheerRewardDialog(
BuildContext context, {
required String lottieFile,
double width = 357.5,
double height = 165,
VoidCallback? onDismiss,
}) async {
await showDialog(
context: context,
barrierColor: Colors.transparent, // 设置透明背景
barrierDismissible: false, // 点击对话框外部不关闭对话框
builder: (BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
Log.d('WQF showCheerRewardDialog onPopInvoked didPop=$didPop');
},
child: Dialog(
backgroundColor: Colors.transparent, // 设置对话框背景为透明
insetPadding: const EdgeInsets.all(0), // 去除对话框的内边距
child: CheerRewardWidget(
lottieFile: lottieFile,
width: width,
height: height,
isPlaying: true,
onAnimationEnd: () {
Navigator.of(context).pop(); // 关闭对话框
},
),
),
);
},
);
onDismiss?.call();
}