Blame view

lib/pages/home/widgets/BaseHomeHeaderWidget.dart 6.6 KB
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
1
2
3
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
  import 'package:flutter_screenutil/flutter_screenutil.dart';
28f20da9   吴启风   feat:针对apple审核对支付...
4
  import 'package:wow_english/common/core/app_config_helper.dart';
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
5
  import 'package:wow_english/common/extension/string_extension.dart';
025d8543   biao   首页gametime播放修改
6
  import 'package:wow_english/utils/audio_player_util.dart';
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
7
8
9
10
11
12
  
  import '../../../common/core/user_util.dart';
  import '../../../models/course_entity.dart';
  import '../../../route/route.dart';
  import '../../../utils/image_util.dart';
  import '../../user/bloc/user_bloc.dart';
6770c637   吴启风   feat: 动态配置客服联系方式
13
  import 'customer_service_qr_dialog.dart';
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
14
  
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
15
16
  typedef HeaderCallback = void Function(dynamic);
  
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
17
  class BaseHomeHeaderWidget extends StatelessWidget {
9d058cb4   吴启风   feat: 调整首页导航栏入口布局
18
19
20
21
22
23
    const BaseHomeHeaderWidget({
      super.key,
      this.entity,
      this.callBack,
      this.onWowSelected,
    });
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
24
25
  
    final CourseEntity? entity;
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
26
    final HeaderCallback? callBack;
9d058cb4   吴启风   feat: 调整首页导航栏入口布局
27
    final VoidCallback? onWowSelected;
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
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
  
    @override
    Widget build(BuildContext context) {
      return BlocBuilder<UserBloc, UserState>(
        builder: (context, state) {
          return Container(
              height: 45,
              width: double.infinity,
              decoration: BoxDecoration(
                image: DecorationImage(
                  image: AssetImage('bg_header_sliver'.assetPng),
                  fit: BoxFit.cover,
                ),
              ),
              padding: EdgeInsets.symmetric(horizontal: 9.5.w),
              child: Row(
                children: [
                  ScreenUtil().bottomBarHeight.horizontalSpace,
                  GestureDetector(
                    onTap: () => {onUserClick()},
                    child: Container(
                      decoration: BoxDecoration(
                        border: Border.all(
                          width: 1.0,
                          color: const Color(0xFF140C10),
                        ),
                        borderRadius: BorderRadius.circular(21),
                      ),
                      child: CircleAvatar(
                        radius: 21,
                        backgroundImage: ImageUtil.getImageProviderOnDefault(
                            UserUtil.getUser()?.avatarUrl),
                      ),
                    ),
                  ),
                  GestureDetector(
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
64
                    onTap: () => {onUserClick()},
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
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
                    child: Container(
                      margin: const EdgeInsets.only(left: 7),
                      padding: const EdgeInsets.all(4.0),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(2),
                        border: Border.all(
                            width: 1.0,
                            color: const Color(0xFF140C10),
                            style: BorderStyle.solid),
                      ),
                      child: Text(
                        UserUtil.getUser()?.name ?? '未登录',
                        style: TextStyle(
                            color: const Color(0xFF333333), fontSize: 16.sp),
                      ),
                    ),
                  ),
                  20.horizontalSpace,
                  const Expanded(
                      child: Text(
                    "WOW ENGLISH",
                    textAlign: TextAlign.left,
                    style: TextStyle(color: Colors.white, fontSize: 30.0),
                  )),
9d058cb4   吴启风   feat: 调整首页导航栏入口布局
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
                  Offstage(
                    offstage: AppConfigHelper.shouldHidePay() ||
                        !UserUtil.isLogined() ||
                        UserUtil.isAppReviewAccount(),
                    child: GestureDetector(
                      onTap: onWowSelected,
                      child: Padding(
                        padding: EdgeInsets.only(right: 10.w),
                        child: Image.asset(
                          'wow_selected_header'.assetPng,
                          width: 105.w,
                          height: 34.h,
                          fit: BoxFit.contain,
                        ),
                      ),
                    ),
                  ),
6770c637   吴启风   feat: 动态配置客服联系方式
107
108
109
110
111
112
113
114
115
116
117
                  FutureBuilder(
                    future: AppConfigHelper.getAppConfig(),
                    builder: (context, snapshot) {
                      final customerQr = snapshot.data?.customerQr?.trim() ?? '';
                      if (customerQr.isEmpty) {
                        return const SizedBox.shrink();
                      }
                      return GestureDetector(
                        onTap: () =>
                            showCustomerServiceQrDialog(context, customerQr),
                        child: Padding(
9d058cb4   吴启风   feat: 调整首页导航栏入口布局
118
                          padding: EdgeInsets.only(right: 10.w),
6770c637   吴启风   feat: 动态配置客服联系方式
119
120
121
122
123
124
125
126
127
128
                          child: Image.asset(
                            'ic_customer_service'.assetPng,
                            width: 90.w,
                            height: 28.h,
                            fit: BoxFit.contain,
                          ),
                        ),
                      );
                    },
                  ),
8d1f93b4   吴启风   feat:隐藏组件优化
129
                  Offstage(
ca0d27b6   吴启风   feat:会员有效期增加点击跳转&...
130
131
132
                      offstage: AppConfigHelper.shouldHidePay() ||
                          !UserUtil.isLogined(),
                      child: GestureDetector(
2d1ead53   吴启风   feat:背景音播放优化
133
134
                        onTap: () async => {
                          await AudioPlayerUtil.getInstance().pause(),
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
135
136
137
138
139
140
141
142
                          pushNamed(AppRouteName.shop).then((value) {
                            if (value != null) {
                              if (callBack == null) {
                              } else {
                                callBack!(value);
                              }
                            }
                          })
ca0d27b6   吴启风   feat:会员有效期增加点击跳转&...
143
                        },
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
144
                        child: Row(children: <Widget>[
ca0d27b6   吴启风   feat:会员有效期增加点击跳转&...
145
146
147
148
149
150
151
                          Image(
                              width: 20.0.w,
                              height: 20.0.h,
                              image: AssetImage('ic_countdown'.assetPng)),
                          // 替换为你的图片资源路径
                          const SizedBox(width: 6.0),
                          // 图片和文本之间的间隔
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
152
153
                          UserUtil.hasPermission()
                              ? Text('还剩${UserUtil.getRemainingValidity()}天')
64501762   biao   修复 忘记密码时可以输入手机号
154
                              : const Text('未购买'),
ca0d27b6   吴启风   feat:会员有效期增加点击跳转&...
155
156
                        ]),
                      )),
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
157
158
159
160
161
162
                  ScreenUtil().bottomBarHeight.horizontalSpace,
                ],
              ));
        },
      );
    }
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
163
  
2d1ead53   吴启风   feat:背景音播放优化
164
    Future<void> onUserClick() async {
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
165
      if (UserUtil.isLogined()) {
2d1ead53   吴启风   feat:背景音播放优化
166
        await AudioPlayerUtil.getInstance().pause();
e6a08b82   biao   修复兑换之后回到首页不刷新问题;修...
167
168
169
170
171
172
173
174
175
176
177
        pushNamed(AppRouteName.user).then((value) {
          if (value != null) {
            if (callBack == null) {
            } else {
              callBack!(value);
            }
          }
        });
      } else {
        pushNamed(AppRouteName.login);
      }
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
178
179
    }
  }