style(group): 优化群组信息页成员头像区布局,使其根据宽度自动充满每行空间以减少右侧空白

This commit is contained in:
Zeew 2025-08-19 14:10:09 +08:00
parent 5f677c5caa
commit 5972a3aa77
1 changed files with 133 additions and 96 deletions

View File

@ -50,12 +50,14 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
TUITheme theme, TUITheme theme,
TUIGroupProfileModel model, TUIGroupProfileModel model,
int showRange, int showRange,
double itemSize,
) { ) {
final isDesktopScreen = final isDesktopScreen =
TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop; TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
return _getMemberList(memberList, showRange).map((element) { return _getMemberList(memberList, showRange).map((element) {
final faceUrl = element?.faceUrl ?? ""; final faceUrl = element?.faceUrl ?? "";
final showName = _getShowName(element); final showName = _getShowName(element);
final double avatarBoxSize = isDesktopScreen ? itemSize : (itemSize - 10);
return InkWell( return InkWell(
onTapDown: (details) { onTapDown: (details) {
if (model.onClickUser != null && element?.userID != null) { if (model.onClickUser != null && element?.userID != null) {
@ -63,17 +65,17 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
} }
}, },
child: SizedBox( child: SizedBox(
width: isDesktopScreen ? 36 : 60, width: itemSize,
height: isDesktopScreen ? 36 : 76, height: isDesktopScreen ? itemSize : (avatarBoxSize + 26),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
width: isDesktopScreen ? 36 : 50, width: avatarBoxSize,
height: isDesktopScreen ? 36 : 50, height: avatarBoxSize,
child: Avatar( child: Avatar(
borderRadius: isDesktopScreen borderRadius: isDesktopScreen
? BorderRadius.circular(18) ? BorderRadius.circular(itemSize / 2)
: null, : null,
faceUrl: faceUrl, faceUrl: faceUrl,
showName: showName, showName: showName,
@ -158,6 +160,17 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
showRange--; showRange--;
} }
// n item
final double containerHorizontalPadding = 16.0; // Container
final double availableWidth =
MediaQuery.of(context).size.width - containerHorizontalPadding * 2;
final double spacingValue = isDesktopScreen ? 10.0 : 20.0; // Wrap
final double sizePre = isDesktopScreen ? 36.0 : 60.0; //
int n = ((availableWidth + spacingValue) / (sizePre + spacingValue)).floor();
if (n < 1) n = 1;
final double itemSize =
(availableWidth - spacingValue * (n - 1)) / n; //
return Container( return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
color: Colors.white, color: Colors.white,
@ -251,20 +264,32 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
// height: 90, // height: 90,
padding: const EdgeInsets.only(top: 12), padding: const EdgeInsets.only(top: 12),
child: Wrap( child: Wrap(
spacing: isDesktopScreen ? 10 : 20, spacing: spacingValue,
runSpacing: 10, runSpacing: 10,
alignment: WrapAlignment.start, alignment: WrapAlignment.start,
children: [ children: [
..._groupMemberListBuilder(memberList, theme, model, showRange), ..._groupMemberListBuilder(
memberList,
theme,
model,
showRange,
itemSize,
),
if (isCanInviteMember) if (isCanInviteMember)
DottedBorder( SizedBox(
width: itemSize,
child: Center(
child: DottedBorder(
borderType: BorderType.RRect, borderType: BorderType.RRect,
radius: Radius.circular(isDesktopScreen ? 18 : 4.5), radius: Radius.circular(
isDesktopScreen ? (itemSize / 2) : 4.5),
color: theme.weakTextColor!, color: theme.weakTextColor!,
dashPattern: const [6, 3], dashPattern: const [6, 3],
child: SizedBox( child: SizedBox(
width: isDesktopScreen ? 32 : 48, width:
height: isDesktopScreen ? 32 : 48, isDesktopScreen ? itemSize : (itemSize - 10),
height:
isDesktopScreen ? itemSize : (itemSize - 10),
child: IconButton( child: IconButton(
onPressed: () { onPressed: () {
if (onAddMemberPressed != null) { if (onAddMemberPressed != null) {
@ -273,13 +298,14 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
if (isDesktopScreen) { if (isDesktopScreen) {
TUIKitWidePopup.showPopupWindow( TUIKitWidePopup.showPopupWindow(
context: context, context: context,
operationKey: operationKey: TUIKitWideModalOperationKey
TUIKitWideModalOperationKey.addGroupMembers, .addGroupMembers,
width: 350, width: 350,
title: TIM_t("添加群成员"), title: TIM_t("添加群成员"),
height: 460, height: 460,
onSubmit: () { onSubmit: () {
addGroupMemberKey.currentState?.submitAdd(); addGroupMemberKey.currentState
?.submitAdd();
}, },
child: (onClose) => AddGroupMemberPage( child: (onClose) => AddGroupMemberPage(
model: model, model: model,
@ -291,27 +317,36 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) => AddGroupMemberPage(
AddGroupMemberPage(model: model), model: model),
), ),
); );
} }
} }
}, },
icon: Icon(Icons.add, size: isDesktopScreen ? 16 : 18), icon: Icon(Icons.add,
size: isDesktopScreen ? 16 : 18),
color: theme.weakTextColor, color: theme.weakTextColor,
), ),
), ),
), ),
),
),
if (isCanKickOffMember) if (isCanKickOffMember)
DottedBorder( SizedBox(
width: itemSize,
child: Center(
child: DottedBorder(
borderType: BorderType.RRect, borderType: BorderType.RRect,
radius: Radius.circular(isDesktopScreen ? 18 : 4.5), radius: Radius.circular(
isDesktopScreen ? (itemSize / 2) : 4.5),
color: theme.weakTextColor!, color: theme.weakTextColor!,
dashPattern: const [6, 3], dashPattern: const [6, 3],
child: SizedBox( child: SizedBox(
width: isDesktopScreen ? 32 : 48, width:
height: isDesktopScreen ? 32 : 48, isDesktopScreen ? itemSize : (itemSize - 10),
height:
isDesktopScreen ? itemSize : (itemSize - 10),
child: IconButton( child: IconButton(
onPressed: () { onPressed: () {
if (onRemoveMemberPressed != null) { if (onRemoveMemberPressed != null) {
@ -354,6 +389,8 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
), ),
), ),
), ),
),
),
], ],
), ),
), ),