|
|
|
@ -59,7 +59,7 @@ class RoomItem extends StatelessWidget { |
|
|
|
} |
|
|
|
|
|
|
|
/// 处理点击事件 |
|
|
|
void _handleTap() { |
|
|
|
void _handleTap() async{ |
|
|
|
final channelId = _getChannelId(); |
|
|
|
if (channelId.isNotEmpty) { |
|
|
|
// 获取 RoomController 并加入频道 |
|
|
|
@ -68,11 +68,7 @@ class RoomItem extends StatelessWidget { |
|
|
|
: Get.put(RoomController()); |
|
|
|
|
|
|
|
// 加入频道并跳转 |
|
|
|
roomController.joinChannel(channelId).then((_) { |
|
|
|
Get.to(() => const LiveRoomPage(id: 0)); |
|
|
|
}).catchError((e) { |
|
|
|
print('❌ 加入直播间失败: $e'); |
|
|
|
}); |
|
|
|
await roomController.joinChannel(channelId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -95,7 +91,7 @@ class RoomItem extends StatelessWidget { |
|
|
|
child: Row( |
|
|
|
mainAxisAlignment: |
|
|
|
isSentByMe ? MainAxisAlignment.end : MainAxisAlignment.start, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
if (!isSentByMe) _buildAvatar(), |
|
|
|
if (!isSentByMe) SizedBox(width: 8.w), |
|
|
|
@ -113,8 +109,7 @@ class RoomItem extends StatelessWidget { |
|
|
|
GestureDetector( |
|
|
|
onTap: _handleTap, |
|
|
|
child: Container( |
|
|
|
constraints: BoxConstraints(maxWidth: 250.w), |
|
|
|
margin: EdgeInsets.only(top: 10.h), |
|
|
|
constraints: BoxConstraints(maxWidth: 150.w, maxHeight: 150.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.white, |
|
|
|
borderRadius: BorderRadius.circular(12.w), |
|
|
|
@ -135,8 +130,8 @@ class RoomItem extends StatelessWidget { |
|
|
|
Stack( |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
width: 250.w, |
|
|
|
height: 250.w, |
|
|
|
width: 150.w, |
|
|
|
height: 150.w, |
|
|
|
color: Colors.grey[200], |
|
|
|
child: anchorAvatar.isNotEmpty |
|
|
|
? CachedNetworkImage( |
|
|
|
@ -204,70 +199,73 @@ class RoomItem extends StatelessWidget { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
// 底部信息 |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.all(12.w), |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
// 头像 |
|
|
|
ClipRRect( |
|
|
|
borderRadius: BorderRadius.circular(12.w), |
|
|
|
child: Container( |
|
|
|
width: 24.w, |
|
|
|
height: 24.w, |
|
|
|
color: Colors.grey[300], |
|
|
|
child: anchorAvatar.isNotEmpty |
|
|
|
? CachedNetworkImage( |
|
|
|
imageUrl: anchorAvatar, |
|
|
|
width: 24.w, |
|
|
|
height: 24.w, |
|
|
|
fit: BoxFit.cover, |
|
|
|
placeholder: (context, url) => |
|
|
|
Container( |
|
|
|
color: Colors.grey[300], |
|
|
|
child: Center( |
|
|
|
child: SizedBox( |
|
|
|
width: 12.w, |
|
|
|
height: 12.w, |
|
|
|
child: CircularProgressIndicator( |
|
|
|
strokeWidth: 2, |
|
|
|
color: Colors.grey[600], |
|
|
|
Positioned( |
|
|
|
left: 8.w, |
|
|
|
bottom: 8.w, |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
// 头像 |
|
|
|
ClipRRect( |
|
|
|
borderRadius: BorderRadius.circular(12.w), |
|
|
|
child: Container( |
|
|
|
width: 24.w, |
|
|
|
height: 24.w, |
|
|
|
color: Colors.grey[300], |
|
|
|
child: anchorAvatar.isNotEmpty |
|
|
|
? CachedNetworkImage( |
|
|
|
imageUrl: anchorAvatar, |
|
|
|
width: 24.w, |
|
|
|
height: 24.w, |
|
|
|
fit: BoxFit.cover, |
|
|
|
placeholder: (context, url) => |
|
|
|
Container( |
|
|
|
color: Colors.grey[300], |
|
|
|
child: Center( |
|
|
|
child: SizedBox( |
|
|
|
width: 12.w, |
|
|
|
height: 12.w, |
|
|
|
child: CircularProgressIndicator( |
|
|
|
strokeWidth: 2, |
|
|
|
color: Colors.grey[600], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
errorWidget: (context, url, error) => |
|
|
|
Icon( |
|
|
|
Icons.person, |
|
|
|
size: 16.w, |
|
|
|
color: Colors.grey[600], |
|
|
|
), |
|
|
|
) |
|
|
|
: Icon( |
|
|
|
Icons.person, |
|
|
|
size: 16.w, |
|
|
|
color: Colors.grey[600], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 8.w), |
|
|
|
// 标题 |
|
|
|
Expanded( |
|
|
|
child: Text( |
|
|
|
anchorName, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 13.sp, |
|
|
|
color: Colors.black87, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
errorWidget: (context, url, error) => |
|
|
|
Icon( |
|
|
|
Icons.person, |
|
|
|
size: 16.w, |
|
|
|
color: Colors.grey[600], |
|
|
|
), |
|
|
|
) |
|
|
|
: Icon( |
|
|
|
Icons.person, |
|
|
|
size: 16.w, |
|
|
|
color: Colors.grey[600], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
maxLines: 1, |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
), |
|
|
|
SizedBox(width: 5.w), |
|
|
|
// 标题 |
|
|
|
Container( |
|
|
|
constraints: BoxConstraints( |
|
|
|
maxWidth: 100.w, |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
anchorName, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 11.sp, |
|
|
|
color: Colors.white, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
maxLines: 1, |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
) |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
|