mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -22,8 +22,10 @@ class FavNoteChildPage extends StatefulWidget {
|
||||
|
||||
class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late final FavNoteController _favNoteController =
|
||||
Get.put(FavNoteController(widget.isPublish), tag: '${widget.isPublish}');
|
||||
late final FavNoteController _favNoteController = Get.put(
|
||||
FavNoteController(widget.isPublish),
|
||||
tag: '${widget.isPublish}',
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -41,9 +43,11 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80),
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: Obx(
|
||||
() => _buildBody(_favNoteController.loadingState.value)),
|
||||
() => _buildBody(_favNoteController.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -86,14 +90,16 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
value: _favNoteController.allSelected.value,
|
||||
onChanged: (value) {
|
||||
_favNoteController.handleSelect(
|
||||
!_favNoteController.allSelected.value);
|
||||
!_favNoteController.allSelected.value,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => _favNoteController.handleSelect(
|
||||
!_favNoteController.allSelected.value),
|
||||
!_favNoteController.allSelected.value,
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 14,
|
||||
@@ -135,37 +141,38 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
Widget _buildBody(LoadingState<List<FavNoteItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favNoteController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavNoteItem(
|
||||
item: item,
|
||||
ctr: _favNoteController,
|
||||
onSelect: () => _favNoteController.onSelect(item),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(onReload: _favNoteController.onReload),
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favNoteController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavNoteItem(
|
||||
item: item,
|
||||
ctr: _favNoteController,
|
||||
onSelect: () => _favNoteController.onSelect(item),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(onReload: _favNoteController.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _favNoteController.onReload,
|
||||
),
|
||||
errMsg: errMsg,
|
||||
onReload: _favNoteController.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,9 @@ class FavNoteController
|
||||
|
||||
Future<void> onRemove() async {
|
||||
List<FavNoteItemModel> dataList = loadingState.value.data!;
|
||||
Set<FavNoteItemModel> removeList =
|
||||
dataList.where((item) => item.checked == true).toSet();
|
||||
Set<FavNoteItemModel> removeList = dataList
|
||||
.where((item) => item.checked == true)
|
||||
.toSet();
|
||||
final res = await FavHttp.delNote(
|
||||
isPublish: isPublish,
|
||||
noteIds: removeList
|
||||
@@ -45,8 +46,10 @@ class FavNoteController
|
||||
.toList(),
|
||||
);
|
||||
if (res['status']) {
|
||||
List<FavNoteItemModel> remainList =
|
||||
dataList.toSet().difference(removeList).toList();
|
||||
List<FavNoteItemModel> remainList = dataList
|
||||
.toSet()
|
||||
.difference(removeList)
|
||||
.toList();
|
||||
loadingState.value = Success(remainList);
|
||||
enableMultiSelect.value = false;
|
||||
SmartDialog.showToast('删除成功');
|
||||
|
||||
@@ -13,8 +13,10 @@ class FavNotePage extends StatefulWidget {
|
||||
|
||||
class _FavNotePageState extends State<FavNotePage>
|
||||
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||
late final TabController _tabController =
|
||||
TabController(length: 2, vsync: this);
|
||||
late final TabController _tabController = TabController(
|
||||
length: 2,
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
@@ -44,16 +46,19 @@ class _FavNotePageState extends State<FavNotePage>
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
dividerHeight: 0,
|
||||
indicatorWeight: 0,
|
||||
indicatorPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
|
||||
indicatorPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 3,
|
||||
vertical: 8,
|
||||
),
|
||||
indicator: BoxDecoration(
|
||||
color: theme.colorScheme.secondaryContainer,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
labelStyle: TabBarTheme.of(context)
|
||||
.labelStyle
|
||||
?.copyWith(fontSize: 14) ??
|
||||
labelStyle:
|
||||
TabBarTheme.of(
|
||||
context,
|
||||
).labelStyle?.copyWith(fontSize: 14) ??
|
||||
const TextStyle(fontSize: 14),
|
||||
labelColor: theme.colorScheme.onSecondaryContainer,
|
||||
unselectedLabelColor: theme.colorScheme.outline,
|
||||
@@ -65,9 +70,8 @@ class _FavNotePageState extends State<FavNotePage>
|
||||
try {
|
||||
if (!_tabController.indexIsChanging) {
|
||||
Get.find<FavNoteController>(
|
||||
tag: index == 0 ? 'false' : 'true')
|
||||
.scrollController
|
||||
.animToTop();
|
||||
tag: index == 0 ? 'false' : 'true',
|
||||
).scrollController.animToTop();
|
||||
}
|
||||
} catch (_) {}
|
||||
},
|
||||
|
||||
@@ -66,40 +66,45 @@ class FavNoteItem extends StatelessWidget {
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
AnimatedOpacity(
|
||||
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 *
|
||||
width:
|
||||
constraints.maxHeight *
|
||||
StyleString.aspectRatio,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color:
|
||||
Colors.black.withValues(alpha: 0.6),
|
||||
color: Colors.black.withValues(
|
||||
alpha: 0.6,
|
||||
),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 34,
|
||||
height: 34,
|
||||
child: AnimatedScale(
|
||||
scale: item.checked == true ? 1 : 0,
|
||||
duration:
|
||||
const Duration(milliseconds: 250),
|
||||
duration: const Duration(
|
||||
milliseconds: 250,
|
||||
),
|
||||
curve: Curves.easeInOut,
|
||||
child: IconButton(
|
||||
tooltip: '取消选择',
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStateProperty.all(
|
||||
EdgeInsets.zero),
|
||||
EdgeInsets.zero,
|
||||
),
|
||||
backgroundColor:
|
||||
WidgetStateProperty.resolveWith(
|
||||
(states) {
|
||||
return theme.colorScheme.surface
|
||||
.withValues(alpha: 0.8);
|
||||
},
|
||||
),
|
||||
(states) {
|
||||
return theme
|
||||
.colorScheme
|
||||
.surface
|
||||
.withValues(alpha: 0.8);
|
||||
},
|
||||
),
|
||||
),
|
||||
onPressed: null,
|
||||
icon: Icon(
|
||||
|
||||
Reference in New Issue
Block a user