import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/rank.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:shared_preferences/shared_preferences.dart'; class MineVipEntry extends StatelessWidget { int vipLevel; int curLevel; final int rankMax; final int rank; final String createTime; final String tag; final double padding; final UserInfo userInfo; final List ranks; MineVipEntry( {this.vipLevel = 1, this.ranks, this.tag, this.userInfo, this.padding = 16, this.curLevel = 1, this.rankMax = 0, this.rank = 0, this.createTime = ""}); String topLeft = ""; String levelText = "普通用户"; Color logoColor = Color(0xFFCACACA); Color levelTextColor = Color(0xFFCACACA); Color levelTextBackdrop = Color(0xFFFFF8EC); @override Widget build(BuildContext context) { if (userInfo != null && userInfo.memberRankVo != null && ranks != null && ranks.length > 0) { curLevel = (ranks.indexWhere((element) => element.id == userInfo.memberRankVo.id) + 1); vipLevel = curLevel; } if (curLevel == vipLevel) { topLeft = S.of(context).dangqiandengji; } else if (vipLevel < curLevel) { topLeft = S.of(context).shangyidengji; } else { topLeft = S.of(context).zanweikaitong; } switch (vipLevel) { case 1: { levelText = "${S.of(context).yinkahuiyuan}"; logoColor = Color(0xFFA0C4E7); levelTextColor = Color(0xFF61ABF3); levelTextBackdrop = Color(0xFFC1DBF4); break; } case 2: { levelText = "${S.of(context).jinkahuiyuan}"; logoColor = Color(0xFFFBB43A); levelTextColor = Color(0xFFFBB43A); levelTextBackdrop = Color(0xFFFFECD2); break; } case 3: { levelText = "${S.of(context).gongchuanghuiyuan}"; logoColor = Color(0xFF352822); levelTextColor = Color(0xFF92755D); levelTextBackdrop = Color(0xFFFFECD2); break; } } Widget widget = Container( height:20.h, width: double.infinity, child: Row( children: [ Container( height: double.infinity, padding: EdgeInsets.symmetric(horizontal:3.w,vertical:4.h), decoration: BoxDecoration( color: logoColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(4), bottomLeft: Radius.circular(4),), boxShadow: [ BoxShadow( color: Color(0x08213303).withAlpha(12), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ), ], ), child: Image.asset( "assets/image/mine_vip_logo.webp", fit: BoxFit.cover, // width: 13.w, // height: 11.h, ), ), Container( height: double.infinity, padding: EdgeInsets.symmetric(horizontal:3.w,vertical:3.h), decoration: BoxDecoration( color: levelTextBackdrop, borderRadius: BorderRadius.only( topRight: Radius.circular(4), bottomRight: Radius.circular(4),), boxShadow: [ BoxShadow( color: Color(0x08213303).withAlpha(12), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ), ], ), child:Row( children: [ Text( levelText, textAlign: TextAlign.center, style: TextStyle( color: levelTextColor, fontSize: 10.sp, fontWeight: MyFontWeight.regular, ), ), Image.asset( "assets/image/icon_right.webp", fit: BoxFit.cover, width: 8, height: 8, color: levelTextColor, ), ], ), ) ], ), ); // Container( // width: double.infinity, // padding: EdgeInsets.only(top: 12.h, bottom: 22.h, left: 12.w, right: 12.w), // margin: EdgeInsets.only(top: 23.h,left: 13.5.w,right: 13.5.w,bottom:15.h), // decoration: BoxDecoration( // color: Color(0xFF3D3D5D), // borderRadius: BorderRadius.circular(6), // boxShadow: [ // BoxShadow( // color: Colors.black.withAlpha(12), // offset: Offset(0, 3), // blurRadius: 14, // spreadRadius: 0, // ) // ], // ), // child: Column( // mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // Row( // children: [ // Image.asset( // "assets/image/vip_logo.webp", // width: 24, // height: 24, // ), // SizedBox( // width: 5.w, // ), // Expanded( // child: Text( // levelText, // style: TextStyle( // fontSize: 16.sp, // fontWeight: MyFontWeight.semi_bold, // color: Color(0xFFFFEAD2)), // )), // Container( // padding: EdgeInsets.fromLTRB(9.w, 4.h, 8.w, 4.h), // decoration: BoxDecoration( // color: Color(0xFFFFECD2), // borderRadius: BorderRadius.circular(10), // ), // child: Text( // S.of(context).chakanquanyi, // style: TextStyle( // fontSize: 12.sp, // fontWeight: MyFontWeight.semi_bold, // color: Color(0xFF92755D), // ), // ), // ) // ], // ), // SizedBox( // height: 16.h, // ), // Container( // height: 4.h, // child: ClipRRect( // borderRadius: BorderRadius.circular(6.5), // child: LinearProgressIndicator( // value: rankMax > (rank ?? 0) // ? ((vipLevel < curLevel) // ? rankMax / rankMax // : (rank ?? 0) / rankMax) // : 0, // backgroundColor: Color(0xFF222233), // color: Color(0xFFFFECD2), // ), // ), // ), // SizedBox( // height: 8.h, // ), // Text( // rank > rankMax // ? S.of(context).dangqiandengji // : "消费金额¥${rank.toStringAsFixed(2).toString()} 距${S.of(context).xiayidengji}还需¥${(rankMax - (rank ?? 0)).toStringAsFixed(2)}", // style: TextStyle( // color: Color(0xFFFFEAD2), // fontWeight: MyFontWeight.light, // fontFamily: 'JDZhengHT', // fontSize: 14.sp, // ), // ) // ], // )); return GestureDetector( onTap: () { 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, // }); Navigator.of(context) .pushNamed('/router/mine_vip_core', arguments: { "rankLevel": curLevel, "userInfo": userInfo.masterCardRankName, "createTime": (userInfo != null) ? "${userInfo.createTime}" : "", "expendAmount": double.tryParse(userInfo?.expendAmount ?? "0").toInt(), }); }); } }, child: widget, ); } }