2026-07-01 18:25:58 +08:00

905 lines
33 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:aslan/app_localizations.dart';
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
import 'package:aslan/chatvibe_ui/components/at_tts.dart';
import 'package:aslan/chatvibe_core/utilities/at_date_utils.dart';
import 'package:aslan/chatvibe_core/utilities/at_string_utils.dart';
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
import 'package:aslan/chatvibe_data/sources/repositories/store_repository_imp.dart';
import 'package:aslan/chatvibe_domain/models/res/vip_list_res.dart';
import 'package:aslan/chatvibe_managers/rtc_manager.dart';
import 'package:provider/provider.dart';
import 'package:aslan/chatvibe_core/constants/at_global_config.dart';
import 'package:aslan/chatvibe_ui/components/dialog/dialog_base.dart';
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart';
import 'package:aslan/chatvibe_managers/user_profile_manager.dart';
import '../../../chatvibe_data/models/enum/at_currency_type.dart';
import '../../../chatvibe_data/models/enum/at_props_type.dart';
class VipItemPage extends StatefulWidget {
VipListRes vip;
int index;
VipItemPage(this.vip, this.index);
@override
_VipItemPageState createState() => _VipItemPageState();
}
class _VipItemPageState extends State<VipItemPage>
with SingleTickerProviderStateMixin {
bool hasCurrentVip = false;
@override
void initState() {
super.initState();
var res = AccountStorage().getCurrentUser()?.userProfile?.getVIP();
if (res != null) {
if (res.id == widget.vip.propsResources?.id) {
hasCurrentVip = true;
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Column(
children: [
SizedBox(height: 20.w),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
width: 138.w,
height: 138.w,
ATGlobalConfig.businessLogicStrategy.getVipPageLargeIcon(
widget.index,
),
),
],
),
SizedBox(height: 20.w),
SizedBox(
width: ScreenUtil().screenWidth,
height: 100.w,
child: ListView.separated(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (context, i) => _buildPrivilegeItem2(i),
itemCount: 9,
padding: EdgeInsets.zero,
separatorBuilder: (context, i) => Container(width: 8.w),
),
),
SizedBox(height: 15.w),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
Stack(
alignment: Alignment.topCenter,
children: [
widget.index < 6
? Image.asset(
ATGlobalConfig.businessLogicStrategy
.getVipPageBackgroundImage(widget.index),
width: ScreenUtil().screenWidth * 0.95,
)
: Container(),
Padding(
padding: EdgeInsetsDirectional.symmetric(
horizontal: 15.w,
),
child: Column(
children: [
SizedBox(height: 42.w),
Row(
children: [
Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'badge',
),
ATAppLocalizations.of(context)!.vipBadge,
),
onTap: () {
_clickBadge();
},
),
),
Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'profile_frame',
),
ATAppLocalizations.of(
context,
)!.vipProfileFrame,
),
onTap: () {
_clickProfileFrame();
},
),
),
Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'profile_card',
),
ATAppLocalizations.of(
context,
)!.vipProfileCard,
),
onTap: () {
_clickProfileCard();
},
),
),
],
),
SizedBox(height: 15.w),
Row(
children: [
Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'mic_rippl',
),
ATAppLocalizations.of(
context,
)!.vipMicSoundWave,
),
onTap: () {
_clickRoomSeat();
},
),
),
Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'entrance_effect',
),
ATAppLocalizations.of(
context,
)!.vipEntranceEffect,
),
onTap: () {
_clickEntranceEffect();
},
),
),
Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'chatbox',
),
ATAppLocalizations.of(
context,
)!.vipChatBox,
),
onTap: () {
_clickChatBox();
},
),
),
],
),
SizedBox(height: 15.w),
Row(
children: [
Expanded(
child:
widget.index > 2
? Expanded(
child: GestureDetector(
child: _buildItem(
ATGlobalConfig
.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'special_gift_tassel',
),
ATAppLocalizations.of(
context,
)!.vipSpecialGiftTassel,
),
onTap: () {
_clickSpecialGiftTassel();
},
),
)
: Spacer(),
),
Expanded(
child:
widget.index > 2
? GestureDetector(
child: _buildItem(
ATGlobalConfig
.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'exclusive_vehicles',
),
ATAppLocalizations.of(
context,
)!.vipExclusiveVehicles,
),
onTap: () {
_clickExclusiveVehicles();
},
)
: Spacer(),
),
Expanded(
child:
widget.index > 3
? GestureDetector(
child: _buildItem(
ATGlobalConfig
.businessLogicStrategy
.getVipPageFeatureIcon(
widget.index,
'rippl_theme',
),
ATAppLocalizations.of(
context,
)!.vipRippleTheme,
),
onTap: () {
_clickRoomCoverBorder();
},
)
: Spacer(),
),
],
),
],
),
),
],
),
],
),
),
),
widget.index < 6
? Container(
height: 68.w,
padding: EdgeInsets.symmetric(horizontal: 15.w),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
ATGlobalConfig.businessLogicStrategy
.getVipPagePurchaseBackgroundImage(widget.index),
),
fit: BoxFit.fill,
),
),
child: Row(
children: [
Expanded(
child: Consumer<ChatVibeUserProfileManager>(
builder: (context, ref, child) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisSize:
hasCurrentVip
? MainAxisSize.max
: MainAxisSize.min,
children: [
Expanded(
child: text(
"${widget.vip.propsPrices?.first.amount}${ATAppLocalizations.of(context)!.coins}/${widget.vip.propsPrices?.first.days} ${ATAppLocalizations.of(context)!.days}",
fontSize: hasCurrentVip ? 13.sp : 15.sp,
fontWeight: FontWeight.bold,
maxLines: 2,
lineHeight: 1.0,
textColor: ATGlobalConfig
.businessLogicStrategy
.getVipPageTextColor(
widget.index,
true,
),
),
),
],
),
hasCurrentVip
? text(
maxLines: 2,
ATAppLocalizations.of(
context,
)!.yourVipWillExpire(
ATMDateUtils.formatDateTime3(
DateTime.fromMillisecondsSinceEpoch(
int.parse(
AccountStorage().getVIPExpireTime(),
),
),
),
),
fontSize: 12.sp,
lineHeight: 1.0,
fontWeight: FontWeight.bold,
textColor: ATGlobalConfig
.businessLogicStrategy
.getVipPageTextColor(
widget.index,
true,
),
)
: Container(),
],
);
},
),
),
GestureDetector(
child: Container(
margin: EdgeInsets.only(top: 2.w),
width: 115.w,
height: 38.w,
alignment: Alignment.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
ATGlobalConfig.businessLogicStrategy
.getVipPagePurchaseButtonImage(),
),
fit: BoxFit.fill,
),
),
child: text(
maxLines: 2,
textAlign: TextAlign.center,
hasCurrentVip
? ATAppLocalizations.of(context)!.renewVip
: ATAppLocalizations.of(context)!.buyVip,
fontWeight: FontWeight.bold,
lineHeight: 1.0,
fontSize: 12.sp,
textColor: Colors.white,
),
),
onTap: () {
SmartDialog.show(
tag: "showConfirmDialog",
alignment: Alignment.center,
debounce: true,
animationType: SmartAnimationType.fade,
builder: (_) {
return MsgDialog(
title: ATAppLocalizations.of(context)!.tips,
msg:
ATAppLocalizations.of(
context,
)!.confirmBuyTips,
btnText: ATAppLocalizations.of(context)!.confirm,
onEnsure: () {
_buy();
},
);
},
);
// if (hasCurrentVip) {
// ATTts.show(ATAppLocalizations.of(context)!.cantBuyVip);
// } else {
//
// }
},
),
],
),
)
: Container(),
],
),
);
}
Widget _buildItem(String icon, String tx) {
return Container(
height: 144.w,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: 101.w,
height: 101.w,
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
ATGlobalConfig.businessLogicStrategy
.getVipPageItemBackgroundImage(widget.index),
),
fit: BoxFit.fill,
),
),
child:
ATStringUtils.isUrl(icon)
? netImage(url: icon)
: Image.asset(icon, fit: BoxFit.contain),
),
SizedBox(height: 5.w),
SizedBox(
width: 100.w,
child: text(
textAlign: TextAlign.center,
tx,
lineHeight: 0.9,
maxLines: 3,
textColor: ATGlobalConfig.businessLogicStrategy
.getVipPageTextColor(widget.index, true),
fontSize: 13.sp,
fontWeight: FontWeight.w600,
),
),
],
),
);
}
_buildPrivilegeItem2(int index) {
String icon = "";
String tx = "";
bool isSelected = false;
if (index == 0) {
isSelected = true;
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
1,
isSelected,
);
tx =
"${widget.vip.nobleVipAbility?.loginRewardsAmount?.ceil()}${ATAppLocalizations.of(context)!.coins}/${ATAppLocalizations.of(context)!.day}";
} else if (index == 1) {
isSelected = true;
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
2,
isSelected,
);
tx = ATAppLocalizations.of(context)!.userColoredID;
} else if (index == 2) {
if (widget.index > 1) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
3,
widget.index > 1,
);
tx = ATAppLocalizations.of(context)!.userLevelXPBoost(
widget.index == 1
? "+0%"
: (widget.index == 2
? "+7%"
: (widget.index == 3
? "+10%"
: (widget.index == 4
? "+15%"
: widget.index == 5
? "+20%"
: "+25%"))),
);
} else if (index == 3) {
if (widget.index > 1) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
4,
isSelected,
);
tx = ATAppLocalizations.of(context)!.gifProfileUpload;
} else if (index == 4) {
if (widget.index > 2) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
5,
isSelected,
);
tx = ATAppLocalizations.of(context)!.dailyTaskRewardBonus(
widget.index == 1
? "+0%"
: (widget.index == 2
? "+7%"
: (widget.index == 3
? "+10%"
: (widget.index == 4
? "+15%"
: widget.index == 5
? "+20%"
: "+25%"))),
);
} else if (index == 5) {
if (widget.index > 2) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
6,
isSelected,
);
tx = ATAppLocalizations.of(context)!.membershipFreeChatSpeak;
} else if (index == 6) {
if (widget.index > 3) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
7,
isSelected,
);
tx = ATAppLocalizations.of(context)!.antiBlock;
} else if (index == 7) {
if (widget.index > 4) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
8,
isSelected,
);
tx = ATAppLocalizations.of(context)!.vipBirthdayGift;
} else if (index == 8) {
if (widget.index > 4) {
isSelected = true;
}
icon = ATGlobalConfig.businessLogicStrategy.getVipPagePrivilegeIcon(
widget.index,
9,
isSelected,
);
tx = ATAppLocalizations.of(context)!.kickPrevention;
}
return SizedBox(
height: 100.w,
child: Column(
children: [
Image.asset(icon, width: 60.w, height: 60.w, fit: BoxFit.contain),
SizedBox(height: 2.w),
SizedBox(
width: 110.w,
child: text(
textAlign: TextAlign.center,
tx,
lineHeight: 0.9,
maxLines: 3,
textColor: ATGlobalConfig.businessLogicStrategy
.getVipPageTextColor(widget.index, isSelected),
fontSize: 11.sp,
fontWeight: FontWeight.w600,
),
),
],
),
);
}
void _clickBadge() {
// SmartDialog.show(
// tag: "showBadge",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// width: ScreenUtil().screenWidth,
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'badge',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickProfileFrame() {
// SmartDialog.show(
// tag: "showProfileFrame",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'profile_frame',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickProfileCard() {
// SmartDialog.show(
// tag: "showProfileCard",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'profile_card',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickEntranceEffect() {
// SmartDialog.show(
// tag: "showEntranceEffect",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'entrance_effect',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickSpecialGiftTassel() {
// SmartDialog.show(
// tag: "showSpecialGiftTassel",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'special_gift_tassel',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickRoomCoverBorder() {
// SmartDialog.show(
// tag: "showRoomCoverBorder",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'room_cover_headdress',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickRoomSeat() {
// SmartDialog.show(
// tag: "showRoomSeat",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'mic_rippl_theme',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickChatBox() {
// SmartDialog.show(
// tag: "showChatBox",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'pre',
// 'chatbox',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _clickExclusiveVehicles() {
// SmartDialog.show(
// tag: "showExclusiveVehicles",
// alignment: Alignment.center,
// animationType: SmartAnimationType.fade,
// builder: (_) {
// return SafeArea(
// top: false,
// child: Container(
// height: 280.w,
// margin: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// ATGlobalConfig.businessLogicStrategy.getVipPagePreviewImage(
// widget.index,
// 'rev',
// 'exclusive_vehicles',
// ),
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// );
// },
// );
}
void _buy() {
ATLoadingManager.exhibitOperation(context: context);
StoreRepositoryImp()
.storePurchasing(
widget.vip.id ?? "",
ATPropsType.NOBLE_VIP.name,
ATCurrencyType.GOLD.name,
"${widget.vip.propsPrices?.first.days}",
)
.then((value) {
ATTts.show(ATAppLocalizations.of(context)!.operationSuccessful);
Provider.of<ChatVibeUserProfileManager>(
context,
listen: false,
).getMyUserInfo(needLoadUserCountGuard: false);
Provider.of<RtcProvider>(context, listen: false).needUpDataUserInfo =
true;
hasCurrentVip = true;
Provider.of<ChatVibeUserProfileManager>(
context,
listen: false,
).updateBalance(value);
setState(() {});
ATLoadingManager.veilRoutine();
})
.catchError((e) {
ATLoadingManager.veilRoutine();
});
}
}