feat: 群组信息自定义

This commit is contained in:
2025-07-15 22:14:08 +08:00
parent a7149a29c3
commit e5d1225f7a
3 changed files with 244 additions and 128 deletions
@@ -20,8 +20,13 @@ import 'package:tencent_cloud_chat_uikit/theme/color.dart';
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
class GroupMemberTitle extends TIMUIKitStatelessWidget {
final VoidCallback? onAddMemberPressed;
final VoidCallback? onRemoveMemberPressed;
GroupMemberTitle({
Key? key,
this.onAddMemberPressed,
this.onRemoveMemberPressed,
}) : super(key: key);
List<V2TimGroupMemberFullInfo?> _getMemberList(memberList, int showRange) {
@@ -40,8 +45,14 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
return friendRemark != "" ? friendRemark : showName;
}
List<Widget> _groupMemberListBuilder(List memberList, TUITheme theme, TUIGroupProfileModel model, int showRange) {
final isDesktopScreen = TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
List<Widget> _groupMemberListBuilder(
List memberList,
TUITheme theme,
TUIGroupProfileModel model,
int showRange,
) {
final isDesktopScreen =
TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
return _getMemberList(memberList, showRange).map((element) {
final faceUrl = element?.faceUrl ?? "";
final showName = _getShowName(element);
@@ -61,22 +72,25 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
width: isDesktopScreen ? 36 : 50,
height: isDesktopScreen ? 36 : 50,
child: Avatar(
borderRadius: isDesktopScreen ? BorderRadius.circular(18) : null,
borderRadius: isDesktopScreen
? BorderRadius.circular(18)
: null,
faceUrl: faceUrl,
showName: showName,
type: 1,
),
),
if (!isDesktopScreen)
const SizedBox(
height: 8,
),
if (!isDesktopScreen) const SizedBox(height: 8),
if (!isDesktopScreen)
Text(
showName,
textAlign: TextAlign.center,
style: TextStyle(overflow: TextOverflow.ellipsis, color: theme.weakTextColor, fontSize: 10),
)
style: TextStyle(
overflow: TextOverflow.ellipsis,
color: theme.weakTextColor,
fontSize: 10,
),
),
],
),
),
@@ -84,35 +98,51 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
}).toList();
}
List<Widget> _inviteMemberBuilder(bool isCanInviteMember, bool isCanKickOffMember, theme, BuildContext context) {
List<Widget> _inviteMemberBuilder(
bool isCanInviteMember,
bool isCanKickOffMember,
theme,
BuildContext context,
) {
return [];
}
void navigateToMemberList(
BuildContext context, TUIGroupProfileModel model, List<V2TimGroupMemberFullInfo?> memberList) {
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
BuildContext context,
TUIGroupProfileModel model,
List<V2TimGroupMemberFullInfo?> memberList,
) {
final isDesktopScreen =
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
if (!isDesktopScreen) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GroupProfileMemberListPage(model: model, memberList: memberList),
));
context,
MaterialPageRoute(
builder: (context) =>
GroupProfileMemberListPage(model: model, memberList: memberList),
),
);
} else {
final option1 = memberList.length.toString();
TUIKitWidePopup.showPopupWindow(
operationKey: TUIKitWideModalOperationKey.groupMembersList,
context: context,
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height * 0.8,
title: TIM_t_para("群成员({{option1}}人)", "群成员($option1人)")(option1: option1),
child: (onClose) => GroupProfileMemberListPage(model: model, memberList: memberList));
operationKey: TUIKitWideModalOperationKey.groupMembersList,
context: context,
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height * 0.8,
title: TIM_t_para("群成员({{option1}}人)", "群成员($option1人)")(
option1: option1,
),
child: (onClose) =>
GroupProfileMemberListPage(model: model, memberList: memberList),
);
}
}
@override
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
final TUITheme theme = value.theme;
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
final isDesktopScreen =
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
final model = Provider.of<TUIGroupProfileModel>(context);
final memberAmount = model.groupInfo?.memberCount ?? 0;
final option1 = memberAmount.toString();
@@ -139,7 +169,14 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
decoration: isDesktopScreen
? null
: BoxDecoration(
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
border: Border(
bottom: BorderSide(
color:
theme.weakDividerColor ??
CommonColor.weakDividerColor,
),
),
),
child: InkWell(
onTap: () async {
navigateToMemberList(context, model, memberList);
@@ -147,19 +184,30 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(TIM_t("群成员"), style: TextStyle(color: theme.darkTextColor, fontSize: isDesktopScreen ? 14 : 16)),
Text(
TIM_t("群成员"),
style: TextStyle(
color: theme.darkTextColor,
fontSize: isDesktopScreen ? 14 : 16,
),
),
Row(
children: [
Text(
TIM_t_para("{{option1}}人", "$option1人")(option1: option1),
style: TextStyle(color: theme.darkTextColor, fontSize: isDesktopScreen ? 14 : 16),
TIM_t_para("{{option1}}人", "$option1人")(
option1: option1,
),
style: TextStyle(
color: theme.darkTextColor,
fontSize: isDesktopScreen ? 14 : 16,
),
),
Icon(
Icons.keyboard_arrow_right,
color: theme.weakTextColor,
),
],
)
),
],
),
),
@@ -171,25 +219,30 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
},
child: Container(
decoration: BoxDecoration(
border: Border.all(width: 1, color: theme.weakDividerColor ?? CommonColor.weakDividerColor),
border: Border.all(
width: 1,
color:
theme.weakDividerColor ?? CommonColor.weakDividerColor,
),
borderRadius: const BorderRadius.all(Radius.circular(4)),
),
// height: 30,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 6,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons.search,
color: hexToColor("979797"),
size: 16,
),
Icon(Icons.search, color: hexToColor("979797"), size: 16),
const SizedBox(width: 6),
Text(TIM_t("搜索"),
style: TextStyle(
color: theme.weakTextColor,
fontSize: 12,
)),
Text(
TIM_t("搜索"),
style: TextStyle(
color: theme.weakTextColor,
fontSize: 12,
),
),
],
),
),
@@ -205,67 +258,76 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
..._groupMemberListBuilder(memberList, theme, model, showRange),
if (isCanInviteMember)
DottedBorder(
borderType: BorderType.RRect,
radius: Radius.circular(isDesktopScreen ? 18 : 4.5),
color: theme.weakTextColor!,
dashPattern: const [6, 3],
child: SizedBox(
width: isDesktopScreen ? 32 : 48,
height: isDesktopScreen ? 32 : 48,
child: IconButton(
onPressed: () {
borderType: BorderType.RRect,
radius: Radius.circular(isDesktopScreen ? 18 : 4.5),
color: theme.weakTextColor!,
dashPattern: const [6, 3],
child: SizedBox(
width: isDesktopScreen ? 32 : 48,
height: isDesktopScreen ? 32 : 48,
child: IconButton(
onPressed: () {
if (onAddMemberPressed != null) {
onAddMemberPressed!();
} else {
if (isDesktopScreen) {
TUIKitWidePopup.showPopupWindow(
context: context,
operationKey: TUIKitWideModalOperationKey.addGroupMembers,
width: 350,
title: TIM_t("添加群成员"),
height: 460,
onSubmit: () {
addGroupMemberKey.currentState?.submitAdd();
},
child: (onClose) => AddGroupMemberPage(
model: model,
onClose: onClose,
key: addGroupMemberKey,
));
context: context,
operationKey:
TUIKitWideModalOperationKey.addGroupMembers,
width: 350,
title: TIM_t("添加群成员"),
height: 460,
onSubmit: () {
addGroupMemberKey.currentState?.submitAdd();
},
child: (onClose) => AddGroupMemberPage(
model: model,
onClose: onClose,
key: addGroupMemberKey,
),
);
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddGroupMemberPage(
model: model,
),
));
context,
MaterialPageRoute(
builder: (context) =>
AddGroupMemberPage(model: model),
),
);
}
},
icon: Icon(
Icons.add,
size: isDesktopScreen ? 16 : 18,
),
color: theme.weakTextColor,
),
)),
}
},
icon: Icon(Icons.add, size: isDesktopScreen ? 16 : 18),
color: theme.weakTextColor,
),
),
),
if (isCanKickOffMember)
DottedBorder(
borderType: BorderType.RRect,
radius: Radius.circular(isDesktopScreen ? 18 : 4.5),
color: theme.weakTextColor!,
dashPattern: const [6, 3],
child: SizedBox(
width: isDesktopScreen ? 32 : 48,
height: isDesktopScreen ? 32 : 48,
child: IconButton(
onPressed: () {
borderType: BorderType.RRect,
radius: Radius.circular(isDesktopScreen ? 18 : 4.5),
color: theme.weakTextColor!,
dashPattern: const [6, 3],
child: SizedBox(
width: isDesktopScreen ? 32 : 48,
height: isDesktopScreen ? 32 : 48,
child: IconButton(
onPressed: () {
if (onRemoveMemberPressed != null) {
onRemoveMemberPressed!();
} else {
if (isDesktopScreen) {
TUIKitWidePopup.showPopupWindow(
operationKey: TUIKitWideModalOperationKey.kickOffGroupMembers,
operationKey: TUIKitWideModalOperationKey
.kickOffGroupMembers,
context: context,
width: 350,
title: TIM_t("删除群成员"),
height: 460,
onSubmit: () {
deleteGroupMemberKey.currentState?.submitDelete();
deleteGroupMemberKey.currentState
?.submitDelete();
},
child: (onClose) => DeleteGroupMemberPage(
model: model,
@@ -275,19 +337,23 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
);
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DeleteGroupMemberPage(model: model),
));
context,
MaterialPageRoute(
builder: (context) =>
DeleteGroupMemberPage(model: model),
),
);
}
},
icon: Icon(
Icons.remove,
size: isDesktopScreen ? 16 : 18,
),
color: theme.weakTextColor,
}
},
icon: Icon(
Icons.remove,
size: isDesktopScreen ? 16 : 18,
),
)),
color: theme.weakTextColor,
),
),
),
],
),
),
@@ -298,7 +364,10 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
margin: EdgeInsets.only(top: isDesktopScreen ? 12 : 16),
child: Text(
TIM_t("查看更多群成员"),
style: TextStyle(color: theme.weakTextColor, fontSize: isDesktopScreen ? 12 : 14),
style: TextStyle(
color: theme.weakTextColor,
fontSize: isDesktopScreen ? 12 : 14,
),
),
),
onTap: () async {