feat: del note

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-29 09:52:53 +08:00
parent cc774015f9
commit 347420c531
7 changed files with 273 additions and 20 deletions

View File

@@ -1,6 +1,8 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart';
@@ -26,13 +28,95 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
@override
Widget build(BuildContext context) {
super.build(context);
return refreshIndicator(
onRefresh: () async {
await _favNoteController.onRefresh();
},
child: CustomScrollView(
slivers: [
Obx(() => _buildBody(_favNoteController.loadingState.value)),
return LayoutBuilder(
builder: (context, constraints) => Stack(
clipBehavior: Clip.none,
children: [
refreshIndicator(
onRefresh: () async {
await _favNoteController.onRefresh();
},
child: CustomScrollView(
slivers: [
Obx(() => _buildBody(_favNoteController.loadingState.value)),
],
),
),
Positioned(
top: constraints.maxHeight,
left: 0,
right: 0,
child: Obx(
() => AnimatedSlide(
offset: _favNoteController.enableMultiSelect.value
? Offset(0, -1)
: Offset.zero,
duration: const Duration(milliseconds: 150),
child: Container(
padding: MediaQuery.paddingOf(context),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onInverseSurface,
border: Border(
top: BorderSide(
width: 0.5,
color: Theme.of(context)
.colorScheme
.outline
.withOpacity(0.5),
),
),
),
width: double.infinity,
child: Row(
children: [
const SizedBox(width: 16),
iconButton(
size: 32,
tooltip: '取消',
context: context,
icon: Icons.clear,
onPressed: _favNoteController.onDisable,
),
const SizedBox(width: 12),
Obx(
() => Checkbox(
value: _favNoteController.allSelected.value,
onChanged: (value) {
_favNoteController.handleSelect(
!_favNoteController.allSelected.value);
},
),
),
GestureDetector(
onTap: () {
_favNoteController.handleSelect(
!_favNoteController.allSelected.value);
},
child: const Text('全选'),
),
const Spacer(),
FilledButton.tonal(
style: TextButton.styleFrom(
visualDensity:
VisualDensity(horizontal: -2, vertical: -2),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {
showConfirmDialog(
context: context,
title: '确定删除已选中的笔记吗?',
onConfirm: _favNoteController.onRemove,
);
},
child: const Text('删除'),
),
const SizedBox(width: 16),
],
),
),
),
),
),
],
),
);
@@ -61,11 +145,17 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.7,
childAspectRatio: StyleString.aspectRatio * 2.6,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
return FavNoteItem(item: loadingState.response[index]);
return FavNoteItem(
item: loadingState.response[index],
ctr: _favNoteController,
onSelect: () {
_favNoteController.onSelect(index);
},
);
},
childCount: loadingState.response.length,
),