| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import 'package:flutter/cupertino.dart';
- import '../../../resource/assets.gen.dart';
- import '../../../resource/colors.gen.dart';
- import '../../../widget/avatar/avatar_image_widget.dart';
- /// 亲密用户组件,包含2个头像和中间一个心形图标
- class IntimacyUserWidget extends StatelessWidget {
- /// 组件的宽度
- final double width;
- /// 组件的高度
- final double height;
- /// 头像的大小
- final double avatarSize;
- /// 头像的边框宽度
- final double avatarBorderWidth;
- /// 爱心的大小
- final double loveSize;
- /// 用户1的头像
- final String avatarUrl1;
- /// 用户2的头像
- final String avatarUrl2;
- const IntimacyUserWidget({
- super.key,
- required this.width,
- required this.height,
- required this.avatarSize,
- required this.avatarBorderWidth,
- required this.loveSize,
- required this.avatarUrl1,
- required this.avatarUrl2,
- });
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- width: width,
- height: height,
- child: Stack(
- // 默认内容都居中
- alignment: Alignment.center,
- children: [
- // 用户1
- Positioned(
- left: 0,
- child: _buildAvatar(
- avatarUrl1,
- defaultImage: Assets.images.iconDefaultAvatarMale.image().image,
- ),
- ),
- // 用户2
- Positioned(
- // 距离左侧的距离
- left: avatarSize - (avatarBorderWidth * 2),
- top: 0,
- child: _buildAvatar(
- avatarUrl2,
- defaultImage: Assets.images.iconDefaultAvatarFemale.image().image,
- ),
- ),
- // 爱心
- Positioned(
- child: Assets.images.iconIntimacyAnalyseLove.image(
- width: loveSize,
- height: loveSize,
- ),
- ),
- ],
- ),
- );
- }
- /// 圆形头像
- Widget _buildAvatar(String? imageUrl, {ImageProvider? defaultImage}) {
- return CircleAvatarWidget(
- imageUrl: imageUrl,
- placeholderImage: defaultImage,
- borderColor: ColorName.white,
- borderWidth: avatarBorderWidth,
- backgroundColor: ColorName.white,
- size: avatarSize,
- );
- }
- }
|