admin
2022-05-05 355fe96b2a4c7821256d9e8828d2cb9539904878
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import 'dart:io';
import 'dart:ui';
 
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:makemoney/api/http.dart';
import 'package:makemoney/api/team_api.dart';
import 'package:makemoney/model/user/user_info.dart';
import 'package:makemoney/ui/widget/button.dart';
import 'package:makemoney/ui/widget/images_widget.dart';
import 'package:makemoney/ui/widget/verification_box.dart';
import 'package:makemoney/utils/ui_utils.dart';
import '../../utils/ui_constant.dart';
import '../../ui/widget/nav.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import '../../utils/pageutils.dart';
 
import 'advice_submit.dart';
import 'package:launch_review/launch_review.dart';
 
class AddTeamPage extends StatefulWidget {
  AddTeamPage({Key? key, required this.title, required this.skip})
      : super(key: key);
 
  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.
 
  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".
 
  final String title;
 
  final bool skip;
 
  @override
  _AddTeamPageState createState() => _AddTeamPageState();
}
 
class _AddTeamPageState extends State<AddTeamPage>
    with SingleTickerProviderStateMixin {
  final TextEditingController _controller = TextEditingController();
 
  @override
  void initState() {
    super.initState();
  }
 
  BoxDecoration getItemDecoration(Color bgColor, Color shadowColor) {
    return BoxDecoration(
        borderRadius: BorderRadius.all(Radius.elliptical(10, 10)),
        color: bgColor,
        boxShadow: [
          BoxShadow(
              color: shadowColor,
              blurRadius: 2.0,
              offset: Offset(0.0, 5.0), //阴影y轴偏移量
              spreadRadius: 1 //阴影扩散程度
              )
        ]);
  }
 
  double? itemWidth;
 
  @override
  Widget build(BuildContext context) {
    itemWidth = itemWidth ??
        (MediaQuery.of(context).size.width - 60 * 2 - 10 * 5 - 1) / 6;
 
    return Scaffold(
        resizeToAvoidBottomInset: true,
        backgroundColor: const Color(0xFFFFFFFF),
        body: Flex(
          direction: Axis.vertical,
          children: [
            TopNavBar(title: "加入团队"),
            Expanded(
                child: Container(
              decoration: const BoxDecoration(
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(13),
                      topRight: Radius.circular(13))),
              margin: const EdgeInsets.only(top: 10, left: 10, right: 10),
              padding: const EdgeInsets.fromLTRB(50, 35, 50, 30),
              child: Column(
                children: [
                  const Text.rich(
                    TextSpan(text: "填写好友的邀请码,即加入好友的团队,每转一圈可多获得", children: [
                      TextSpan(text: "10%", style: TextStyle(fontSize: 18)),
                      TextSpan(text: "金币。"),
                    ]),
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        fontSize: 13,
                        color: ColorConstant.theme,
                        fontWeight: FontWeight.bold),
                  ),
                  const SizedBox(
                    height: 40,
                  ),
                  Container(
                      alignment: Alignment.center,
                      child:
 
                          // VerificationBox(
                          //   6,
                          //   _controller,
                          //   width: MediaQuery.of(context).size.width - 60 * 2,
                          // )
                          PinCodeTextField(
                        appContext: context,
                        length: 6,
                        obscureText: false,
                        animationType: AnimationType.fade,
                        textStyle: const TextStyle(
                            color: ColorConstant.theme,
                            fontSize: 24,
                            fontWeight: FontWeight.bold),
                        cursorColor: ColorConstant.theme,
                        controller: _controller,
                        pinTheme: PinTheme(
                          activeColor: Colors.transparent,
                          selectedColor: Colors.transparent,
                          inactiveColor: Colors.transparent,
                          inactiveFillColor: const Color(0xFFEFEFEF),
                          activeFillColor: const Color(0xFFEFEFEF),
                          selectedFillColor: const Color(0xFFEFEFEF),
                          shape: PinCodeFieldShape.box,
                          borderRadius: BorderRadius.circular(13),
                          fieldHeight: itemWidth! * 1.25,
                          fieldWidth: itemWidth,
                          borderWidth: 0,
                        ),
                        animationDuration: const Duration(milliseconds: 100),
                        backgroundColor: Colors.transparent,
                        enableActiveFill: true,
                        onCompleted: (v) {
                          print("Completed");
                        },
                        onChanged: (value) {
                          print(value);
                          setState(() {
                            // currentText = value;
                          });
                        },
                        beforeTextPaste: (text) {
                          print("Allowing to paste $text");
                          //if you return true then it will show the paste confirmation dialog. Otherwise if false, then nothing will happen.
                          //but you can show anything you want here, like your pop up saying wrong paste format or etc
                          return true;
                        },
                      )),
                  const SizedBox(
                    height: 46,
                  ),
                  MyFillButton(
                    "确    定",
                    13,
                    height: 42,
                    fontSize: 15,
                    onClick: () {
                      if (_controller.text.length < 6) {
                        return;
                      }
                      TeamApiUtil.getUserByInviteCode(context, _controller.text)
                          .then((value) {
                        if (value == null) {
                          return;
                        }
                        if (value["code"] == 0) {
                          UserInfo boss = UserInfo.fromJson(value["data"]);
                          DialogUtil.showDialog(context, AddTeamDialog(boss));
                        } else {
                          ToastUtil.toast(value["msg"], context);
                        }
                      });
                    },
                  ),
                  Expanded(child: Container()),
                  widget.skip
                      ? InkWell(
                          onTap: () {
                            popPage(context);
                          },
                          child: Container(
                            height: 60,
                            width: 60,
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(60),
                                color: const Color(0xFFF5EBA4)),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                const Text(
                                  "跳过",
                                  style: TextStyle(
                                      fontSize: 15,
                                      color: Color(0xFFFF8316),
                                      height: 1),
                                ),
                                const SizedBox(
                                  height: 4,
                                ),
                                Image.asset(
                                  "assets/imgs/mine/icon_add_team_ignore.png",
                                  height: 11,
                                )
                              ],
                            ),
                          ))
                      : Container()
                ],
              ),
            ))
          ],
        ));
  }
}
 
