632 lines
21 KiB
Dart
632 lines
21 KiB
Dart
import 'dart:ui' as ui;
|
|
import 'package:aslan/chatvibe_ui/widgets/room/room_charm_page.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_core/constants/at_room_msg_type.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_room_utils.dart';
|
|
import 'package:aslan/chatvibe_ui/widgets/room/room_msg_item.dart';
|
|
import 'package:aslan/chatvibe_ui/widgets/room/redpack/room_redenvelope_config_page.dart';
|
|
import 'package:aslan/chatvibe_ui/widgets/room/switch_model/room_mic_switch_page.dart';
|
|
import 'package:aslan/main.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_pick_utils.dart';
|
|
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
|
|
import 'package:aslan/chatvibe_domain/models/res/join_room_res.dart';
|
|
import 'package:aslan/chatvibe_managers/rtc_manager.dart';
|
|
import 'package:aslan/chatvibe_managers/rtm_manager.dart';
|
|
import '../../../chatvibe_core/constants/at_global_config.dart';
|
|
import '../../../chatvibe_core/routes/at_fluro_navigator.dart';
|
|
import '../../../chatvibe_core/utilities/at_gift_vap_svga_manager.dart';
|
|
import '../../../chatvibe_data/models/enum/at_vip_type.dart';
|
|
import '../../../chatvibe_data/sources/local/data_persistence.dart';
|
|
import '../../../chatvibe_features/room/music/at_room_music_page.dart';
|
|
import '../../../chatvibe_features/store/store_route.dart';
|
|
import '../../components/at_debounce_widget.dart';
|
|
import '../../components/at_tts.dart';
|
|
import '../../components/text/at_text.dart';
|
|
|
|
class RoomMenuDialog extends StatefulWidget {
|
|
int roomMenuStime = 0;
|
|
Function(int eTime) callBack;
|
|
|
|
RoomMenuDialog(this.roomMenuStime, this.callBack);
|
|
|
|
@override
|
|
_RoomMenuDialogState createState() => _RoomMenuDialogState();
|
|
}
|
|
|
|
class _RoomMenuDialogState extends State<RoomMenuDialog> {
|
|
List<RoomMenu> items1 = [];
|
|
List<RoomMenu> items2 = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
items1.clear();
|
|
items1.add(
|
|
RoomMenu(
|
|
0,
|
|
ATAppLocalizations.of(context)!.music,
|
|
"at_icon_room_music_tag.png",
|
|
),
|
|
);
|
|
items1.add(
|
|
RoomMenu(
|
|
1,
|
|
ATAppLocalizations.of(context)!.redEnvelope,
|
|
"at_icon_room_redpack_tag.png",
|
|
),
|
|
);
|
|
items1.add(
|
|
RoomMenu(
|
|
4,
|
|
ATAppLocalizations.of(context)!.luckNumber,
|
|
"at_icon_luck_number_tag.png",
|
|
),
|
|
);
|
|
items1.add(
|
|
RoomMenu(2, ATAppLocalizations.of(context)!.dice, "at_icon_dice_tag.png"),
|
|
);
|
|
items1.add(
|
|
RoomMenu(3, ATAppLocalizations.of(context)!.rps, "at_icon_rps_tag.png"),
|
|
);
|
|
|
|
items2.clear();
|
|
if (Provider.of<RtcProvider>(context, listen: false).isFz()) {
|
|
items2.add(
|
|
RoomMenu(
|
|
0,
|
|
ATAppLocalizations.of(context)!.micManagement,
|
|
"at_icon_menu_mic_model_change.png",
|
|
),
|
|
);
|
|
}
|
|
|
|
items2.add(
|
|
RoomMenu(
|
|
1,
|
|
ATAppLocalizations.of(context)!.clearMessage,
|
|
"at_icon_room_msg_clear.png",
|
|
),
|
|
);
|
|
items2.add(
|
|
RoomMenu(
|
|
2,
|
|
ATAppLocalizations.of(context)!.picture,
|
|
"at_icon_room_msg_pic.png",
|
|
),
|
|
);
|
|
items2.add(
|
|
RoomMenu(
|
|
3,
|
|
ATAppLocalizations.of(context)!.shop,
|
|
"at_icon_room_menu_shop.png",
|
|
),
|
|
);
|
|
if (Provider.of<RtcProvider>(context, listen: false).isFz()) {
|
|
items2.add(
|
|
RoomMenu(
|
|
4,
|
|
ATAppLocalizations.of(context)!.charm,
|
|
"at_icon_room_charm.png",
|
|
),
|
|
);
|
|
}
|
|
|
|
items2.add(
|
|
RoomMenu(
|
|
5,
|
|
ATAppLocalizations.of(context)!.sound2,
|
|
"atu_icon_room_sound_open.png",
|
|
),
|
|
);
|
|
items2.add(
|
|
RoomMenu(
|
|
6,
|
|
ATAppLocalizations.of(context)!.giftEffect,
|
|
"at_icon_room_menu_gift_effect.png",
|
|
),
|
|
);
|
|
items2.add(
|
|
RoomMenu(
|
|
7,
|
|
ATAppLocalizations.of(context)!.winFloat,
|
|
"at_icon_room_menu_float_win.png",
|
|
),
|
|
);
|
|
items2.add(
|
|
RoomMenu(
|
|
8,
|
|
ATAppLocalizations.of(context)!.giftVibration,
|
|
"at_icon_room_menu_gift_vibration.png",
|
|
),
|
|
);
|
|
items2.add(
|
|
RoomMenu(
|
|
9,
|
|
ATAppLocalizations.of(context)!.entryVehicleAnimation,
|
|
"at_icon_room_menu_entry_vehicle_animation.png",
|
|
),
|
|
);
|
|
return SafeArea(
|
|
top: false,
|
|
child: Stack(
|
|
alignment: Alignment.topCenter,
|
|
children: [
|
|
Container(
|
|
height: 380.w,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xff262533),
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(12.w),
|
|
topRight: Radius.circular(12.w),
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: 15.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 20.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.entertainment,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.w),
|
|
GridView.builder(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
padding: EdgeInsets.only(bottom: 2.w),
|
|
shrinkWrap: true,
|
|
gridDelegate:
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4, // 每行3个项目
|
|
crossAxisSpacing: 2,
|
|
mainAxisSpacing: 2,
|
|
childAspectRatio: 1,
|
|
),
|
|
itemBuilder: (c, i) {
|
|
return _buildItem1(items1[i], i);
|
|
},
|
|
itemCount: items1.length,
|
|
),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 20.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.roomTools,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.w),
|
|
GridView.builder(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
padding: EdgeInsets.only(bottom: 2.w),
|
|
shrinkWrap: true,
|
|
gridDelegate:
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4, // 每行3个项目
|
|
crossAxisSpacing: 2,
|
|
mainAxisSpacing: 2,
|
|
childAspectRatio: 1,
|
|
),
|
|
itemBuilder: (c, i) {
|
|
return _buildItem2(items2[i], i);
|
|
},
|
|
itemCount: items2.length,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildItem1(RoomMenu item, int i) {
|
|
return GestureDetector(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/room/${item.icon}",
|
|
width: 45.w,
|
|
height: 45.w,
|
|
),
|
|
SizedBox(height: 10.w),
|
|
text(
|
|
item.title,
|
|
fontSize: 9.sp,
|
|
textColor: Colors.white54,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: 0.1,
|
|
maxLines: 2,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
onTap: () async {
|
|
if (item.id == 0) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
SmartDialog.show(
|
|
tag: "showRoomMusic",
|
|
alignment: Alignment.bottomCenter,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return ATRoomMusicPage();
|
|
},
|
|
);
|
|
} else if (item.id == 1) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
SmartDialog.show(
|
|
tag: "showRedEnvelopeConfig",
|
|
alignment: Alignment.center,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return RoomRedenvelopeConfigPage(1);
|
|
},
|
|
);
|
|
} else if (item.id == 2) {
|
|
int sTime = DateTime.now().millisecondsSinceEpoch;
|
|
if (sTime - widget.roomMenuStime < 3000) {
|
|
ATTts.show(
|
|
ATAppLocalizations.of(context)!.operationsAreTooFrequent,
|
|
);
|
|
return;
|
|
}
|
|
widget.callBack(sTime);
|
|
if (ATRoomUtils.touristCanMsg(context)) {
|
|
JoinRoomRes? room =
|
|
Provider.of<RtcProvider>(context, listen: false).currenRoom;
|
|
if (room != null) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
num indexOnMic = Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).userOnMaiInIndex(
|
|
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
|
|
);
|
|
Msg msg = Msg(
|
|
groupId: room.roomProfile?.roomProfile?.roomAccount ?? "",
|
|
msg: "${ATRoomUtils.collectRandomInt(1, 6)}",
|
|
type: ATRoomMsgType.roomDice,
|
|
number: indexOnMic,
|
|
user: AccountStorage().getCurrentUser()?.userProfile,
|
|
);
|
|
Provider.of<RtmProvider>(
|
|
context,
|
|
listen: false,
|
|
).sendMsg(msg, addLocal: true);
|
|
Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).starPlayEmoji(msg);
|
|
}
|
|
}
|
|
} else if (item.id == 3) {
|
|
int sTime = DateTime.now().millisecondsSinceEpoch;
|
|
if (sTime - widget.roomMenuStime < 3000) {
|
|
ATTts.show(
|
|
ATAppLocalizations.of(context)!.operationsAreTooFrequent,
|
|
);
|
|
return;
|
|
}
|
|
widget.callBack(sTime);
|
|
if (ATRoomUtils.touristCanMsg(context)) {
|
|
JoinRoomRes? room =
|
|
Provider.of<RtcProvider>(context, listen: false).currenRoom;
|
|
if (room != null) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
num indexOnMic = Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).userOnMaiInIndex(
|
|
UserManager().getCurrentUser()?.userProfile?.id ?? "",
|
|
);
|
|
Msg msg = Msg(
|
|
groupId: room.roomProfile?.roomProfile?.roomAccount ?? "",
|
|
msg: "${ATRoomUtils.collectRandomInt(1, 3)}",
|
|
type: ATRoomMsgType.roomRPS,
|
|
number: indexOnMic,
|
|
user: UserManager().getCurrentUser()?.userProfile,
|
|
);
|
|
Provider.of<RtmProvider>(
|
|
context,
|
|
listen: false,
|
|
).sendMsg(msg, addLocal: true);
|
|
Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).starPlayEmoji(msg);
|
|
}
|
|
}
|
|
} else if (item.id == 4) {
|
|
int sTime = DateTime.now().millisecondsSinceEpoch;
|
|
if (sTime - widget.roomMenuStime < 3000) {
|
|
ATTts.show(
|
|
ATAppLocalizations.of(context)!.operationsAreTooFrequent,
|
|
);
|
|
return;
|
|
}
|
|
widget.callBack(sTime);
|
|
if (ATRoomUtils.touristCanMsg(context)) {
|
|
JoinRoomRes? room =
|
|
Provider.of<RtcProvider>(context, listen: false).currenRoom;
|
|
if (room != null) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
Provider.of<RtmProvider>(context, listen: false).sendMsg(
|
|
Msg(
|
|
groupId: room.roomProfile?.roomProfile?.roomAccount ?? "",
|
|
msg: "${ATRoomUtils.collectRandomInt(0, 999)}",
|
|
type: ATRoomMsgType.roomLuckNumber,
|
|
user: UserManager().getCurrentUser()?.userProfile,
|
|
),
|
|
addLocal: true,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildItem2(RoomMenu item, int i) {
|
|
return ATDebounceWidget(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Stack(
|
|
alignment: AlignmentDirectional.center,
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/room/${item.icon}",
|
|
width: 45.w,
|
|
height: 45.w,
|
|
),
|
|
PositionedDirectional(
|
|
end: 0,
|
|
bottom: 0,
|
|
child: _buildSwitch(item),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 10.w),
|
|
text(
|
|
item.title,
|
|
fontSize: 9.sp,
|
|
textColor: Colors.white54,
|
|
fontWeight: FontWeight.w600,
|
|
lineHeight: 1.1,
|
|
letterSpacing: 0.1,
|
|
maxLines: 2,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
onTap: () async {
|
|
if (item.id == 0) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
SmartDialog.show(
|
|
tag: "showRoomMicSwitch",
|
|
alignment: Alignment.bottomCenter,
|
|
animationType: SmartAnimationType.fade,
|
|
debounce: true,
|
|
builder: (_) {
|
|
return RoomMicSwitchPage();
|
|
},
|
|
);
|
|
} else if (item.id == 1) {
|
|
Provider.of<RtmProvider>(context, listen: false).clearMessage();
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
} else if (item.id == 2) {
|
|
if (ATRoomUtils.touristCanMsg(context)) {
|
|
ATPickUtils.pickImageProcess(context, (bool success, String url) {
|
|
if (success) {
|
|
Provider.of<RtmProvider>(context, listen: false).sendMsg(
|
|
Msg(
|
|
groupId:
|
|
Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).currenRoom?.roomProfile?.roomProfile?.roomAccount,
|
|
msg: url,
|
|
type: ATRoomMsgType.image,
|
|
role:
|
|
Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).currenRoom?.entrants?.roles ??
|
|
"",
|
|
user: AccountStorage().getCurrentUser()?.userProfile,
|
|
),
|
|
addLocal: true,
|
|
);
|
|
}
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
}, neeCrop: false);
|
|
}
|
|
} else if (item.id == 3) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
ATNavigatorUtils.push(
|
|
navigatorKey.currentState!.context,
|
|
StoreRoute.list,
|
|
replace: false,
|
|
);
|
|
} else if (item.id == 4) {
|
|
SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
SmartDialog.show(
|
|
tag: "showRoomCharm",
|
|
alignment: Alignment.bottomCenter,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return RoomCharmPage();
|
|
},
|
|
);
|
|
} else if (item.id == 5) {
|
|
// SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
Provider.of<RealTimeCommunicationManager>(
|
|
context,
|
|
listen: false,
|
|
).muteAllRemote();
|
|
} else if (item.id == 6) {
|
|
// SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
setState(() {
|
|
ATGlobalConfig.isGiftSpecialEffects =
|
|
!ATGlobalConfig.isGiftSpecialEffects;
|
|
});
|
|
DataPersistence.setBool(
|
|
"${AccountStorage().getCurrentUser()?.userProfile?.account}-GiftSpecialEffects",
|
|
ATGlobalConfig.isGiftSpecialEffects,
|
|
);
|
|
if (!ATGlobalConfig.isGiftSpecialEffects) {
|
|
ATGiftVapSvgaManager().clearTasks();
|
|
}
|
|
} else if (item.id == 7) {
|
|
// SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
setState(() {
|
|
ATGlobalConfig.isFloatingAnimationInGlobal =
|
|
!ATGlobalConfig.isFloatingAnimationInGlobal;
|
|
});
|
|
DataPersistence.setBool(
|
|
"${AccountStorage().getCurrentUser()?.userProfile?.account}-FloatingAnimationInGlobal",
|
|
ATGlobalConfig.isFloatingAnimationInGlobal,
|
|
);
|
|
} else if (item.id == 8) {
|
|
// SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
setState(() {
|
|
ATGlobalConfig.isLuckGiftSpecialEffects =
|
|
!ATGlobalConfig.isLuckGiftSpecialEffects;
|
|
});
|
|
DataPersistence.setBool(
|
|
"${AccountStorage().getCurrentUser()?.userProfile?.account}-LuckGiftSpecialEffects",
|
|
ATGlobalConfig.isLuckGiftSpecialEffects,
|
|
);
|
|
if (!ATGlobalConfig.isLuckGiftSpecialEffects) {
|
|
ATGiftVapSvgaManager().clearTasks();
|
|
Provider.of<RtmProvider>(
|
|
context,
|
|
listen: false,
|
|
).cleanLuckGiftBackCoins();
|
|
}
|
|
} else if (item.id == 9) {
|
|
// SmartDialog.dismiss(tag: "showRoomMenuDialog");
|
|
var vip = AccountStorage().getCurrentUser()?.userProfile?.getVIP();
|
|
if (vip?.name == ATVIPType.MARQUIS.name ||
|
|
vip?.name == ATVIPType.DUKE.name ||
|
|
vip?.name == ATVIPType.KING.name ||
|
|
vip?.name == ATVIPType.EMPEROR.name) {
|
|
setState(() {
|
|
ATGlobalConfig.isEntryVehicleAnimation =
|
|
!ATGlobalConfig.isEntryVehicleAnimation;
|
|
});
|
|
DataPersistence.setBool(
|
|
"${AccountStorage().getCurrentUser()?.userProfile?.account}-EntryVehicleAnimation",
|
|
ATGlobalConfig.isEntryVehicleAnimation,
|
|
);
|
|
} else {
|
|
ATTts.show(
|
|
ATAppLocalizations.of(context)!.thisFeatureIsCurrentlyUnavailable,
|
|
);
|
|
}
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
_buildSwitch(RoomMenu item) {
|
|
if (item.id == 5) {
|
|
return Selector<RtcProvider, bool>(
|
|
selector: (c, p) => p.roomIsMute,
|
|
shouldRebuild: (prev, next) => prev != next,
|
|
builder: (_, isMute, __) {
|
|
return Transform.translate(
|
|
offset: Offset(3.w, 8.w),
|
|
child: Image.asset(
|
|
isMute
|
|
? "atu_images/general/at_icon_social_privilege_close.png"
|
|
: "atu_images/general/at_icon_social_privilege_open.png",
|
|
width: 20.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
} else if (item.id == 6) {
|
|
return Transform.translate(
|
|
offset: Offset(3.w, 8.w),
|
|
child: Image.asset(
|
|
ATGlobalConfig.isGiftSpecialEffects
|
|
? "atu_images/general/at_icon_social_privilege_open.png"
|
|
: "atu_images/general/at_icon_social_privilege_close.png",
|
|
width: 20.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
);
|
|
} else if (item.id == 7) {
|
|
return Transform.translate(
|
|
offset: Offset(3.w, 8.w),
|
|
child: Image.asset(
|
|
ATGlobalConfig.isFloatingAnimationInGlobal
|
|
? "atu_images/general/at_icon_social_privilege_open.png"
|
|
: "atu_images/general/at_icon_social_privilege_close.png",
|
|
width: 20.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
);
|
|
} else if (item.id == 8) {
|
|
return Transform.translate(
|
|
offset: Offset(3.w, 8.w),
|
|
child: Image.asset(
|
|
ATGlobalConfig.isLuckGiftSpecialEffects
|
|
? "atu_images/general/at_icon_social_privilege_open.png"
|
|
: "atu_images/general/at_icon_social_privilege_close.png",
|
|
width: 20.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
);
|
|
} else if (item.id == 9) {
|
|
return Transform.translate(
|
|
offset: Offset(3.w, 8.w),
|
|
child: Image.asset(
|
|
ATGlobalConfig.isEntryVehicleAnimation
|
|
? "atu_images/general/at_icon_social_privilege_open.png"
|
|
: "atu_images/general/at_icon_social_privilege_close.png",
|
|
width: 20.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
);
|
|
}
|
|
return Container();
|
|
}
|
|
}
|
|
|
|
class RoomMenu {
|
|
int id = 0;
|
|
|
|
String title = "";
|
|
String icon = "";
|
|
|
|
RoomMenu(this.id, this.title, this.icon);
|
|
}
|