Blame view

lib/pages/shopping/view.dart 5.47 KB
4224b3f8   吴启风   feat:支付详情页ui
1
2
3
4
5
6
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
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
164
165
166
167
168
169
170
171
  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';
  
  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 {
    const ShoppingPage({super.key});
  
    @override
    Widget build(BuildContext context) {
      return BlocProvider(
        create: (BuildContext context) =>
        ShoppingBloc()
          ..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(
                  imageUrl: "${bloc.productData?.url}",
                  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: [
              Text('套餐价格:${bloc.productData?.price ?? "199(记得删除)"}',
                  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),
                ),
              ),
            ],
          );
        },
      );