feat: 一键三连、视频页(取消)收藏

This commit is contained in:
guozhigq
2023-05-13 23:49:39 +08:00
parent 4d85eedd7b
commit 598a293a09
16 changed files with 449 additions and 270 deletions

View File

@ -122,43 +122,56 @@ class _MediaPageState extends State<MediaPage>
SizedBox(
width: double.infinity,
height: 170,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
const SizedBox(width: 20),
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data;
if (data['status']) {
return Obx(() => Row(
children: [
if (_mediaController.favFolderData.value.list !=
null) ...[
for (FavFolderItemData i in _mediaController
.favFolderData.value.list!) ...[
FavFolderItem(item: i),
const SizedBox(width: 14)
]
]
],
));
} else {
return SizedBox(
height: 160,
child: Center(child: Text(data['msg'])),
);
}
} else {
// 骨架屏
return SizedBox();
}
}),
// for (var i in [1, 2, 3]) ...[const FavFolderItem()],
const SizedBox(width: 10)
],
),
child: FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data;
if (data['status']) {
List favFolderList =
_mediaController.favFolderData.value.list!;
int favFolderCount =
_mediaController.favFolderData.value.count!;
bool flag = favFolderCount > favFolderList.length;
return Obx(() => ListView.builder(
itemCount: _mediaController
.favFolderData.value.list!.length +
(flag ? 1 : 0),
itemBuilder: (context, index) {
if (flag && index == favFolderList.length) {
return Padding(
padding: const EdgeInsets.only(
right: 14, bottom: 35),
child: Center(
child: IconButton(
onPressed: () => Get.toNamed('/fav'),
icon: Icon(
Icons.arrow_forward_ios,
size: 18,
color: Theme.of(context).primaryColor,
),
),
));
} else {
return FavFolderItem(
item: _mediaController
.favFolderData.value.list![index],
index: index);
}
},
scrollDirection: Axis.horizontal,
));
} else {
return SizedBox(
height: 160,
child: Center(child: Text(data['msg'])),
);
}
} else {
// 骨架屏
return SizedBox();
}
}),
),
],
);
@ -166,59 +179,63 @@ class _MediaPageState extends State<MediaPage>
}
class FavFolderItem extends StatelessWidget {
FavFolderItem({super.key, this.item});
FavFolderItem({super.key, this.item, this.index});
FavFolderItemData? item;
int? index;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Get.toNamed('/favDetail', arguments: item, parameters: {
'mediaId': item!.id.toString(),
}),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 12),
Container(
width: 180,
height: 110,
margin: const EdgeInsets.only(bottom: 8),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Theme.of(context).colorScheme.onInverseSurface,
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.onInverseSurface,
offset: const Offset(4, -12), // 阴影与容器的距离
blurRadius: 0.0, // 高斯的标准偏差与盒子的形状卷积。
spreadRadius: 0.0, // 在应用模糊之前,框应该膨胀的量。
),
],
return Container(
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: 14),
child: GestureDetector(
onTap: () => Get.toNamed('/favDetail', arguments: item, parameters: {
'mediaId': item!.id.toString(),
}),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 12),
Container(
width: 180,
height: 110,
margin: const EdgeInsets.only(bottom: 8),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Theme.of(context).colorScheme.onInverseSurface,
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.onInverseSurface,
offset: const Offset(4, -12), // 阴影与容器的距离
blurRadius: 0.0, // 高斯的标准偏差与盒子的形状卷积。
spreadRadius: 0.0, // 在应用模糊之前,框应该膨胀的量。
),
],
),
child: LayoutBuilder(
builder: (context, BoxConstraints box) {
return NetworkImgLayer(
src: item!.cover,
width: box.maxWidth,
height: box.maxHeight,
);
},
),
),
child: LayoutBuilder(
builder: (context, BoxConstraints box) {
return NetworkImgLayer(
src: item!.cover,
width: box.maxWidth,
height: box.maxHeight,
);
},
Text(
' ${item!.title}',
overflow: TextOverflow.fade,
maxLines: 1,
),
),
Text(
' ${item!.title}',
overflow: TextOverflow.fade,
maxLines: 1,
),
Text(
'${item!.mediaCount}条视频',
style: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(color: Theme.of(context).colorScheme.outline),
)
],
Text(
'${item!.mediaCount}条视频',
style: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(color: Theme.of(context).colorScheme.outline),
)
],
),
),
);
}