feat:设置头像为默认圆形
This commit is contained in:
parent
69154d528d
commit
4cf3be0670
|
|
@ -20,7 +20,9 @@ class Avatar extends TIMUIKitStatelessWidget {
|
||||||
final V2TimUserStatus? onlineStatus;
|
final V2TimUserStatus? onlineStatus;
|
||||||
final int? type; // 1 c2c 2 group
|
final int? type; // 1 c2c 2 group
|
||||||
final bool isShowBigWhenClick;
|
final bool isShowBigWhenClick;
|
||||||
final TUISelfInfoViewModel selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
final bool isCircle; // 是否显示为圆形头像
|
||||||
|
final TUISelfInfoViewModel selfInfoViewModel =
|
||||||
|
serviceLocator<TUISelfInfoViewModel>();
|
||||||
|
|
||||||
Avatar(
|
Avatar(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
|
|
@ -30,6 +32,7 @@ class Avatar extends TIMUIKitStatelessWidget {
|
||||||
this.isShowBigWhenClick = false,
|
this.isShowBigWhenClick = false,
|
||||||
this.isFromLocalAsset = false,
|
this.isFromLocalAsset = false,
|
||||||
this.borderRadius,
|
this.borderRadius,
|
||||||
|
this.isCircle = true,
|
||||||
this.type = 1})
|
this.type = 1})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
|
@ -37,18 +40,24 @@ class Avatar extends TIMUIKitStatelessWidget {
|
||||||
Widget defaultAvatar() {
|
Widget defaultAvatar() {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
return Image.asset(
|
return Image.asset(
|
||||||
TencentUtils.checkString(selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
|
TencentUtils.checkString(
|
||||||
|
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
|
||||||
'images/default_c2c_head.png',
|
'images/default_c2c_head.png',
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
package:
|
package:
|
||||||
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null ? null : 'tencent_cloud_chat_uikit');
|
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null
|
||||||
|
? null
|
||||||
|
: 'tencent_cloud_chat_uikit');
|
||||||
} else {
|
} else {
|
||||||
return Image.asset(
|
return Image.asset(
|
||||||
TencentUtils.checkString(selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
|
TencentUtils.checkString(
|
||||||
|
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
|
||||||
'images/default_group_head.png',
|
'images/default_group_head.png',
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
package:
|
package:
|
||||||
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null ? null : 'tencent_cloud_chat_uikit');
|
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null
|
||||||
|
? null
|
||||||
|
: 'tencent_cloud_chat_uikit');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,19 +85,27 @@ class Avatar extends TIMUIKitStatelessWidget {
|
||||||
ImageProvider defaultAvatar() {
|
ImageProvider defaultAvatar() {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
return Image.asset(
|
return Image.asset(
|
||||||
TencentUtils.checkString(selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
|
TencentUtils.checkString(selfInfoViewModel
|
||||||
|
.globalConfig?.defaultAvatarAssetPath) ??
|
||||||
'images/default_c2c_head.png',
|
'images/default_c2c_head.png',
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
package:
|
package:
|
||||||
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null ? null : 'tencent_cloud_chat_uikit')
|
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath !=
|
||||||
|
null
|
||||||
|
? null
|
||||||
|
: 'tencent_cloud_chat_uikit')
|
||||||
.image;
|
.image;
|
||||||
} else {
|
} else {
|
||||||
return Image.asset(
|
return Image.asset(
|
||||||
TencentUtils.checkString(selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
|
TencentUtils.checkString(selfInfoViewModel
|
||||||
|
.globalConfig?.defaultAvatarAssetPath) ??
|
||||||
'images/default_group_head.png',
|
'images/default_group_head.png',
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
package:
|
package:
|
||||||
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null ? null : 'tencent_cloud_chat_uikit')
|
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath !=
|
||||||
|
null
|
||||||
|
? null
|
||||||
|
: 'tencent_cloud_chat_uikit')
|
||||||
.image;
|
.image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,6 +126,16 @@ class Avatar extends TIMUIKitStatelessWidget {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final TUITheme theme = value.theme;
|
final TUITheme theme = value.theme;
|
||||||
|
|
||||||
|
// 根据isCircle参数决定borderRadius
|
||||||
|
BorderRadius getAvatarBorderRadius() {
|
||||||
|
if (isCircle) {
|
||||||
|
return BorderRadius.circular(200); // 使用大圆角值来实现圆形效果
|
||||||
|
}
|
||||||
|
return borderRadius ??
|
||||||
|
selfInfoViewModel.globalConfig?.defaultAvatarBorderRadius ??
|
||||||
|
BorderRadius.circular(4.8);
|
||||||
|
}
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
|
|
@ -119,24 +146,22 @@ class Avatar extends TIMUIKitStatelessWidget {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
PageRouteBuilder(
|
PageRouteBuilder(
|
||||||
opaque: false, // set to false
|
opaque: false, // set to false
|
||||||
pageBuilder: (_, __, ___) => ImageScreen(imageProvider: getImageProvider(), heroTag: faceUrl),
|
pageBuilder: (_, __, ___) => ImageScreen(
|
||||||
|
imageProvider: getImageProvider(), heroTag: faceUrl),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Hero(
|
child: Hero(
|
||||||
tag: faceUrl,
|
tag: faceUrl,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: borderRadius ??
|
borderRadius: getAvatarBorderRadius(),
|
||||||
selfInfoViewModel.globalConfig?.defaultAvatarBorderRadius ??
|
|
||||||
BorderRadius.circular(4.8),
|
|
||||||
child: getImageWidget(context, theme),
|
child: getImageWidget(context, theme),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isShowBigWhenClick)
|
if (!isShowBigWhenClick)
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius:
|
borderRadius: getAvatarBorderRadius(),
|
||||||
borderRadius ?? selfInfoViewModel.globalConfig?.defaultAvatarBorderRadius ?? BorderRadius.circular(4.8),
|
|
||||||
child: getImageWidget(context, theme),
|
child: getImageWidget(context, theme),
|
||||||
),
|
),
|
||||||
if (onlineStatus?.statusType != null && onlineStatus?.statusType != 0)
|
if (onlineStatus?.statusType != null && onlineStatus?.statusType != 0)
|
||||||
|
|
|
||||||
1008
pubspec.lock
1008
pubspec.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue