2026-07-10 20:31:52 +08:00

831 lines
43 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.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_managers/rtc_manager.dart';
import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.dart';
import 'package:provider/provider.dart';
import 'package:aslan/chatvibe_core/routes/at_fluro_navigator.dart';
import 'package:aslan/chatvibe_core/utilities/at_lk_dialog_util.dart';
import 'package:aslan/chatvibe_features/room/manager/room_member_page.dart';
import 'package:aslan/chatvibe_features/room/voice_room_route.dart';
import '../../../chatvibe_data/models/enum/at_room_roles_type.dart';
import '../../../chatvibe_data/sources/local/user_manager.dart';
import '../../../chatvibe_data/sources/repositories/room_repository_imp.dart';
import '../../../chatvibe_ui/components/at_compontent.dart';
import '../../../chatvibe_ui/components/at_debounce_widget.dart';
import '../../../chatvibe_ui/components/at_tts.dart';
import '../../../chatvibe_ui/components/dialog/dialog_base.dart';
import '../../../chatvibe_ui/components/text/at_text.dart';
import '../../../main.dart';
import '../../index/main_route.dart';
///房间详情
class RoomDetailPage extends StatefulWidget {
///是否是房主
final bool isHomeowner;
const RoomDetailPage(this.isHomeowner, {super.key});
@override
_RoomDetailPageState createState() => _RoomDetailPageState();
}
class _RoomDetailPageState extends State<RoomDetailPage> {
@override
void initState() {
super.initState();
Provider.of<RtcProvider>(context, listen: false).loadRoomInfo(
Provider.of<RtcProvider>(
context,
listen: false,
).currenRoom?.roomProfile?.roomProfile?.id ??
"",
);
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Consumer<RtcProvider>(
builder: (context, ref, child) {
return Container(
height: widget.isHomeowner ? 300.w : 400.w,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12.w),
topRight: Radius.circular(12.w),
),
),
child: Column(
children: [
SizedBox(height: 15.w),
text(
widget.isHomeowner
? ATAppLocalizations.of(context)!.roomSetting
: ATAppLocalizations.of(context)!.roomDetails,
fontSize: 14.sp,
textColor: Colors.black,
fontWeight: FontWeight.w600,
),
Expanded(
child: SingleChildScrollView(
child: Column(
spacing: 10.w,
children: [
SizedBox(height: 15.w),
GestureDetector(
child: Container(
decoration: BoxDecoration(
color: Color(0xffF2F2F2),
borderRadius: BorderRadius.circular(10.w),
),
margin: EdgeInsets.symmetric(horizontal: 15.w),
padding: EdgeInsets.all(15.w),
child: Row(
children: [
netImage(
url:
ref
.currenRoom
?.roomProfile
?.roomProfile
?.roomCover ??
"",
width: 48.w,
height: 48.w,
borderRadius: BorderRadius.all(
Radius.circular(8.w),
),
),
SizedBox(width: 8.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
constraints: BoxConstraints(
maxWidth:
ScreenUtil().screenWidth * 0.6,
),
child: text(
textColor: Colors.black,
ref
.currenRoom
?.roomProfile
?.roomProfile
?.roomName ??
"",
fontSize: 14.sp,
),
),
SizedBox(width: 3.w),
widget.isHomeowner
? Image.asset(
"atu_images/room/at_icon_room_edit.png",
width: 13.w,
height: 13.w,
)
: Container(),
],
),
SizedBox(height: 5.w),
Row(
children: [
text(
"ID:${ref.currenRoom?.roomProfile?.userProfile?.getID()}",
fontSize: 12.sp,
textColor: Colors.black,
),
SizedBox(width: 3.w),
GestureDetector(
child: Container(
padding: EdgeInsets.all(3.w),
child: Image.asset(
"atu_images/room/at_icon_user_card_copy_id.png",
width: 11.w,
height: 11.w,
color: Colors.black,
),
),
onTap: () {
Clipboard.setData(
ClipboardData(
text:
ref
.currenRoom
?.roomProfile
?.userProfile
?.getID() ??
"",
),
);
ATTts.show(
ATAppLocalizations.of(
context,
)!.copiedToClipboard,
);
},
),
],
),
],
),
],
),
),
onTap: () {
if (!widget.isHomeowner) {
return;
}
ATNavigatorUtils.push(
context,
"${VoiceRoomRoute.roomEdit}?need=false",
replace: false,
);
},
),
if (!widget.isHomeowner)
ATDebounceWidget(
child: Container(
decoration: BoxDecoration(
color: Color(0xffF2F2F2),
borderRadius: BorderRadius.circular(10.w),
),
margin: EdgeInsets.symmetric(horizontal: 15.w),
padding: EdgeInsets.all(15.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text(
"${ATAppLocalizations.of(context)!.roomOwner}:",
fontSize: 15.sp,
textColor: Colors.black,
),
SizedBox(height: 3.w),
Row(
children: [
netImage(
url:
ref
.currenRoom
?.roomProfile
?.userProfile
?.userAvatar ??
"",
shape: BoxShape.circle,
width: 40.w,
height: 40.w,
),
SizedBox(width: 10.w),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
chatvibeNickNameText(
maxWidth: 135.w,
textColor: Colors.black,
ref
.currenRoom
?.roomProfile
?.userProfile
?.userNickname ??
"",
fontSize: 14.sp,
fontWeight: FontWeight.w600,
type:
ref
.currenRoom
?.roomProfile
?.userProfile
?.getVIP()
?.name ??
"",
needScroll:
(ref
.currenRoom
?.roomProfile
?.userProfile
?.userNickname
?.characters
.length ??
0) >
13,
),
GestureDetector(
child: SizedBox(
child: Row(
children: [
getIdIcon(
ref.currenRoom?.roomProfile?.userProfile?.wealthLevel ?? 0,
width: 28.w,
height: 28.w,
textColor: Color(0xFF333333)
),
chatvibeNickNameText(
maxWidth: 135.w,
ref.currenRoom?.roomProfile?.userProfile?.getID() ?? "",
textColor: Color(0xFF333333),
fontSize: 12.sp,
fontWeight: FontWeight.w600,
type: ref.currenRoom?.roomProfile?.userProfile?.getVIP()?.name ?? "",
needScroll:
(ref.currenRoom?.roomProfile?.userProfile
?.getID()
.characters
.length ??
0) >
13,
),
],
),
),
onTap: () {
Clipboard.setData(
ClipboardData(text: ref.currenRoom?.roomProfile?.userProfile?.getID() ?? ""),
);
ATTts.show(
ATAppLocalizations.of(context)!.copiedToClipboard,
);
},
),
],
),
],
),
],
),
),
onTap: () {
ATNavigatorUtils.push(
context,
replace: false,
"${MainRoute.person}?isMe=${AccountStorage().getCurrentUser()?.userProfile?.id == ref.currenRoom?.roomProfile?.userProfile?.id}&tageId=${ref.currenRoom?.roomProfile?.userProfile?.id}",
);
},
),
ATDebounceWidget(
child: Container(
decoration: BoxDecoration(
color: Color(0xffF2F2F2),
borderRadius: BorderRadius.circular(10.w),
),
margin: EdgeInsets.symmetric(horizontal: 15.w),
padding: EdgeInsets.all(15.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
text(
textColor: Colors.black,
fontSize: 14.sp,
ATAppLocalizations.of(
context,
)!.roomAnnouncement,
),
Spacer(),
widget.isHomeowner
? Icon(
Icons.keyboard_arrow_right_sharp,
color: Colors.black,
size: 15.w,
)
: Container(),
],
),
Row(
children: [
Consumer<RtcProvider>(
builder: (context, ref, child) {
return Expanded(
child: text(
ref
.currenRoom
?.roomProfile
?.roomProfile
?.roomDesc ??
"",
fontSize: 13.sp,
maxLines: 2,
textColor: Color(0xffB1B1B1),
),
);
},
),
],
),
],
),
),
onTap: () {
if (!widget.isHomeowner) {
return;
}
ATNavigatorUtils.push(
context,
"${VoiceRoomRoute.roomEdit}?need=false",
replace: false,
);
},
),
widget.isHomeowner
? Row(
children: [
SizedBox(width: 15.w),
Expanded(
child: ATDebounceWidget(
child: Container(
height: 45.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
10.w,
),
color: Color(0xffF2F2F2),
),
child: Row(
children: [
SizedBox(width: 20.w),
text(
ATAppLocalizations.of(
context,
)!.roomMember,
textColor: Colors.black,
fontSize: 14.sp,
),
Spacer(),
Icon(
Icons.keyboard_arrow_right_sharp,
color: Colors.black,
size: 20.w,
),
SizedBox(width: 15.w),
],
),
),
onTap: () {
Navigator.of(context).pop();
showBottomInBottomDialog(
context,
RoomMemberPage(
roomId:
Provider.of<RtcProvider>(
context!,
listen: false,
)
.currenRoom
?.roomProfile
?.roomProfile
?.id ??
"",
isHomeowner: widget.isHomeowner,
),
);
},
),
),
SizedBox(width: 10.w),
Expanded(
child: ATDebounceWidget(
child: Container(
height: 45.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
10.w,
),
color: Color(0xffF2F2F2),
),
child: Row(
children: [
SizedBox(width: 20.w),
text(
ATAppLocalizations.of(
context,
)!.roomEdit,
textColor: Colors.black,
fontSize: 14.sp,
),
Spacer(),
Icon(
Icons.keyboard_arrow_right_sharp,
color: Colors.black,
size: 20.w,
),
SizedBox(width: 15.w),
],
),
),
onTap: () {
ATNavigatorUtils.push(
context,
"${VoiceRoomRoute.roomEdit}?need=false",
replace: false,
);
},
),
),
SizedBox(width: 15.w),
],
)
: Container(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 15.w,
children: [
ref.isTourists()
? ATDebounceWidget(
child: Container(
width: 160.w,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffFFD800),
Color(0xffFF9500),
],
),
borderRadius: BorderRadius.circular(
35.w,
),
),
height: 42.w,
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Image.asset(
"atu_images/room/at_icon_join_room_member.png",
height: 20.w,
width: 20.w,
),
SizedBox(width: 8.w),
text(
ref.isTourists()
? ATAppLocalizations.of(
context,
)!.join
: ATAppLocalizations.of(
context,
)!.giveUpIdentity,
textColor: Colors.white,
fontSize: 15.sp,
fontWeight: FontWeight.bold,
),
SizedBox(width: 3.w),
text(
"(${ref.currenRoom?.roomProfile?.roomSetting?.joinGolds ?? 0})",
textColor: Colors.white,
fontSize: 15.sp,
fontWeight: FontWeight.bold,
),
],
),
),
onTap: () {
SmartDialog.show(
tag: "showConfirmDialog",
alignment: Alignment.center,
debounce: true,
animationType: SmartAnimationType.fade,
builder: (_) {
return MsgDialog(
title:
ATAppLocalizations.of(
context,
)!.tips,
msg:
ref.isTourists()
? ATAppLocalizations.of(
context,
)!.joinMemberTips2
: ATAppLocalizations.of(
context,
)!.leaveRoomIdentityTips,
btnText:
ATAppLocalizations.of(
context,
)!.confirm,
onEnsure: () {
ChatRoomRepository()
.changeRoomRole(
ref
.currenRoom
?.roomProfile
?.roomProfile
?.id ??
"",
ref.isTourists()
? ATRoomRolesType
.ADMIN
.name
: ATRoomRolesType
.TOURIST
.name,
UserManager()
.getCurrentUser()
?.userProfile
?.id ??
"",
UserManager()
.getCurrentUser()
?.userProfile
?.id ??
"",
"ONESELF_JOIN",
)
.then((reslt) {
ref.currenRoom = ref
.currenRoom
?.copyWith(
entrants: ref
.currenRoom
?.entrants
?.copyWith(
roles:
ATRoomRolesType
.MEMBER
.name,
),
);
setState(() {});
ATTts.show(
ATAppLocalizations.of(
navigatorKey
.currentState!
.context,
)!.operationSuccessful,
);
});
},
);
},
);
},
)
: SizedBox.shrink(),
ref.currenRoom?.roomProfile?.roomProfile?.userId ==
UserManager()
.getCurrentUser()
?.userProfile
?.id
? SizedBox.shrink()
: Selector<RtcProvider, bool>(
selector:
(c, p) =>
p.isFollowRoomRes?.followRoom ??
false,
shouldRebuild: (prev, next) => prev != next,
builder: (_, follow, __) {
return ATDebounceWidget(
child: Container(
width: 160.w,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffFFD800),
Color(0xffFF9500),
],
),
borderRadius: BorderRadius.circular(
35.w,
),
),
height: 42.w,
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Row(
children: [
Image.asset(
!follow
? "atu_images/room/at_icon_follow_room_un.png"
: "atu_images/room/at_icon_follow_room_en.png",
width: 20.w,
height: 20.w,
),
SizedBox(width: 8.w),
text(
!follow
? ATAppLocalizations.of(
context,
)!.follow
: ATAppLocalizations.of(
context,
)!.following,
textColor: Colors.white,
fontSize: 15.sp,
fontWeight: FontWeight.bold,
),
],
),
],
),
),
onTap: () {
if (follow) {
SmartDialog.show(
tag: "unFollowDialog",
alignment: Alignment.center,
animationType:
SmartAnimationType.fade,
builder: (_) {
return Container(
width:
ScreenUtil().screenWidth *
0.75,
padding: EdgeInsets.symmetric(
horizontal: 10.w,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.all(
Radius.circular(12.w),
),
),
child: Column(
mainAxisSize:
MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment
.center,
children: [
SizedBox(height: 15.w),
text(
ATAppLocalizations.of(
context,
)!.unFollow,
fontSize: 16.sp,
textColor: Colors.black,
fontWeight:
FontWeight.bold,
),
SizedBox(height: 15.w),
text(
ATAppLocalizations.of(
context,
)!.sureUnfollowThisRoom,
fontWeight:
FontWeight.w600,
textColor: Colors.grey,
fontSize: 14.sp,
),
SizedBox(height: 15.w),
Row(
mainAxisSize:
MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment
.center,
children: [
GestureDetector(
behavior:
HitTestBehavior
.opaque,
onTap: () {
SmartDialog.dismiss(
tag:
"unFollowDialog",
);
},
child: Container(
alignment:
AlignmentDirectional
.center,
decoration:
BoxDecoration(
borderRadius:
BorderRadius.circular(
35.w,
),
color: Color(
0xffF2F2F2,
),
),
height: 35.w,
width: 95.w,
child: text(
ATAppLocalizations.of(
context,
)!.cancel,
textColor:
Colors.grey,
fontSize: 15.sp,
fontWeight:
FontWeight
.w600,
),
),
),
SizedBox(width: 18.w),
GestureDetector(
onTap: () {
ref.followRoom();
},
behavior:
HitTestBehavior
.opaque,
child: Container(
alignment:
AlignmentDirectional
.center,
decoration: BoxDecoration(
color:
ChatVibeTheme
.primaryLight,
borderRadius:
BorderRadius.circular(
35.w,
),
),
height: 35.w,
width: 95.w,
child: text(
ATAppLocalizations.of(
context,
)!.unFollow,
textColor:
Colors
.white,
fontSize: 15.sp,
fontWeight:
FontWeight
.w600,
),
),
),
],
),
SizedBox(height: 25.w),
],
),
);
},
);
} else {
ref.followRoom();
}
},
);
},
),
],
),
SizedBox(height: 10.w,)
],
),
),
),
],
),
);
},
),
);
}
}