feat: fav pgc page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-29 13:28:07 +08:00
parent 6ea8ffea7a
commit 72fa9c51f0
16 changed files with 884 additions and 216 deletions

View File

@@ -149,6 +149,9 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response.length - 1) {
_favNoteController.onLoadMore();
}
return FavNoteItem(
item: loadingState.response[index],
ctr: _favNoteController,

View File

@@ -1,8 +1,5 @@
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/note/child_view.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FavNotePage extends StatefulWidget {
const FavNotePage({super.key});
@@ -62,30 +59,30 @@ class _FavNotePageState extends State<FavNotePage>
],
),
),
TextButton(
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
visualDensity: VisualDensity(horizontal: -2, vertical: -2),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () async {
final favNoteController = Get.find<FavNoteController>(
tag: _tabController.index == 0 ? 'false' : 'true');
if (favNoteController.enableMultiSelect.value) {
favNoteController.onDisable();
} else {
if (favNoteController.loadingState.value is Success &&
((favNoteController.loadingState.value as Success)
.response as List?)
?.isNotEmpty ==
true) {
favNoteController.enableMultiSelect.value = true;
}
}
},
child: const Text('管理'),
),
const SizedBox(width: 12),
// TextButton(
// style: TextButton.styleFrom(
// foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
// visualDensity: VisualDensity(horizontal: -2, vertical: -2),
// tapTargetSize: MaterialTapTargetSize.shrinkWrap,
// ),
// onPressed: () async {
// final favNoteController = Get.find<FavNoteController>(
// tag: _tabController.index == 0 ? 'false' : 'true');
// if (favNoteController.enableMultiSelect.value) {
// favNoteController.onDisable();
// } else {
// if (favNoteController.loadingState.value is Success &&
// ((favNoteController.loadingState.value as Success)
// .response as List?)
// ?.isNotEmpty ==
// true) {
// favNoteController.enableMultiSelect.value = true;
// }
// }
// },
// child: const Text('管理'),
// ),
// const SizedBox(width: 12),
],
),
Expanded(

View File

@@ -18,123 +18,126 @@ class FavNoteItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
if (ctr.enableMultiSelect.value) {
onSelect();
return;
}
Utils.handleWebview(item['web_url'], inApp: true);
},
onLongPress: () {
if (!ctr.enableMultiSelect.value) {
ctr.enableMultiSelect.value = true;
onSelect();
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
item['title'],
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
height: 1.4,
fontSize: 14,
fontWeight: FontWeight.bold,
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
if (ctr.enableMultiSelect.value) {
onSelect();
return;
}
Utils.handleWebview(item['web_url'], inApp: true);
},
onLongPress: () {
if (!ctr.enableMultiSelect.value) {
ctr.enableMultiSelect.value = true;
onSelect();
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
item['title'],
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
height: 1.4,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
),
),
Text(
item['summary'],
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
Text(
item['summary'],
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
),
Text(
item['message'],
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
Text(
item['message'],
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
),
],
],
),
),
),
if (item['arc']?['pic'] != null) ...[
const SizedBox(width: 10),
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder:
(BuildContext context, BoxConstraints boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: item['arc']?['pic'],
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
),
Positioned.fill(
child: IgnorePointer(
child: LayoutBuilder(
builder: (context, constraints) =>
AnimatedOpacity(
opacity: item['checked'] == true ? 1 : 0,
duration: const Duration(milliseconds: 200),
child: Container(
alignment: Alignment.center,
height: constraints.maxHeight,
width: constraints.maxHeight *
StyleString.aspectRatio,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.black.withOpacity(0.6),
),
child: SizedBox(
width: 34,
height: 34,
child: AnimatedScale(
scale: item['checked'] == true ? 1 : 0,
duration:
const Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: IconButton(
tooltip: '取消选择',
style: ButtonStyle(
padding: WidgetStateProperty.all(
EdgeInsets.zero),
backgroundColor:
WidgetStateProperty.resolveWith(
(states) {
return Theme.of(context)
.colorScheme
.surface
.withOpacity(0.8);
},
if (item['arc']?['pic'] != null) ...[
const SizedBox(width: 10),
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder:
(BuildContext context, BoxConstraints boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: item['arc']?['pic'],
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
),
Positioned.fill(
child: IgnorePointer(
child: LayoutBuilder(
builder: (context, constraints) =>
AnimatedOpacity(
opacity: item['checked'] == true ? 1 : 0,
duration: const Duration(milliseconds: 200),
child: Container(
alignment: Alignment.center,
height: constraints.maxHeight,
width: constraints.maxHeight *
StyleString.aspectRatio,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.black.withOpacity(0.6),
),
child: SizedBox(
width: 34,
height: 34,
child: AnimatedScale(
scale: item['checked'] == true ? 1 : 0,
duration:
const Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: IconButton(
tooltip: '取消选择',
style: ButtonStyle(
padding: WidgetStateProperty.all(
EdgeInsets.zero),
backgroundColor:
WidgetStateProperty.resolveWith(
(states) {
return Theme.of(context)
.colorScheme
.surface
.withOpacity(0.8);
},
),
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color: Theme.of(context)
.colorScheme
.primary,
),
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color: Theme.of(context)
.colorScheme
.primary,
),
),
),
@@ -143,14 +146,14 @@ class FavNoteItem extends StatelessWidget {
),
),
),
),
],
);
},
],
);
},
),
),
),
],
],
],
),
),
),
);