Blame view

lib/common/utils/show_star_reward_dialog.dart 2.34 KB
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
1
  import 'package:flutter/material.dart';
642081ad   吴启风   feat:lottie动画加载优化...
2
  
951eb853   吴启风   feat:代码优化-星星等动效对话...
3
  import '../../utils/log_util.dart';
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
4
  import '../widgets/cheer_reward_widget.dart';
642081ad   吴启风   feat:lottie动画加载优化...
5
  import '../widgets/star_reward_widget.dart';
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
6
  
951eb853   吴启风   feat:代码优化-星星等动效对话...
7
8
  Future<void> showStarRewardDialog(
    BuildContext context, {
13de08d7   吴启风   feat:星星动效使用纯json代...
9
10
    double width = 357.5,
    double height = 165,
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
11
    int starCount = 3,
951eb853   吴启风   feat:代码优化-星星等动效对话...
12
13
14
15
    VoidCallback? onDismiss,
  }) async {
    ///showDialog 方法的返回值将是 Navigator.of(context).pop 传递给对话框的参数
    await showDialog(
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
16
      context: context,
4fb9cd24   吴启风   feat:星星奖励动效背景透明
17
18
      barrierColor: Colors.transparent, // 设置透明背景
      barrierDismissible: false,  // 点击对话框外部不关闭对话框
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
19
      builder: (BuildContext context) {
951eb853   吴启风   feat:代码优化-星星等动效对话...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        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(); // 关闭对话框
              },
            ),
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
37
38
39
40
          ),
        );
      },
    );
951eb853   吴启风   feat:代码优化-星星等动效对话...
41
    onDismiss?.call();
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
42
43
  }
  
951eb853   吴启风   feat:代码优化-星星等动效对话...
44
45
  Future<void> showCheerRewardDialog(
    BuildContext context, {
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
46
    required String lottieFile,
13de08d7   吴启风   feat:星星动效使用纯json代...
47
48
    double width = 357.5,
    double height = 165,
951eb853   吴启风   feat:代码优化-星星等动效对话...
49
50
51
    VoidCallback? onDismiss,
  }) async {
    await showDialog(
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
52
      context: context,
4fb9cd24   吴启风   feat:星星奖励动效背景透明
53
      barrierColor: Colors.transparent, // 设置透明背景
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
54
55
      barrierDismissible: false, // 点击对话框外部不关闭对话框
      builder: (BuildContext context) {
951eb853   吴启风   feat:代码优化-星星等动效对话...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
        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(); // 关闭对话框
              },
            ),
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
73
74
75
76
          ),
        );
      },
    );
951eb853   吴启风   feat:代码优化-星星等动效对话...
77
78
    onDismiss?.call();
  }