Blame view

lib/pages/shop/exchane/exchange_lesson_page.dart 4.81 KB
d1d32220   liangchengyou   feat:兑换课程+购买记录
1
2
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
d1d32220   liangchengyou   feat:兑换课程+购买记录
3
4
5
  import 'package:flutter_screenutil/flutter_screenutil.dart';
  import 'package:wow_english/common/extension/string_extension.dart';
  import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
608c05b4   liangchengyou   feat:兑换课程
6
  import 'package:wow_english/pages/shop/exchane/widegts/exchange_result_dialog.dart';
d1d32220   liangchengyou   feat:兑换课程+购买记录
7
  import 'package:wow_english/route/route.dart';
d1d32220   liangchengyou   feat:兑换课程+购买记录
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  
  import 'bloc/exchange_lesson_bloc.dart';
  
  class ExchangeLessonPage extends StatelessWidget {
    const ExchangeLessonPage({super.key});
  
    @override
    Widget build(BuildContext context) {
      return BlocProvider(
        create: (context) => ExchangeLessonBloc(),
        child: _ExchangeLessonPage(),
      );
    }
  }
  
  class _ExchangeLessonPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
c61b3c1a   Key   feat: toast_util....
26
27
      return BlocListener<ExchangeLessonBloc, ExchangeLessonState>(
        listener: (context, state) {
d1d32220   liangchengyou   feat:兑换课程+购买记录
28
          if (state is CheckCodeResultState) {
608c05b4   liangchengyou   feat:兑换课程
29
30
31
32
33
34
35
            showDialog<ExChangeResultDialog>(
                context: context,
                barrierDismissible: !state.result,
                builder: (context){
                  return ExChangeResultDialog(
                      resultType:state.result,
                      onTap:(){
15987941   liangchengyou   feat:兑换码接口+本地密码加密
36
                        popPage();
608c05b4   liangchengyou   feat:兑换课程
37
38
39
                      }
                  );
            });
d1d32220   liangchengyou   feat:兑换课程+购买记录
40
41
42
43
44
45
          }
        },
        child: _exchangeLessonPageView(),
      );
    }
  
c61b3c1a   Key   feat: toast_util....
46
    Widget _exchangeLessonPageView() => BlocBuilder<ExchangeLessonBloc, ExchangeLessonState>(builder: (context, state) {
d1d32220   liangchengyou   feat:兑换课程+购买记录
47
48
49
50
51
52
53
54
55
56
          final bloc = BlocProvider.of<ExchangeLessonBloc>(context);
          return Scaffold(
            resizeToAvoidBottomInset: false,
            body: Container(
              color: Colors.white,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  10.5.verticalSpace,
                  Padding(
c61b3c1a   Key   feat: toast_util....
57
                    padding: EdgeInsets.symmetric(horizontal: 15.w),
d1d32220   liangchengyou   feat:兑换课程+购买记录
58
59
60
61
62
63
64
65
66
67
68
69
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        IconButton(
                          icon: Image.asset(
                            'back_around'.assetPng,
                            width: 40,
                            height: 40,
                          ),
                          color: Colors.white,
                          onPressed: () {
c61b3c1a   Key   feat: toast_util....
70
                            Navigator.pop(context);
d1d32220   liangchengyou   feat:兑换课程+购买记录
71
72
73
74
75
76
77
                          },
                        ),
                        Image.asset(
                          'wow_ex_lesson'.assetPng,
                          width: 139.w,
                          height: 81.h,
                        ),
c61b3c1a   Key   feat: toast_util....
78
                        SizedBox.fromSize(size: const Size(40.0, 40.0))
d1d32220   liangchengyou   feat:兑换课程+购买记录
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
                      ],
                    ),
                  ),
                  Expanded(
                    child: Padding(
                      padding: EdgeInsets.symmetric(horizontal: 135.w),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          TextFieldCustomerWidget(
                            height: 55.h,
                            hitText: '请输入兑换码',
                            bgImageName: 'Input_layer_up',
                            textInputType: TextInputType.emailAddress,
                            controller: bloc.codeNumberController,
                            onChangeValue: (String value) {
                              bloc.add(CodeNumberChangeEvent());
                            },
                          ),
                          21.5.verticalSpace,
                          GestureDetector(
                            onTap: () {
                              if (bloc.checkCode) {
                                bloc.add(CheckCodeEvent());
                              }
                            },
                            child: Container(
                              decoration: BoxDecoration(
                                image: DecorationImage(
c61b3c1a   Key   feat: toast_util....
108
109
                                    image: AssetImage(bloc.checkCode ? 'ex_sure'.assetPng : 'ex_dis'.assetPng),
                                    fit: BoxFit.fill),
d1d32220   liangchengyou   feat:兑换课程+购买记录
110
                              ),
c61b3c1a   Key   feat: toast_util....
111
                              padding: EdgeInsets.symmetric(horizontal: 27.w, vertical: 14.h),
d1d32220   liangchengyou   feat:兑换课程+购买记录
112
113
                              child: Text(
                                '兑换',
c61b3c1a   Key   feat: toast_util....
114
                                style: TextStyle(fontSize: 16.sp, color: Colors.white),
d1d32220   liangchengyou   feat:兑换课程+购买记录
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
                              ),
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  Image.asset(
                    'bottom_grass'.assetPng,
                  ),
                ],
              ),
            ),
          );
        });
c61b3c1a   Key   feat: toast_util....
130
  }