Blame view

lib/pages/section/subsection/base_section/bloc.dart 2.43 KB
46675a89   吴启风   feat:过渡页-视频环节
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
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
  import 'package:wow_english/common/extension/string_extension.dart';
  
  import '../../../../route/route.dart';
  import 'event.dart';
  import 'state.dart';
  
  abstract class BaseSectionBloc<E extends BaseSectionEvent,
      S extends BaseSectionState> extends Bloc<E, S> {
    BaseSectionBloc(super.initialState);
  
    bool isCompleteDialogShow = false;
  
    // 这里可以定义一些通用的逻辑
    void completeSection(final VoidCallback? nextSectionTap) {
      // 逻辑来标记步骤为已完成
      // 比如更新状态
      if (isCompleteDialogShow) {
        return;
      }
      isCompleteDialogShow = true;
      showDialog(
        context: AppRouter.context,
        barrierDismissible: false,
        barrierColor: Colors.black54,
        builder: (BuildContext context) {
          return AlertDialog(
            backgroundColor: Colors.transparent,
            content: SizedBox(
              width: double.infinity, // 宽度设置为无限,使其尽可能铺满屏幕
              height: MediaQuery.of(context).size.height * 0.6, // 高度设置为屏幕高度的60%
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween, // 图片之间分配空间
                children: <Widget>[
                  // 左侧可点击的图片
                  Expanded(
                    flex: 1,
                    child: GestureDetector(
                      onTap: () {
                        isCompleteDialogShow = false;
                        popPage();
                        add(SectionAgainEvent() as E);
                      },
                      child: Image.asset('section_finish_again'.assetPng),
                    ),
                  ),
                  // 中间的图片
                  Expanded(
                    flex: 2,
                    child: Image.asset('section_finish_steve'.assetPng),
                  ),
                  // 右侧可点击的图片
                  Expanded(
                    flex: 1,
                    child: GestureDetector(
                      onTap: () {
                        // 处理右侧图片的点击事件
                        isCompleteDialogShow = false;
                        popPage();
                        nextSectionTap!();
                      },
                      child: Image.asset('section_finish_next'.assetPng),
                    ),
                  ),
                ],
              ),
            ),
          );
        },
      );
    }
  }