feat: live search

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-06 20:31:09 +08:00
parent 867efecc54
commit 661e7bfa78
23 changed files with 835 additions and 68 deletions

View File

@@ -0,0 +1,114 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/image/image_save.dart';
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/models/live/live_search/room_item.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
// 视频卡片 - 垂直布局
class LiveCardVSearch extends StatelessWidget {
final LiveSearchRoomItemModel item;
const LiveCardVSearch({
super.key,
required this.item,
});
@override
Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(item.roomid);
return Card(
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.zero,
child: InkWell(
onTap: () {
Get.toNamed('/liveRoom?roomid=${item.roomid}');
},
onLongPress: () => imageSaveDialog(
title: item.title,
cover: item.cover,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
clipBehavior: Clip.none,
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
src: item.cover!,
width: maxWidth,
height: maxHeight,
),
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: AnimatedOpacity(
opacity: 1,
duration: const Duration(milliseconds: 200),
child: videoStat(context),
),
),
],
);
}),
),
Padding(
padding: const EdgeInsets.fromLTRB(5, 8, 5, 4),
child: Text(
'${item.title}',
textAlign: TextAlign.start,
style: const TextStyle(
letterSpacing: 0.3,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
);
}
Widget videoStat(context) {
return Container(
height: 50,
padding: const EdgeInsets.only(top: 26, left: 10, right: 10),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Colors.transparent,
Colors.black54,
],
tileMode: TileMode.mirror,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${item.name}',
style: const TextStyle(fontSize: 11, color: Colors.white),
),
if (item.watchedShow?.textSmall != null)
Text(
'${Utils.numFormat(item.watchedShow!.textSmall)}围观',
style: const TextStyle(fontSize: 11, color: Colors.white),
),
],
),
);
}
}

View File

@@ -0,0 +1,66 @@
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/models/live/live_search/user_item.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class LiveSearchUserItem extends StatelessWidget {
const LiveSearchUserItem({
super.key,
required this.item,
});
final LiveSearchUserItemModel item;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final style = TextStyle(
fontSize: 13,
color: theme.colorScheme.outline,
);
return InkWell(
onTap: () => Get.toNamed(
'/liveRoom?roomid=${item.roomid}',
),
child: Row(
children: [
const SizedBox(width: 15),
NetworkImgLayer(
src: item.face,
width: 42,
height: 42,
type: 'avatar',
),
const SizedBox(width: 10),
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
Text(
item.name!,
style: const TextStyle(
fontSize: 14,
),
),
if (item.liveStatus == 1) ...[
const SizedBox(width: 10),
Image.asset(height: 14, 'assets/images/live/live.gif'),
],
],
),
const SizedBox(height: 2),
Text(
'分区: ${item.areaName ?? ''} 关注数: ${Utils.numFormat(item.fansNum ?? 0)}',
style: style,
),
],
)
],
),
);
}
}