573 lines
26 KiB
Dart
573 lines
26 KiB
Dart
|
||
import 'package:circle_app/app/invite/share.dart';
|
||
import 'package:circle_app/app/swiper/view.dart';
|
||
import 'package:circle_app/common/Widgets/rich_text.dart';
|
||
import 'package:circle_app/components/my_app_bar.dart';
|
||
import 'package:circle_app/util/util.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:flutter_swiper/flutter_swiper.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
import 'logic.dart';
|
||
|
||
class InvitePage extends StatelessWidget {
|
||
InvitePage({Key? key}) : super(key: key);
|
||
|
||
final logic = Get.find<InviteLogic>();
|
||
final state = Get
|
||
.find<InviteLogic>()
|
||
.state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Container(
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage(getBaseImage("home_back")),
|
||
fit: BoxFit.cover,
|
||
),
|
||
),
|
||
child: Scaffold(
|
||
backgroundColor: Colors.transparent,
|
||
appBar: MyAppBar(
|
||
centerTitle: "邀请得会员",
|
||
actionWdiget: Container(
|
||
alignment: Alignment.center,
|
||
height: 22.sp,
|
||
width: 62.sp,
|
||
child: Image.asset(getMineImage('invite_right_icon'),
|
||
),
|
||
),
|
||
onPressed: (){
|
||
navigateToInviteStrategy();
|
||
},
|
||
),
|
||
body: GetBuilder<InviteLogic>(builder: (logic) {
|
||
List<Widget> peopleCountList = [];
|
||
List<Widget> dayCountList = [];
|
||
List<TextSpan> allSpan = [];
|
||
if (logic.isLoad == false) {
|
||
logic.homeData!.inviteAwardConf!.forEach((element) {
|
||
peopleCountList.add(peopleCountWidget('${element!.inviteCount! ?? '0'}',(element!.inviteCount! ?? 0) <= logic.homeData!.inviteCount!));
|
||
|
||
if ((element.rewardDay! ?? 0) > 365) {
|
||
dayCountList.add(timeWidget('${(element.rewardDay! / 365).toInt()}年'));
|
||
} else {
|
||
dayCountList.add(timeWidget('${element.rewardDay!}天'));
|
||
}
|
||
// timeWidget(
|
||
// '+30天',
|
||
// ),
|
||
|
||
});
|
||
|
||
allSpan.addAll(getTextSpanList(
|
||
'Tip:您已成功邀请',
|
||
Color(0xFF0DF5F7),
|
||
12.sp,
|
||
searchContent: 'Tip:'));
|
||
allSpan.addAll(getTextSpanList(
|
||
' ${logic.homeData!.inviteCount! ?? 0} 位圈友,',
|
||
Color(0xFFDC5BFD),
|
||
12.sp,
|
||
searchContent: '${logic.homeData!.inviteCount! ?? 0}'));
|
||
allSpan.addAll(getTextSpanList(
|
||
'免费获得会员 ${logic.homeData!.achieveRewardDay! ?? '0'} 天,',
|
||
Color(0xFFDC5BFD),
|
||
12.sp,
|
||
searchContent: '${logic.homeData!.achieveRewardDay! ?? '0'} '));
|
||
int maxCount = logic.homeData!.inviteAwardConf!.last.inviteCount ?? 0;
|
||
if (logic.homeData!.inviteCount! >= maxCount) {
|
||
allSpan.addAll(getTextSpanList(
|
||
' 再邀请可领取更多奖励~',
|
||
Color(0xFFDC5BFD),
|
||
12.sp,
|
||
searchContent: ''));
|
||
} else {
|
||
allSpan.addAll(getTextSpanList(
|
||
' 再邀请 ${logic.homeData!.diffAwardCount} 位圈友可领取更多奖励~',
|
||
Color(0xFFDC5BFD),
|
||
12.sp,
|
||
searchContent: '${logic.homeData!.diffAwardCount}'));
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
return logic.isLoad ? loaddingWidget(true) : SingleChildScrollView(
|
||
child: Column(children: [
|
||
Container(
|
||
height: 203.sp,
|
||
margin: EdgeInsets.only(
|
||
left: 20.sp,
|
||
right: 20.sp,
|
||
top: 10.sp
|
||
),
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage(getCircleImage("pic_bg")),
|
||
fit: BoxFit.fill,
|
||
),
|
||
),
|
||
child: Column(
|
||
children: [
|
||
Container(
|
||
padding: EdgeInsets.only(
|
||
left: 14.sp, right: 14.sp, top: 24.sp),
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Text(
|
||
'我的专属邀请码',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w500),
|
||
),
|
||
GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: () {
|
||
showCodePicker(logic);
|
||
},
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
|
||
width: 84.sp,
|
||
|
||
child: Image.asset(getMineImage('add_code_icon')),
|
||
),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(top: 10.sp),
|
||
child: Row(
|
||
children: [
|
||
SizedBox(width: 20.sp,),
|
||
Text(
|
||
logic.homeData!.inviteCode! ?? '',
|
||
style: TextStyle(
|
||
fontSize: 30.sp,
|
||
fontWeight: FontWeight.w600,
|
||
color: Color(0xffF657FF)
|
||
),
|
||
),
|
||
SizedBox(
|
||
width: 4.sp,
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
Clipboard.setData(
|
||
ClipboardData(text: logic.homeData!.inviteCode! ?? ''));
|
||
showOKToast('复制成功');
|
||
},
|
||
child: Text(
|
||
'复制',
|
||
style: TextStyle(
|
||
color: Color(0xff0DF5F7),
|
||
fontSize: 14.sp),
|
||
)),
|
||
Expanded(child: Container())
|
||
],
|
||
),
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
shopSharePiker(logic.homeData!.inviteCode! ?? '',(logic.homeData!.link! ?? '') +
|
||
'?code=${logic.homeData!.inviteCode! ?? ''}');
|
||
},
|
||
child: Container(
|
||
width: 174.sp,
|
||
height: 42.sp,
|
||
margin: EdgeInsets.only(top: 35.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(21.sp),
|
||
gradient: const LinearGradient(
|
||
colors: [
|
||
Color(0xFF06F9FA),
|
||
Color(0xFFDC5BFD),
|
||
],
|
||
)),
|
||
alignment: Alignment.center,
|
||
child: Text(
|
||
'立即邀请',
|
||
style: TextStyle(
|
||
color: Color(0xFF000000),
|
||
fontSize: 16,
|
||
fontWeight: FontWeight.w600),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
Container(
|
||
height: 62.sp,
|
||
margin: EdgeInsets.only(
|
||
left: 20.sp, right: 20.sp, top: 15.sp),
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage(getMineImage("invite_sys_bg")),
|
||
fit: BoxFit.fill,
|
||
),
|
||
),
|
||
child: Swiper(
|
||
physics: NeverScrollableScrollPhysics(),
|
||
autoplay: true,
|
||
// controller: 5,
|
||
index: 0,
|
||
itemBuilder: (BuildContext context, int index) {
|
||
Map data = logic.sysData[index];
|
||
return Container(
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Text(
|
||
data['inviter_name'],
|
||
style: TextStyle(
|
||
color: Color(0xff0DF5F7),
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w500),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 5.sp, right: 5.sp),
|
||
child: Text(
|
||
'邀请',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w500),
|
||
)),
|
||
Text(
|
||
data['invitee_name'],
|
||
style: TextStyle(
|
||
color: Color(0xff0DF5F7),
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w500),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(left: 5.sp),
|
||
child: Text(
|
||
'加入微乐园',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w500),
|
||
)),
|
||
],
|
||
),
|
||
);
|
||
},
|
||
itemCount: logic.sysData.length,
|
||
),
|
||
),
|
||
Container(
|
||
height: 220.sp,
|
||
width: Get.width-30.sp,
|
||
margin:
|
||
EdgeInsets.only(top: 15.sp),
|
||
padding: EdgeInsets.only(top: 10.sp,bottom: 10.sp,left: 10.sp,right: 10.sp),
|
||
decoration: BoxDecoration(
|
||
image:DecorationImage(
|
||
image: AssetImage(getMineImage("invite_count_bg")),
|
||
fit: BoxFit.fill,
|
||
),
|
||
),
|
||
child: Column(
|
||
children: [
|
||
Container(
|
||
margin: EdgeInsets.only(top: 15.sp,left: 35.sp,right: 35.sp),
|
||
alignment: Alignment.center,
|
||
child: Image.asset(getMineImage('invite_title'),height: 22.sp,),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(top: 15.sp),
|
||
alignment: Alignment.center,
|
||
child: Image.asset(getMineImage('invite_line'),height: 1.2.sp,),
|
||
),
|
||
Container(
|
||
height: 70.sp,
|
||
margin: EdgeInsets.only(
|
||
left: 15.sp, right: 15.sp),
|
||
child: Row(
|
||
children: [
|
||
Text(
|
||
'邀请人数',
|
||
style: TextStyle(
|
||
color: Color(0xFF0DF5F7),
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500),
|
||
),
|
||
Expanded(
|
||
child: Stack(
|
||
// fit: StackFit.expand,
|
||
alignment: Alignment.center,
|
||
children: [
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 61.sp, right: 46.sp),
|
||
height: 2.sp,
|
||
color: Color(0xFF0DF5F7),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 15.sp),
|
||
child: Row(
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children:peopleCountList,
|
||
),
|
||
)
|
||
],
|
||
))
|
||
],
|
||
)),
|
||
Container(
|
||
height: 20.sp,
|
||
margin: EdgeInsets.only(
|
||
left: 15.sp, right: 15.sp),
|
||
child: Row(
|
||
children: [
|
||
Text(
|
||
'会员时长',
|
||
style: TextStyle(
|
||
color: Color(0xFF0DF5F7),
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500),
|
||
),
|
||
Expanded(
|
||
child: Stack(
|
||
// fit: StackFit.expand,
|
||
alignment: Alignment.center,
|
||
children: [
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 25.sp, right: 15.sp),
|
||
child: Row(
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.spaceBetween,
|
||
children: dayCountList
|
||
),
|
||
)
|
||
],
|
||
)),
|
||
],
|
||
)),
|
||
Expanded(child: Container()),
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 15.sp, right: 15.sp,bottom: 15.sp),
|
||
child: RichText(
|
||
text: TextSpan(
|
||
children: allSpan
|
||
)))
|
||
],
|
||
)),
|
||
SafeArea(
|
||
child: Container(
|
||
margin: EdgeInsets.only(top: 15.sp),
|
||
alignment: Alignment.center,
|
||
child: Image.asset(getMineImage('invite_vip_desc'),width: Get.width-30.sp,),
|
||
),
|
||
),
|
||
// Container(
|
||
// height: 203.sp,
|
||
// margin:
|
||
// EdgeInsets.only(left: 20.sp, right: 20.sp, top: 20.sp),
|
||
// decoration: BoxDecoration(
|
||
// borderRadius: BorderRadius.circular(10.sp),
|
||
// color: Color(0x1AFFFFFF),
|
||
// ),
|
||
// child: Column(children: [
|
||
// Expanded(
|
||
// child: ListView.builder(
|
||
// itemBuilder: (BuildContext context, int index) {
|
||
// return Container(
|
||
// margin: EdgeInsets.only(top: 10.sp),
|
||
// padding: EdgeInsets.only(left: 15.sp, right: 15.sp),
|
||
// child: Row(
|
||
// children: [
|
||
// ClipOval(
|
||
// child: Image.network(
|
||
// 'https://p26-passport.byteacctimg.com/img/user-avatar/b0541a2a377dd239a22eea2934709967~100x100.awebp',
|
||
// width: 40.sp,
|
||
// height: 40.sp,
|
||
// ),
|
||
// ),
|
||
// SizedBox(
|
||
// width: 4.sp,
|
||
// ),
|
||
// Column(
|
||
// children: [
|
||
// Text(
|
||
// '2222',
|
||
// style: TextStyle(
|
||
// color: Colors.white, fontSize: 14.sp),
|
||
// ),
|
||
// ],
|
||
// )
|
||
// ],
|
||
// ),
|
||
// );
|
||
// },
|
||
// itemCount: 5,
|
||
// ))
|
||
// ])),
|
||
]));
|
||
})));
|
||
}
|
||
|
||
peopleCountWidget(String count, bool isCheck) {
|
||
return Container(
|
||
width: 46.sp,
|
||
height: 46.sp,
|
||
alignment: Alignment.center,
|
||
decoration:
|
||
BoxDecoration(color: isCheck ? Color(0xFF0DF5F7) : Color(0xFF504261), shape: BoxShape.circle),
|
||
child: Text(
|
||
'$count人',
|
||
style: TextStyle(color:isCheck ? Color(0xFF000000) : Colors.white, fontSize: 12.sp),
|
||
),
|
||
);
|
||
}
|
||
|
||
timeWidget(String time) {
|
||
return Text(
|
||
time,
|
||
style: TextStyle(color: Colors.white, fontSize: 12.sp),
|
||
);
|
||
}
|
||
|
||
void shopSharePiker(String code,String link) {
|
||
Get.bottomSheet(
|
||
Share(code,link), isScrollControlled: true,
|
||
enableDrag: false
|
||
);
|
||
}
|
||
}
|
||
|
||
void showCodePicker(InviteLogic logic) {
|
||
Get.bottomSheet(
|
||
GestureDetector(
|
||
onTap: () {
|
||
FocusManager.instance.primaryFocus?.unfocus();
|
||
},
|
||
child: Scaffold(
|
||
backgroundColor: Colors.transparent,
|
||
resizeToAvoidBottomInset: false,
|
||
body: Center(
|
||
child: Container(
|
||
height: 240.sp,
|
||
decoration: BoxDecoration(
|
||
color: Color(0xFF292247),
|
||
borderRadius: BorderRadius.circular(6.sp)),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Container(
|
||
margin: EdgeInsets.only(top: 20.sp, left: 20.sp),
|
||
child: Text(
|
||
'请输入邀请您加入APP的圈友的邀请码',
|
||
style: TextStyle(color: Colors.white, fontSize: 14.sp),
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(left: 20, right: 20.sp, top: 30.sp),
|
||
decoration: BoxDecoration(
|
||
color: Color(0x1AFFFFFF),
|
||
borderRadius: BorderRadius.circular(6.sp)),
|
||
alignment: Alignment.center,
|
||
child: TextField(
|
||
controller: logic.codeEditingController,
|
||
keyboardType: TextInputType.phone,
|
||
maxLength: 8,
|
||
textAlign: TextAlign.center,
|
||
style: TextStyle(color: Colors.white, fontSize: 16.sp),
|
||
decoration: InputDecoration(
|
||
hintText: '请输入邀请码',
|
||
hintStyle:
|
||
TextStyle(color: Colors.white70, fontSize: 16.sp),
|
||
border: InputBorder.none,
|
||
counterText: '',
|
||
contentPadding: EdgeInsets.only(left: 16.sp)),
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(top: 15.sp),
|
||
alignment: Alignment.center,
|
||
child: Text(
|
||
'为防止作弊,进入APP后请在1小时填写TA的邀请码',
|
||
style: TextStyle(color: Colors.white, fontSize: 12.sp),
|
||
),
|
||
),
|
||
Expanded(child: Container()),
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 40.sp, right: 40.sp, bottom: 20.sp),
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
GestureDetector(
|
||
onTap: () {
|
||
Get.back();
|
||
},
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
width: 114.sp,
|
||
height: 38.sp,
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(19.sp),
|
||
color: Color(0x1AFFFFFF)),
|
||
child: const Text(
|
||
'放弃对接',
|
||
style: TextStyle(
|
||
color: Colors.white, fontSize: 16),
|
||
),
|
||
),
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
if (logic.codeEditingController.text.isEmpty) {
|
||
showOKToast('请输入邀请码');
|
||
return;
|
||
}
|
||
Get.back();
|
||
logic.addCode(logic.codeEditingController.text);
|
||
},
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
width: 114.sp,
|
||
height: 38.sp,
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(19.sp),
|
||
gradient: const LinearGradient(
|
||
colors: [
|
||
Color(0xFF06F9FA),
|
||
Color(0xFFDC5BFD),
|
||
],
|
||
)),
|
||
child: const Text(
|
||
'确认对接',
|
||
style: TextStyle(
|
||
color: Colors.black, fontSize: 16),
|
||
),
|
||
),
|
||
)
|
||
],
|
||
),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
isScrollControlled: true,
|
||
enableDrag: false);
|
||
}
|