Blame view

lib/common/utils/show_star_reward_dialog.dart 2.18 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,
951eb853   吴启风   feat:代码优化-星星等动效对话...
17
      barrierDismissible: false,
ae239ac7   吴启风   feat:星星动画封装(资源有点问题)
18
      builder: (BuildContext context) {
951eb853   吴启风   feat:代码优化-星星等动效对话...
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
        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:星星动画封装(资源有点问题)
36
37
38
39
          ),
        );
      },
    );
951eb853   吴启风   feat:代码优化-星星等动效对话...
40
    onDismiss?.call();
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
41
42
  }
  
951eb853   吴启风   feat:代码优化-星星等动效对话...
43
44
  Future<void> showCheerRewardDialog(
    BuildContext context, {
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
45
    required String lottieFile,
13de08d7   吴启风   feat:星星动效使用纯json代...
46
47
    double width = 357.5,
    double height = 165,
951eb853   吴启风   feat:代码优化-星星等动效对话...
48
49
50
    VoidCallback? onDismiss,
  }) async {
    await showDialog(
c623c7b2   吴启风   feat:语音跟读作答结果动效&语音
51
52
53
      context: context,
      barrierDismissible: false, // 点击对话框外部不关闭对话框
      builder: (BuildContext context) {
951eb853   吴启风   feat:代码优化-星星等动效对话...
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        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:语音跟读作答结果动效&语音
71
72
73
74
          ),
        );
      },
    );
951eb853   吴启风   feat:代码优化-星星等动效对话...
75
76
    onDismiss?.call();
  }