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")),
|
)));
|
}
|
}
|