Blame view

lib/pages/reading/reading_page.dart 6.68 KB
1dc46cf7   吴启风   feat:绘本ui
1
2
3
4
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
  import 'package:flutter_screenutil/flutter_screenutil.dart';
  import 'package:wow_english/common/extension/string_extension.dart';
2a427e12   吴启风   feat:绘本静态ui基本完成
5
  import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart';
1dc46cf7   吴启风   feat:绘本ui
6
7
8
  
  import 'bloc/reading_bloc.dart';
  
2a427e12   吴启风   feat:绘本静态ui基本完成
9
10
  class ReadingPage extends StatelessWidget {
    const ReadingPage({super.key});
1dc46cf7   吴启风   feat:绘本ui
11
12
13
14
  
    @override
    Widget build(BuildContext context) {
      return BlocProvider(
2a427e12   吴启风   feat:绘本静态ui基本完成
15
        create: (_) => ReadingPageBloc(PageController()),
1dc46cf7   吴启风   feat:绘本ui
16
17
18
19
20
21
22
23
24
25
        child: _ReadingPage(),
      );
    }
  }
  
  class _ReadingPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return BlocListener<ReadingPageBloc, ReadingPageState>(
        listener: (context, state) {},
2a427e12   吴启风   feat:绘本静态ui基本完成
26
        child: _readingPageView(),
1dc46cf7   吴启风   feat:绘本ui
27
28
29
      );
    }
  
2a427e12   吴启风   feat:绘本静态ui基本完成
30
31
32
    Widget _readingPageView() => BlocBuilder<ReadingPageBloc, ReadingPageState>(
        buildWhen: (_, s) => s is CurrentPageIndexState,
        builder: (context, state) {
1dc46cf7   吴启风   feat:绘本ui
33
34
35
36
37
          final bloc = BlocProvider.of<ReadingPageBloc>(context);
          return Container(
            color: Colors.white,
            child: Stack(
              children: [
2a427e12   吴启风   feat:绘本静态ui基本完成
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
74
75
76
77
78
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
                PageView.builder(
                    itemCount: 10,
                    controller: bloc.pageController,
                    onPageChanged: (int index) {
                      bloc.add(CurrentPageIndexChangeEvent(index));
                    },
                    itemBuilder: (context, int index) {
                      return _readingPagerItem();
                    }),
                Container(
                  color: Colors.transparent,
                  height: 60.h,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Padding(
                        padding:
                            EdgeInsets.only(left: ScreenUtil().bottomBarHeight),
                        child: IconButton(
                            onPressed: () {
                              Navigator.pop(context);
                            },
                            icon: Image.asset(
                              'back_around'.assetPng,
                              width: 40,
                              height: 40,
                            )),
                      ),
                      Container(
                        height: 32.h,
                        padding: EdgeInsets.symmetric(horizontal: 27.w),
                        decoration: BoxDecoration(
                          color: const Color(0xFF00B6F1),
                          borderRadius: BorderRadius.circular(15.r),
                          border: Border.all(
                            width: 1.0,
                            color: const Color(0xFF140C10),
                          ),
                        ),
                        alignment: Alignment.center,
                        child: Text(
                          '${bloc.currentPage}/10',
  
                          ///todo 分母需要替换成数据数组长度
                          style: TextStyle(fontSize: 20.sp, color: Colors.white),
                        ),
                      ),
  
                      Padding(
                        padding: EdgeInsets.only(right: 15.w + ScreenUtil().bottomBarHeight),
                        child: GestureDetector(
                          onTap: () {
                            bloc.add(CurrentModeChangeEvent());
                          },
                          child: SizedBox(
                            height: 40.h,
                            child: Container(
                              decoration: BoxDecoration(
                                image: DecorationImage(
                                    image: AssetImage('bg_reading_mode'.assetPng),
                                    fit: BoxFit.fill),
                              ),
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(horizontal: 10.w),
                              child: Text(
                                bloc.currentMode == ReadingModeType.auto
                                    ? '设为手动'
                                    : '设为自动',
                                style: TextStyle(fontSize: 14.5.sp),
                              ),
                            ),
                          ),
                        ),
                      ),
  
                      // ScreenUtil().bottomBarHeight.horizontalSpace,
                    ],
                  ),
                ),
                Align(
                  alignment: Alignment.bottomLeft,
                  child: Container(
                    color: const Color(0x4DFFFFFF),
                    margin: EdgeInsets.symmetric(horizontal: 10.w),
                    child: Row(
                      children: [
                        Image.asset(
                          'voice'.assetPng,
                          height: 40.h,
                          width: 45.w,
                        ),
                        SizedBox(
                          width: 10.w,
                        ),
                        Expanded(
                            child: Text(
                          "HelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorld",
                          style: TextStyle(
                              color: const Color(0xFF333333), fontSize: 21.sp),
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                        )),
                        SizedBox(
                          width: 10.w,
                        ),
                        Image.asset(
                          'micro_phone'.assetPng,
                          height: 47.h,
                          width: 47.w,
                        ),
                        SizedBox(
                          width: 10.w,
                        ),
                        Visibility(
                          visible: false,
  
                          ///todo 依据是否录过音
                          child: Image.asset(
                            'record_pause'.assetWebp,
  
                            ///todo 根据播放状态切换图片
                            height: 33.h,
                            width: 33.w,
                          ),
                        )
                      ],
1dc46cf7   吴启风   feat:绘本ui
164
                    ),
2a427e12   吴启风   feat:绘本静态ui基本完成
165
                  ),
1dc46cf7   吴启风   feat:绘本ui
166
167
168
169
170
171
                )
              ],
            ),
          );
        });
  
2a427e12   吴启风   feat:绘本静态ui基本完成
172
173
174
    Widget _readingPagerItem() =>
        BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
          return Stack(
1dc46cf7   吴启风   feat:绘本ui
175
176
            children: [
              Image.network(
2a427e12   吴启风   feat:绘本静态ui基本完成
177
178
179
                  'https://img.liblibai.com/web/648331d5a2cb5.png?image_process=format,webp&x-oss-process=image/resize,w_2980,m_lfit/format,webp',
                  height: double.infinity,
                  width: double.infinity),
1dc46cf7   吴启风   feat:绘本ui
180
181
182
183
            ],
          );
        });
  }