Blame view

lib/pages/shopping/view.dart 5.59 KB
4224b3f8   吴启风   feat:支付详情页ui
1
2
3
4
5
  import 'package:cached_network_image/cached_network_image.dart';
  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';
07599105   吴启风   feat:商品列表请求&路由
6
  import 'package:wow_english/models/product_entity.dart';
4224b3f8   吴启风   feat:支付详情页ui
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  
  import '../../common/core/assets_const.dart';
  import '../../common/widgets/we_app_bar.dart';
  import '../../utils/image_util.dart';
  import 'bloc.dart';
  import 'event.dart';
  import 'state.dart';
  
  Widget buildRadioOption({
    required int value,
    required ImageProvider icon,
    required String text,
    required int groupValue,
    required ValueChanged onChanged,
  }) {
    return Row(
      children: [
        Image(image: icon,
            width: 20.0.w,
            height: 20.0.h,
            fit: BoxFit.contain),
        const SizedBox(width: 10.0),
        // Expanded(
        //   child: Text(
        //     text,
        //     style: TextStyle(color: Color(0xFF333333), fontSize: 12.5.sp),
        //   ),
        // ),
        Text(
          text,
          style: TextStyle(color: Color(0xFF333333), fontSize: 12.5.sp),
        ),
        Radio(
            value: value,
            groupValue: groupValue,
            onChanged: onChanged
        ),
      ],
    );
  }
  
  class ShoppingPage extends StatelessWidget {
07599105   吴启风   feat:商品列表请求&路由
49
50
51
    const ShoppingPage({super.key, this.productEntity});
  
    final ProductEntity? productEntity;
4224b3f8   吴启风   feat:支付详情页ui
52
53
54
55
56
  
    @override
    Widget build(BuildContext context) {
      return BlocProvider(
        create: (BuildContext context) =>
07599105   吴启风   feat:商品列表请求&路由
57
        ShoppingBloc(productEntity)
4224b3f8   吴启风   feat:支付详情页ui
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
          ..add(InitEvent()),
        child: _ShoppingView(),
      );
    }
  }
  
  class _ShoppingView extends StatelessWidget {
  
    @override
    Widget build(BuildContext context) {
      final bloc = BlocProvider.of<ShoppingBloc>(context);
      return BlocListener<ShoppingBloc, ShoppingState>(
        listener: (context, state) {
        },
        child: Scaffold(
          appBar: const WEAppBar(
            //标题传进来的
            titleText: '支付',
          ),
          body: Container(
            margin: const EdgeInsets.only(left: 80.0, top: 28.0, right: 56.0),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                CachedNetworkImage(
07599105   吴启风   feat:商品列表请求&路由
83
                  imageUrl: "${bloc.productData?.detailPicUrl}",
4224b3f8   吴启风   feat:支付详情页ui
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
                  imageBuilder: (context, imageProvider) =>
                      Container(
                        decoration: BoxDecoration(
                          image: DecorationImage(
                            image: imageProvider,
                            fit: BoxFit.cover,
                          ),
                          borderRadius: BorderRadius.circular(5.0),
                        ),
                      ),
                  placeholder: (context, url) =>
                  const CircularProgressIndicator(),
                  // errorWidget: (context, url, error) => const Icon(Icons.error),
                  height: 210.0.h,
                  width: 210.0.w,
                ),
                const SizedBox(width: 35.5),
                _paymentWidget(),
              ],
            ),
          ),
        ),);
    }
  }
  
  Widget _paymentWidget() =>
      BlocBuilder<ShoppingBloc, ShoppingState>
        (
        builder: (context, state) {
          final bloc = BlocProvider.of<ShoppingBloc>(context);
          return Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
07599105   吴启风   feat:商品列表请求&路由
117
              Text('套餐价格:${bloc.productData?.price ?? ''}',
4224b3f8   吴启风   feat:支付详情页ui
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
164
165
166
167
168
169
170
171
172
173
174
                  style: TextStyle(
                      color: const Color(0xFF333333), fontSize: 16.sp)),
              const SizedBox(height: 15.0),
              Text('套餐名称:${bloc.productData?.name ?? ''}',
                  style: TextStyle(
                      color: const Color(0xFF333333), fontSize: 16.sp)),
              const SizedBox(height: 15.0),
              Container(
                padding:
                EdgeInsets.symmetric(horizontal: 6.w, vertical: 10.h),
                decoration: BoxDecoration(
                    image: DecorationImage(
                        image: ImageUtil.getImageProviderOnDefault(
                            AssetsConst.bgUserInformationText),
                        fit: BoxFit.fill)),
                child: const Text('支付方式选择',
                    style: TextStyle(
                        color: Color(0xFF333333),
                        fontSize: 12,
                        fontFamily: 'PingFangSC-Regular')),
              ),
              const SizedBox(height: 15.0),
              buildRadioOption(
                value: PaymentChannel.wechatPay.payChannelType,
                icon: AssetImage('weixin'.assetPng),
                text: PaymentChannel.wechatPay.payChannelName,
                groupValue: bloc.curPaymentChannel.payChannelType,
                onChanged: (newValue) {
                  bloc.add(
                      ChangePaymentChannelEvent(PaymentChannel.wechatPay));
                },
              ),
              buildRadioOption(
                value: PaymentChannel.aliPay.payChannelType,
                icon: AssetImage('zhifubao'.assetPng),
                text: PaymentChannel.aliPay.payChannelName,
                groupValue: bloc.curPaymentChannel.payChannelType,
                onChanged: (newValue) {
                  bloc.add(
                      ChangePaymentChannelEvent(PaymentChannel.aliPay));
                },
              ),
              const SizedBox(height: 15.0),
              // 确认支付按钮
              InkWell(
                onTap: () {
                },
                child: Image(
                  width: 125.w,
                  height: 45.h,
                  image: AssetImage('btn_pay'.assetPng),
                ),
              ),
            ],
          );
        },
      );