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

539 lines
24 KiB
Dart

import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aslan/app_localizations.dart';
import 'package:aslan/chatvibe_ui/components/appbar/chatvibe_appbar.dart';
import 'package:aslan/chatvibe_ui/components/at_tts.dart';
import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart';
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
import 'package:aslan/chatvibe_data/sources/repositories/user_repository_impl.dart';
import 'package:aslan/chatvibe_ui/components/at_debounce_widget.dart';
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
import '../../../../chatvibe_core/utilities/at_user_utils.dart';
import '../../../../chatvibe_data/models/enum/at_vip_contact_mode_type.dart';
import '../../../../chatvibe_data/models/enum/at_vip_type.dart';
import '../../../../chatvibe_domain/models/res/at_user_vip_ability_res.dart';
class SocialPrivilegePage extends StatefulWidget {
@override
_SocialPrivilegePageState createState() => _SocialPrivilegePageState();
}
class _SocialPrivilegePageState extends State<SocialPrivilegePage> {
ATUserVipAbilityRes? res;
@override
void initState() {
super.initState();
_getUserVipAbility();
}
@override
Widget build(BuildContext context) {
return SafeArea(
top: false,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xff2D2B35), Color(0xff17161E)],
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
),
height: ScreenUtil().screenHeight * 0.6,
child: Column(
children: [
SizedBox(height: 10.w),
Row(
mainAxisSize: MainAxisSize.min,
children: [
text(
ATAppLocalizations.of(context)!.permissionSettings,
textColor: ChatVibeTheme.primaryLight,
fontWeight: FontWeight.w600,
fontSize: 16.sp,
),
AccountStorage().getVIP() != null
? text(
"(${ATAccountHelper.getVipLevel(AccountStorage().getVIP()?.name??"")})",
textColor: ChatVibeTheme.primaryLight,
fontWeight: FontWeight.w600,
fontSize: 16.sp,
)
: Container(),
],
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
Container(
alignment: AlignmentDirectional.bottomStart,
margin: EdgeInsetsDirectional.only(start: 15.w),
child: text(
ATAppLocalizations.of(context)!.contactUs,
textColor: Colors.white70,
fontSize: 15.sp,
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 3.w),
margin: EdgeInsets.symmetric(
vertical: 4.w,
horizontal: 15.w,
),
child: Column(
children: [
ATDebounceWidget(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
ATAppLocalizations.of(context)!.everyone,
textColor: Colors.white70,
fontSize: 13.sp,
),
text(
ATAppLocalizations.of(
context,
)!.basicPermissions,
textColor: Colors.white38,
fontSize: 11.sp,
),
],
),
Spacer(),
Image.asset(
res?.contactMode !=
ATVipContactModeType
.VIP2_ABOVE
.name &&
res?.contactMode !=
ATVipContactModeType
.VIP3_ABOVE
.name &&
res?.contactMode !=
ATVipContactModeType
.VIP4_ABOVE
.name &&
res?.contactMode !=
ATVipContactModeType
.VIP5_ABOVE
.name
? "atu_images/general/at_icon_social_privilege_select.png"
: "atu_images/general/at_icon_social_privilege_unselect.png",
width: 16.w,
height: 16.w,
),
],
),
onTap: () {
if (res?.contactMode !=
ATVipContactModeType.EVERYONE.name) {
_userVipAbilityUpdate(
contactMode:
ATVipContactModeType.EVERYONE.name,
);
}
},
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 3.w),
margin: EdgeInsets.symmetric(
vertical: 4.w,
horizontal: 15.w,
),
child: Column(
children: [
ATDebounceWidget(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
ATAppLocalizations.of(
context,
)!.andAboveUsers("VIP2"),
textColor: Colors.white70,
fontSize: 13.sp,
),
text(
ATAppLocalizations.of(
context,
)!.privileges("VIP2"),
textColor: Colors.white38,
fontSize: 11.sp,
),
],
),
Spacer(),
Image.asset(
res?.contactMode ==
ATVipContactModeType.VIP2_ABOVE.name
? "atu_images/general/at_icon_social_privilege_select.png"
: "atu_images/general/at_icon_social_privilege_unselect.png",
width: 16.w,
height: 16.w,
),
],
),
onTap: () {
if (AccountStorage().getVIP()?.name ==
ATVIPType.EARL.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.MARQUIS.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.DUKE.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.KING.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.EMPEROR.name) {
if (res?.contactMode !=
ATVipContactModeType.VIP2_ABOVE.name) {
_userVipAbilityUpdate(
contactMode:
ATVipContactModeType.VIP2_ABOVE.name,
);
}
} else {
ATTts.show(
ATAppLocalizations.of(
context,
)!.pleaseUpgradeYourVipLevel,
);
}
},
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 3.w),
margin: EdgeInsets.symmetric(
vertical: 4.w,
horizontal: 15.w,
),
child: Column(
children: [
ATDebounceWidget(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
ATAppLocalizations.of(
context,
)!.andAboveUsers("VIP3"),
textColor: Colors.white70,
fontSize: 13.sp,
),
text(
ATAppLocalizations.of(
context,
)!.privileges("VIP3"),
textColor: Colors.white38,
fontSize: 11.sp,
),
],
),
Spacer(),
Image.asset(
res?.contactMode ==
ATVipContactModeType.VIP3_ABOVE.name
? "atu_images/general/at_icon_social_privilege_select.png"
: "atu_images/general/at_icon_social_privilege_unselect.png",
width: 16.w,
height: 16.w,
),
],
),
onTap: () {
if (AccountStorage().getVIP()?.name ==
ATVIPType.MARQUIS.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.DUKE.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.KING.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.EMPEROR.name) {
if (res?.contactMode !=
ATVipContactModeType.VIP3_ABOVE.name) {
_userVipAbilityUpdate(
contactMode:
ATVipContactModeType.VIP3_ABOVE.name,
);
}
} else {
ATTts.show(
ATAppLocalizations.of(
context,
)!.pleaseUpgradeYourVipLevel,
);
}
},
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 3.w),
margin: EdgeInsets.symmetric(
vertical: 4.w,
horizontal: 15.w,
),
child: Column(
children: [
ATDebounceWidget(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
ATAppLocalizations.of(
context,
)!.andAboveUsers("VIP4"),
textColor: Colors.white70,
fontSize: 13.sp,
),
text(
ATAppLocalizations.of(
context,
)!.privileges("VIP4"),
textColor: Colors.white38,
fontSize: 11.sp,
),
],
),
Spacer(),
Image.asset(
res?.contactMode ==
ATVipContactModeType.VIP4_ABOVE.name
? "atu_images/general/at_icon_social_privilege_select.png"
: "atu_images/general/at_icon_social_privilege_unselect.png",
width: 16.w,
height: 16.w,
),
],
),
onTap: () {
if (AccountStorage().getVIP()?.name ==
ATVIPType.DUKE.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.KING.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.EMPEROR.name) {
if (res?.contactMode !=
ATVipContactModeType.VIP4_ABOVE.name) {
_userVipAbilityUpdate(
contactMode:
ATVipContactModeType.VIP4_ABOVE.name,
);
}
} else {
ATTts.show(
ATAppLocalizations.of(
context,
)!.pleaseUpgradeYourVipLevel,
);
}
},
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 3.w),
margin: EdgeInsets.symmetric(
vertical: 4.w,
horizontal: 15.w,
),
child: Column(
children: [
ATDebounceWidget(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
ATAppLocalizations.of(
context,
)!.andAboveUsers("VIP5"),
textColor: Colors.white70,
fontSize: 13.sp,
),
text(
ATAppLocalizations.of(
context,
)!.privileges("VIP5"),
textColor: Colors.white38,
fontSize: 11.sp,
),
],
),
Spacer(),
Image.asset(
res?.contactMode ==
ATVipContactModeType.VIP5_ABOVE.name
? "atu_images/general/at_icon_social_privilege_select.png"
: "atu_images/general/at_icon_social_privilege_unselect.png",
width: 16.w,
height: 16.w,
),
],
),
onTap: () {
if (AccountStorage().getVIP()?.name ==
ATVIPType.KING.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.EMPEROR.name) {
if (res?.contactMode !=
ATVipContactModeType.VIP5_ABOVE.name) {
_userVipAbilityUpdate(
contactMode:
ATVipContactModeType.VIP5_ABOVE.name,
);
}
} else {
ATTts.show(
ATAppLocalizations.of(
context,
)!.pleaseUpgradeYourVipLevel,
);
}
},
),
],
),
),
SizedBox(height: 8.w),
Container(
alignment: AlignmentDirectional.bottomStart,
margin: EdgeInsetsDirectional.only(start: 15.w),
child: text(
ATAppLocalizations.of(context)!.vipPrivilege,
textColor: Colors.white70,
fontSize: 15.sp,
),
),
SizedBox(height: 8.w),
Container(
padding: EdgeInsets.symmetric(vertical: 3.w),
margin: EdgeInsets.symmetric(
vertical: 4.w,
horizontal: 15.w,
),
child: Column(
children: [
ATDebounceWidget(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
ATAppLocalizations.of(
context,
)!.avoidBeingKicked,
textColor: Colors.white70,
fontSize: 13.sp,
),
text(
ATAppLocalizations.of(
context,
)!.privileges("VIP5"),
textColor: Colors.white38,
fontSize: 11.sp,
),
],
),
Spacer(),
Image.asset(
res?.kickPrevention ?? false
? "atu_images/general/at_icon_social_privilege_open.png"
: "atu_images/general/at_icon_social_privilege_close.png",
width: 32.w,
height: 18.w,
),
],
),
onTap: () {
if (AccountStorage().getVIP()?.name ==
ATVIPType.KING.name ||
AccountStorage().getVIP()?.name ==
ATVIPType.EMPEROR.name) {
_userVipAbilityUpdate(
kickPrevention:
!(res?.kickPrevention ?? false),
);
} else {
ATTts.show(
ATAppLocalizations.of(
context,
)!.pleaseUpgradeYourVipLevel,
);
}
},
),
],
),
),
SizedBox(height: 12.w),
],
),
),
),
],
),
),
);
}
void _getUserVipAbility() {
ATLoadingManager.exhibitOperation();
AccountRepository()
.userVipAbility()
.then((value) {
ATLoadingManager.veilRoutine();
res = value;
setState(() {});
})
.catchError((_) {
ATLoadingManager.veilRoutine();
});
}
void _userVipAbilityUpdate({
String? contactMode,
bool? kickPrevention,
bool? mysteriousInvisibility,
bool? antiBlock,
}) {
ATLoadingManager.exhibitOperation();
AccountRepository()
.userVipAbilityUpdate(
contactMode: contactMode,
kickPrevention: kickPrevention,
mysteriousInvisibility: mysteriousInvisibility,
antiBlock: antiBlock,
)
.then((res) {
_getUserVipAbility();
})
.catchError((_) {
ATLoadingManager.veilRoutine();
});
}
}