You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

313 lines
11 KiB

4 years ago
import 'package:flutter/material.dart';
4 years ago
import 'package:huixiang/generated/l10n.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
3 years ago
import 'package:huixiang/retrofit/data/rank.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
3 years ago
import 'package:huixiang/view_widget/login_tips_dialog.dart';
3 years ago
import 'package:shared_preferences/shared_preferences.dart';
4 years ago
class MineVipView extends StatelessWidget {
3 years ago
int vipLevel;
int curLevel;
4 years ago
final int rankMax;
final int rank;
final String createTime;
3 years ago
final String tag;
4 years ago
final double padding;
3 years ago
final UserInfo userInfo;
final List<Rank> ranks;
4 years ago
3 years ago
MineVipView({
3 years ago
this.vipLevel = 1,
3 years ago
this.ranks,
this.tag = "",
this.userInfo,
4 years ago
this.padding = 16,
3 years ago
this.curLevel = 1,
4 years ago
this.rankMax = 0,
this.rank = 0,
this.createTime = "",
4 years ago
});
4 years ago
String topLeft = "";
String levelText = "";
4 years ago
@override
Widget build(BuildContext context) {
List<Color> linearColor = [
4 years ago
Color(0xFFD6F6F3),
Color(0xFF86BEBA),
];
4 years ago
Color levelColor = Color(0xFF558B87);
Color textColor = Colors.white;
4 years ago
3 years ago
if (userInfo != null &&
userInfo.memberRankVo != null &&
ranks != null &&
ranks.length > 0) {
3 years ago
curLevel = (ranks
.indexWhere((element) => element.id == userInfo.memberRankVo.id) +
3 years ago
1);
vipLevel = curLevel;
}
4 years ago
if (curLevel == vipLevel) {
4 years ago
topLeft = S.of(context).dangqiandengji;
3 years ago
} else if (vipLevel < curLevel) {
4 years ago
topLeft = S.of(context).shangyidengji;
4 years ago
} else {
4 years ago
topLeft = S.of(context).xiayidengji;
4 years ago
}
4 years ago
switch (vipLevel) {
case 1:
{
linearColor = [
Color(0xFFD6F6F3),
Color(0xFF86BEBA),
];
levelColor = Color(0xFF558B87);
4 years ago
levelText = "LV1 ${S.of(context).qingtonghuiyuan}";
4 years ago
break;
}
case 2:
{
linearColor = [
Color(0xFFF2F2F2),
Color(0xFFBEBEBE),
];
levelColor = Color(0xFF575757);
textColor = Color(0xFF575757);
4 years ago
levelText = "LV2 ${S.of(context).baiyinhuiyuan}";
4 years ago
break;
}
case 3:
{
linearColor = [
Color(0xFFFEF5DC),
Color(0xFFD1B97D),
];
levelColor = Color(0xFFAE9B6D);
4 years ago
levelText = "LV3 ${S.of(context).huangjinhuiyuan}";
4 years ago
break;
}
case 4:
{
linearColor = [
Color(0xFFEEEEEF),
Color(0xFFA999DB),
];
levelColor = Color(0xFF887CB4);
4 years ago
levelText = "LV4 ${S.of(context).zuanshihuiyuan}";
4 years ago
break;
}
4 years ago
case 5:
{
linearColor = [
Color(0xFFEEEEEF),
Color(0xFF000000),
];
levelColor = Color(0xFF000000);
4 years ago
levelText = "LV5 ${S.of(context).zhizunhuiyuan}";
4 years ago
break;
}
4 years ago
}
3 years ago
return GestureDetector(
onTap: () {
3 years ago
if (userInfo != null) {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
LoginTipsDialog().show(context);
return;
}
Navigator.of(context)
.pushNamed('/router/mine_vip_level_page', arguments: {
"rankLevel": curLevel,
"createTime": (userInfo != null) ? "${userInfo.createTime}" : "",
"points": (userInfo != null) ? int.tryParse(userInfo.points) : 0,
});
3 years ago
});
3 years ago
}
3 years ago
},
child: Hero(
tag: tag,
child: Container(
margin: EdgeInsets.fromLTRB(padding.w, 16.h, padding.w, 8.h),
width: MediaQuery.of(context).size.width - 32.w,
3 years ago
height: (MediaQuery.of(context).size.width - 32.w) /
1.78 *
AppUtils.textScale(context),
3 years ago
decoration: BoxDecoration(
gradient: LinearGradient(
colors: linearColor,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
3 years ago
),
3 years ago
child: Column(
3 years ago
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
3 years ago
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
3 years ago
crossAxisAlignment: CrossAxisAlignment.start,
3 years ago
children: [
Container(
3 years ago
height: 86.w,
3 years ago
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.fromLTRB(9.w, 4.h, 8.w, 4.h),
decoration: BoxDecoration(
color: levelColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomRight: Radius.circular(8),
),
),
child: Text(
topLeft,
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
4 years ago
),
3 years ago
Container(
margin: EdgeInsets.only(left: 13.w),
child: Text(
levelText,
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
fontSize: 23.sp,
),
),
4 years ago
),
3 years ago
],
3 years ago
),
3 years ago
),
Container(
margin: EdgeInsets.only(right: 11.w, bottom: 9.h),
child: Image.asset(
"assets/image/icon_mine_huixiang_logo.png",
width: 86.w,
3 years ago
height: 86.w,
3 years ago
fit: BoxFit.contain,
3 years ago
),
3 years ago
),
],
3 years ago
),
3 years ago
Expanded(
child: Container(
margin: EdgeInsets.only(
left: 13.w,
right: 12.w,
bottom: 12.h,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Text(
rank > rankMax
? S.of(context).dangqiandengji
: "${S.of(context).jifen_(rankMax - rank)} ${S.of(context).daoxiayidengji}",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: textColor,
fontWeight: FontWeight.w400,
fontSize: 14.sp,
),
3 years ago
),
3 years ago
flex: 1,
3 years ago
),
3 years ago
Text.rich(
TextSpan(
children: [
3 years ago
TextSpan(
3 years ago
text: "$rank",
3 years ago
style: TextStyle(
3 years ago
fontSize: 26.sp,
fontWeight: FontWeight.bold,
3 years ago
color: textColor,
),
),
3 years ago
if (rank <= rankMax)
TextSpan(
text: rankMax > 0 ? "/$rankMax" : "/0",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: textColor,
),
),
],
),
3 years ago
),
3 years ago
],
3 years ago
),
3 years ago
Container(
height: 8.h,
child: ClipRRect(
borderRadius: BorderRadius.circular(6.5),
child: LinearProgressIndicator(
value: rankMax > 0 ? rank / rankMax : 0,
backgroundColor: Colors.white,
color: levelColor,
3 years ago
),
),
3 years ago
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
S.of(context).kaitongriqi(
(createTime != null && createTime != "")
? createTime.split(" ")[0]
: "$createTime"),
style: TextStyle(
color: textColor,
fontWeight: FontWeight.w400,
fontSize: 12.sp,
),
),
Icon(
Icons.qr_code,
size: 24,
color: Colors.white,
),
],
),
],
),
3 years ago
),
3 years ago
flex: 1,
3 years ago
),
],
3 years ago
),
3 years ago
),
4 years ago
),
);
}
}