class AddTeamDialog extends Dialog {
  BuildContext? context;
  final UserInfo user;
 
  AddTeamDialog(this.user);
 
  Offset? offset;
 
  @override
  Widget build(BuildContext context) {
    this.context = context;
    double width = MediaQuery.of(context).size.width;
    double dialogWidth = width * 4 / 5;
 
    //关闭弹框
    // Navigator.pop(context);
    return WillPopScope(
        onWillPop: () async {
          return false;
        },
        child: Material(
            type: MaterialType.transparency,
            child: Align(
                alignment: Alignment.center,
                child: Container(
                    width: dialogWidth,
                    height: 350,
                    child: Stack(children: [
                      Container(
                        margin: const EdgeInsets.only(top: 30, bottom: 110),
                        decoration: const BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(15)),
                            color: Colors.white),
                        alignment: Alignment.topCenter,
                      ),
                      Padding(
                          padding: const EdgeInsets.only(left: 10, right: 10),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              //-------头像--------
                              portraitWidget(),
                              //昵称
                              Text(
                                user.nickName!,
                                style: const TextStyle(
                                    color: Color(0xFF333333),
                                    fontSize: 13,
                                    fontWeight: FontWeight.bold),
                              ),
                              //内容
                              const SizedBox(
                                height: 15,
                              ),
                              const Text(
                                "加入好友的团队?",
                                style: TextStyle(
                                    color: ColorConstant.theme,
                                    fontSize: 18,
                                    fontWeight: FontWeight.bold),
                              ),
                              const SizedBox(
                                height: 35,
                              ),
                              //------按钮区域--------
                              MyFillButton(
                                "确    认",
                                10,
                                height: 42,
                                fontSize: 15,
                                onClick: () {
                                  TeamApiUtil.joinTeam(context, user.id!)
                                      .then((value) {
                                    if (value == null) {
                                      return;
                                    }
                                    if (value["code"] == 0) {
                                      ToastUtil.toast("加入成功", context);
                                      popPage(context);
                                      popPage(context);
                                    } else {
                                      ToastUtil.toast(value["msg"], context);
                                    }
                                  });
                                },
                              ),
                              const SizedBox(
                                height: 28,
                              ),
                              InkWell(
                                onTap: () {
                                  dismissDialog(context);
                                },
                                child: Image.asset(
                                  "assets/imgs/common/icon_dialog_close.png",
                                  height: 30,
                                ),
                              )
                            ],
                          ))
                    ])))));
  }
 
  Widget portraitWidget() {
    return InkWell(
        onTap: () {},
        child: Container(
            width: 90,
            height: 90,
            padding: const EdgeInsets.all(4),
            alignment: Alignment.center,
            decoration: BoxDecoration(
                color: Colors.white, borderRadius: BorderRadius.circular(50)),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(50),
              child: CommonImage(user.portrait!,
                  defaultWidget:
                      Image.asset("assets/imgs/ic_portrait_default.png")),
            )));
  }
}