Blame view

lib/pages/section/subsection/base_section/bloc.dart 2.23 KB
46675a89   吴启风   feat:过渡页-视频环节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  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;
  
aa0d2360   吴启风   feat:过渡页-视频环节(再来一次)
15
16
17
    ///这里可以定义一些通用的逻辑
    void sectionComplete(final VoidCallback? nextSectionTap,
        {BuildContext? context}) {
46675a89   吴启风   feat:过渡页-视频环节
18
19
20
21
22
23
24
      // 逻辑来标记步骤为已完成
      // 比如更新状态
      if (isCompleteDialogShow) {
        return;
      }
      isCompleteDialogShow = true;
      showDialog(
aa0d2360   吴启风   feat:过渡页-视频环节(再来一次)
25
        context: context ?? AppRouter.context,
46675a89   吴启风   feat:过渡页-视频环节
26
27
28
29
30
31
32
33
34
35
36
        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>[
46675a89   吴启风   feat:过渡页-视频环节
37
38
39
40
                  Expanded(
                    flex: 1,
                    child: GestureDetector(
                      onTap: () {
46675a89   吴启风   feat:过渡页-视频环节
41
                        add(SectionAgainEvent() as E);
aa0d2360   吴启风   feat:过渡页-视频环节(再来一次)
42
                        popPage();
46675a89   吴启风   feat:过渡页-视频环节
43
44
45
46
                      },
                      child: Image.asset('section_finish_again'.assetPng),
                    ),
                  ),
46675a89   吴启风   feat:过渡页-视频环节
47
48
49
50
                  Expanded(
                    flex: 2,
                    child: Image.asset('section_finish_steve'.assetPng),
                  ),
46675a89   吴启风   feat:过渡页-视频环节
51
52
53
54
                  Expanded(
                    flex: 1,
                    child: GestureDetector(
                      onTap: () {
46675a89   吴启风   feat:过渡页-视频环节
55
56
57
58
59
60
61
62
63
64
65
                        popPage();
                        nextSectionTap!();
                      },
                      child: Image.asset('section_finish_next'.assetPng),
                    ),
                  ),
                ],
              ),
            ),
          );
        },
aa0d2360   吴启风   feat:过渡页-视频环节(再来一次)
66
      ).then((value) => isCompleteDialogShow = false);
46675a89   吴启风   feat:过渡页-视频环节
67
68
    }
  }