Blame view

lib/pages/home/widgets/home_tab_header_widget.dart 3.82 KB
95edef4f   liangchengyou   feat:更新适配代码
1
  import 'package:flutter/material.dart';
2b55d503   liangchengyou   feat:添加插件
2
  import 'package:flutter_bloc/flutter_bloc.dart';
95edef4f   liangchengyou   feat:更新适配代码
3
  import 'package:flutter_screenutil/flutter_screenutil.dart';
2b55d503   liangchengyou   feat:添加插件
4
  import 'package:wow_english/common/blocs/cachebloc/cache_bloc.dart';
95edef4f   liangchengyou   feat:更新适配代码
5
6
  import 'package:wow_english/common/extension/string_extension.dart';
  
60e47f7c   liangchengyou   feat:课程选择功能
7
8
9
10
11
12
13
14
15
  enum HeaderActionType {
    //视频跟读
    video,
    //阶段选择
    phase,
    //磨耳朵
    listen,
    //购买
    shop,
d35a4e87   liangchengyou   feat:磨耳朵功能UI
16
    //个人信息
056970d8   Key   feat: api
17
    user
60e47f7c   liangchengyou   feat:课程选择功能
18
19
  }
  
95edef4f   liangchengyou   feat:更新适配代码
20
  class HomeTabHeaderWidget extends StatelessWidget {
c61b3c1a   Key   feat: toast_util....
21
    const HomeTabHeaderWidget({super.key, this.actionTap});
60e47f7c   liangchengyou   feat:课程选择功能
22
23
  
    final Function(HeaderActionType type)? actionTap;
95edef4f   liangchengyou   feat:更新适配代码
24
25
26
27
  
    @override
    Widget build(BuildContext context) {
      return Container(
7652f701   liangchengyou   feat:课程购买UI逻辑
28
        height: 45,
95edef4f   liangchengyou   feat:更新适配代码
29
30
31
32
33
        width: double.infinity,
        color: Colors.purple,
        padding: EdgeInsets.symmetric(horizontal: 9.5.w),
        child: Row(
          children: [
4bf67b91   liangchengyou   feat:设置密码
34
            ScreenUtil().bottomBarHeight.horizontalSpace,
d35a4e87   liangchengyou   feat:磨耳朵功能UI
35
            GestureDetector(
c61b3c1a   Key   feat: toast_util....
36
              onTap: () => actionTap?.call(HeaderActionType.user),
d35a4e87   liangchengyou   feat:磨耳朵功能UI
37
38
39
40
41
42
43
44
              child: Container(
                decoration: BoxDecoration(
                  border: Border.all(
                    width: 1.0,
                    color: const Color(0xFF140C10),
                  ),
                  borderRadius: BorderRadius.circular(21),
                ),
2b55d503   liangchengyou   feat:添加插件
45
                child: CircleAvatar(
d35a4e87   liangchengyou   feat:磨耳朵功能UI
46
47
                  radius: 21,
                  backgroundImage: NetworkImage(
c61b3c1a   Key   feat: toast_util....
48
49
                    context.read<CacheBloc>().userEntity?.avatarUrl ??
                        'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Faa1c2213-820a-4223-8757-5f8cee318a28%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1688713226&t=192b18a613683bcdc5bd76f65c9ff032',
d35a4e87   liangchengyou   feat:磨耳朵功能UI
50
51
                  ),
                ),
95edef4f   liangchengyou   feat:更新适配代码
52
53
              ),
            ),
d35a4e87   liangchengyou   feat:磨耳朵功能UI
54
55
            GestureDetector(
              onTap: () {
c61b3c1a   Key   feat: toast_util....
56
                if (actionTap != null) {
056970d8   Key   feat: api
57
                  actionTap!(HeaderActionType.user);
d35a4e87   liangchengyou   feat:磨耳朵功能UI
58
59
60
61
62
63
64
65
                }
              },
              child: Container(
                margin: const EdgeInsets.only(left: 7),
                padding: const EdgeInsets.all(4.0),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(2),
c61b3c1a   Key   feat: toast_util....
66
                  border: Border.all(width: 1.0, color: const Color(0xFF140C10), style: BorderStyle.solid),
d35a4e87   liangchengyou   feat:磨耳朵功能UI
67
                ),
c61b3c1a   Key   feat: toast_util....
68
69
70
                child: Text(
                  context.read<CacheBloc>().userEntity?.name ?? '',
                  style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp),
d35a4e87   liangchengyou   feat:磨耳朵功能UI
71
72
                ),
              ),
95edef4f   liangchengyou   feat:更新适配代码
73
74
75
            ),
            20.horizontalSpace,
            const Expanded(
c61b3c1a   Key   feat: toast_util....
76
77
78
79
80
                child: Text(
              'learn wow!yellow',
              textAlign: TextAlign.left,
              style: TextStyle(color: Colors.white, fontSize: 30.0),
            )),
95edef4f   liangchengyou   feat:更新适配代码
81
            IconButton(
c61b3c1a   Key   feat: toast_util....
82
83
                onPressed: () {
                  if (actionTap != null) {
60e47f7c   liangchengyou   feat:课程选择功能
84
85
86
                    actionTap!(HeaderActionType.video);
                  }
                },
c61b3c1a   Key   feat: toast_util....
87
                icon: Image.asset('video'.assetPng)),
95edef4f   liangchengyou   feat:更新适配代码
88
            IconButton(
c61b3c1a   Key   feat: toast_util....
89
90
                onPressed: () {
                  if (actionTap != null) {
60e47f7c   liangchengyou   feat:课程选择功能
91
92
93
                    actionTap!(HeaderActionType.phase);
                  }
                },
c61b3c1a   Key   feat: toast_util....
94
                icon: Image.asset('home'.assetPng)),
95edef4f   liangchengyou   feat:更新适配代码
95
            IconButton(
c61b3c1a   Key   feat: toast_util....
96
97
                onPressed: () {
                  if (actionTap != null) {
60e47f7c   liangchengyou   feat:课程选择功能
98
99
100
                    actionTap!(HeaderActionType.listen);
                  }
                },
c61b3c1a   Key   feat: toast_util....
101
                icon: Image.asset('listen'.assetPng)),
6f617434   liangchengyou   feat:磨耳朵/视频跟读列表页接口调整
102
103
104
105
106
107
108
109
            // IconButton(
            //     onPressed: (){
            //       if(actionTap != null) {
            //         actionTap!(HeaderActionType.shop);
            //       }
            //     },
            //     icon: Image.asset('shop'.assetPng)
            // ),
4bf67b91   liangchengyou   feat:设置密码
110
            ScreenUtil().bottomBarHeight.horizontalSpace,
95edef4f   liangchengyou   feat:更新适配代码
111
112
113
114
          ],
        ),
      );
    }
056970d8   Key   feat: api
115
  }