Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-23 16:47:11 +08:00
parent 148e0872b4
commit 418a1e8d39
821 changed files with 29467 additions and 25520 deletions

View File

@@ -20,8 +20,9 @@ class FavArticlePage extends StatefulWidget {
class _FavArticlePageState extends State<FavArticlePage>
with AutomaticKeepAliveClientMixin {
final FavArticleController _favArticleController =
Get.put(FavArticleController());
final FavArticleController _favArticleController = Get.put(
FavArticleController(),
);
@override
bool get wantKeepAlive => true;
@@ -40,8 +41,9 @@ class _FavArticlePageState extends State<FavArticlePage>
top: StyleString.safeSpace - 5,
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
sliver:
Obx(() => _buildBody(_favArticleController.loadingState.value)),
sliver: Obx(
() => _buildBody(_favArticleController.loadingState.value),
),
),
],
),
@@ -51,41 +53,42 @@ class _FavArticlePageState extends State<FavArticlePage>
Widget _buildBody(LoadingState<List<FavArticleItemModel>?> 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) {
_favArticleController.onLoadMore();
}
final item = response[index];
return FavArticleItem(
item: item,
onDelete: () => showConfirmDialog(
context: context,
title: '确定取消收藏?',
onConfirm: () =>
_favArticleController.onRemove(index, item.opusId),
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _favArticleController.onReload),
),
Success(:var response) =>
response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_favArticleController.onLoadMore();
}
final item = response[index];
return FavArticleItem(
item: item,
onDelete: () => showConfirmDialog(
context: context,
title: '确定取消收藏?',
onConfirm: () =>
_favArticleController.onRemove(index, item.opusId),
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _favArticleController.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _favArticleController.onReload,
),
errMsg: errMsg,
onReload: _favArticleController.onReload,
),
};
}
}

View File

@@ -45,14 +45,17 @@ class FavArticleItem extends StatelessWidget {
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints boxConstraints) {
return NetworkImgLayer(
src: item.cover!.url,
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
);
},
builder:
(
BuildContext context,
BoxConstraints boxConstraints,
) {
return NetworkImgLayer(
src: item.cover!.url,
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
);
},
),
),
const SizedBox(width: 10),

View File

@@ -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,
),
};
}

View File

@@ -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('删除成功');

View File

@@ -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 (_) {}
},

View File

@@ -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(

View File

@@ -48,9 +48,11 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80),
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
sliver: Obx(
() => _buildBody(_favPgcController.loadingState.value)),
() => _buildBody(_favPgcController.loadingState.value),
),
),
],
),
@@ -93,14 +95,16 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
value: _favPgcController.allSelected.value,
onChanged: (value) {
_favPgcController.handleSelect(
!_favPgcController.allSelected.value);
!_favPgcController.allSelected.value,
);
},
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _favPgcController
.handleSelect(!_favPgcController.allSelected.value),
onTap: () => _favPgcController.handleSelect(
!_favPgcController.allSelected.value,
),
child: const Padding(
padding: EdgeInsets.only(
top: 14,
@@ -112,12 +116,13 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
),
const Spacer(),
...const [
(followStatus: 1, title: '想看'),
(followStatus: 2, title: '在看'),
(followStatus: 3, title: '看过'),
]
.where((item) =>
item.followStatus != widget.followStatus)
(followStatus: 1, title: '想看'),
(followStatus: 2, title: '在看'),
(followStatus: 3, title: '看过'),
]
.where(
(item) => item.followStatus != widget.followStatus,
)
.map(
(item) => Padding(
padding: const EdgeInsets.only(left: 25),
@@ -126,13 +131,16 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
onTap: () {
if (_favPgcController.checkedCount.value !=
0) {
_favPgcController
.onUpdateList(item.followStatus);
_favPgcController.onUpdateList(
item.followStatus,
);
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 14, horizontal: 5),
vertical: 14,
horizontal: 5,
),
child: Text(
'标记为${item.title}',
style: TextStyle(
@@ -158,56 +166,57 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
Widget _buildBody(LoadingState<List<FavPgcItemModel>?> loadingState) {
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const FavPgcItemSkeleton();
},
childCount: 10,
),
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const FavPgcItemSkeleton();
},
childCount: 10,
),
Success(:var response) => response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_favPgcController.onLoadMore();
}
final item = response[index];
return FavPgcItem(
item: item,
ctr: _favPgcController,
onSelect: () => _favPgcController.onSelect(item),
onUpdateStatus: () => showPgcFollowDialog(
context: context,
type: widget.type == 0 ? '追番' : '追剧',
followStatus: widget.followStatus,
onUpdateStatus: (followStatus) {
if (followStatus == -1) {
_favPgcController.pgcDel(
index,
item.seasonId,
);
} else {
_favPgcController.onUpdate(
index,
followStatus,
item.seasonId,
);
}
},
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _favPgcController.onReload),
),
Success(:var response) =>
response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_favPgcController.onLoadMore();
}
final item = response[index];
return FavPgcItem(
item: item,
ctr: _favPgcController,
onSelect: () => _favPgcController.onSelect(item),
onUpdateStatus: () => showPgcFollowDialog(
context: context,
type: widget.type == 0 ? '追番' : '追剧',
followStatus: widget.followStatus,
onUpdateStatus: (followStatus) {
if (followStatus == -1) {
_favPgcController.pgcDel(
index,
item.seasonId,
);
} else {
_favPgcController.onUpdate(
index,
followStatus,
item.seasonId,
);
}
},
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _favPgcController.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _favPgcController.onReload,
),
errMsg: errMsg,
onReload: _favPgcController.onReload,
),
};
}

View File

@@ -41,11 +41,11 @@ class FavPgcController
@override
Future<LoadingState<FavPgcData>> customGetData() => FavHttp.favPgc(
mid: Accounts.main.mid,
type: type,
followStatus: followStatus,
pn: page,
);
mid: Accounts.main.mid,
type: type,
followStatus: followStatus,
pn: page,
);
void onDisable() {
if (checkedCount.value != 0) {
@@ -67,24 +67,28 @@ class FavPgcController
Future<void> onUpdateList(int followStatus) async {
List<FavPgcItemModel> dataList = loadingState.value.data!;
Set<FavPgcItemModel> updateList =
dataList.where((item) => item.checked == true).toSet();
Set<FavPgcItemModel> updateList = dataList
.where((item) => item.checked == true)
.toSet();
final res = await VideoHttp.pgcUpdate(
seasonId: updateList.map((item) => item.seasonId).toList(),
status: followStatus,
);
if (res['status']) {
List<FavPgcItemModel> remainList =
dataList.toSet().difference(updateList).toList();
List<FavPgcItemModel> remainList = dataList
.toSet()
.difference(updateList)
.toList();
loadingState.value = Success(remainList);
enableMultiSelect.value = false;
try {
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
if (ctr.loadingState.value.isSuccess) {
ctr.loadingState
..value
.data!
.insertAll(0, updateList.map((item) => item..checked = null))
..value.data!.insertAll(
0,
updateList.map((item) => item..checked = null),
)
..refresh();
ctr.allSelected.value = false;
}

View File

@@ -15,8 +15,11 @@ class FavPgcPage extends StatefulWidget {
class _FavPgcPageState extends State<FavPgcPage>
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
late final TabController _tabController =
TabController(length: 3, vsync: this, initialIndex: 1);
late final TabController _tabController = TabController(
length: 3,
vsync: this,
initialIndex: 1,
);
@override
bool get wantKeepAlive => true;
@@ -46,16 +49,19 @@ class _FavPgcPageState extends State<FavPgcPage>
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,

View File

@@ -55,8 +55,7 @@ class FavPgcItem extends StatelessWidget {
AspectRatio(
aspectRatio: 3 / 4,
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints boxConstraints) {
builder: (BuildContext context, BoxConstraints boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
@@ -82,52 +81,66 @@ class FavPgcItem extends StatelessWidget {
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: const BorderRadius.all(
Radius.circular(4)),
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),
curve: Curves.easeInOut,
child: IconButton(
tooltip: '取消选择',
style: ButtonStyle(
padding: WidgetStateProperty.all(
EdgeInsets.zero),
backgroundColor:
WidgetStateProperty
.resolveWith(
(states) {
return theme
.colorScheme.surface
.withValues(alpha: 0.8);
},
),
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:
const BorderRadius.all(
Radius.circular(4),
),
color: Colors.black.withValues(
alpha: 0.6,
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color: theme.colorScheme.primary,
),
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
.colorScheme
.surface
.withValues(
alpha: 0.8,
);
},
),
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color:
theme.colorScheme.primary,
),
),
),
),
),
),
),
),
),
),
),
@@ -155,7 +168,8 @@ class FavPgcItem extends StatelessWidget {
],
if (item.progress != null) ...[
SizedBox(
height: item.newEp?.indexShow != null ? 2 : 6),
height: item.newEp?.indexShow != null ? 2 : 6,
),
Text(
item.progress!,
style: TextStyle(

View File

@@ -40,8 +40,9 @@ class _FavTopicPageState extends State<FavTopicPage>
top: StyleString.safeSpace,
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
sliver:
Obx(() => _buildBody(theme, _controller.loadingState.value)),
sliver: Obx(
() => _buildBody(theme, _controller.loadingState.value),
),
),
],
),
@@ -49,74 +50,81 @@ class _FavTopicPageState extends State<FavTopicPage>
}
Widget _buildBody(
ThemeData theme, LoadingState<List<FavTopicItem>?> loadingState) {
ThemeData theme,
LoadingState<List<FavTopicItem>?> loadingState,
) {
return switch (loadingState) {
Loading() => const SliverToBoxAdapter(
child: SizedBox(
height: 125,
child: Center(
child: CircularProgressIndicator(),
),
child: SizedBox(
height: 125,
child: Center(
child: CircularProgressIndicator(),
),
),
Success(:var response) => response?.isNotEmpty == true
? SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 12,
crossAxisSpacing: 12,
maxCrossAxisExtent: Grid.smallCardWidth,
mainAxisExtent: MediaQuery.textScalerOf(context).scale(30),
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_controller.onLoadMore();
}
final item = response[index];
return Material(
color: theme.colorScheme.onInverseSurface,
borderRadius: const BorderRadius.all(Radius.circular(6)),
child: InkWell(
onTap: () => Get.toNamed(
'/dynTopic',
parameters: {
'id': item.id!.toString(),
'name': item.name!,
},
),
onLongPress: () => showConfirmDialog(
context: context,
title: '确定取消收藏?',
onConfirm: () {
_controller.onRemove(index, item.id);
},
),
),
Success(:var response) =>
response?.isNotEmpty == true
? SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 12,
crossAxisSpacing: 12,
maxCrossAxisExtent: Grid.smallCardWidth,
mainAxisExtent: MediaQuery.textScalerOf(context).scale(30),
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_controller.onLoadMore();
}
final item = response[index];
return Material(
color: theme.colorScheme.onInverseSurface,
borderRadius: const BorderRadius.all(Radius.circular(6)),
child: Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(
horizontal: 11, vertical: 5),
child: Text(
'# ${item.name}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
color: theme.colorScheme.onSurfaceVariant,
child: InkWell(
onTap: () => Get.toNamed(
'/dynTopic',
parameters: {
'id': item.id!.toString(),
'name': item.name!,
},
),
onLongPress: () => showConfirmDialog(
context: context,
title: '确定取消收藏?',
onConfirm: () {
_controller.onRemove(index, item.id);
},
),
borderRadius: const BorderRadius.all(
Radius.circular(6),
),
child: Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(
horizontal: 11,
vertical: 5,
),
child: Text(
'# ${item.name}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
color: theme.colorScheme.onSurfaceVariant,
),
),
),
),
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _controller.onReload),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _controller.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _controller.onReload,
),
errMsg: errMsg,
onReload: _controller.onReload,
),
};
}
}

View File

@@ -34,8 +34,8 @@ class FavController extends CommonListController<FavFolderData, FavFolderInfo> {
@override
Future<LoadingState<FavFolderData>> customGetData() => FavHttp.userfavFolder(
pn: page,
ps: 20,
mid: accountService.mid,
);
pn: page,
ps: 20,
mid: accountService.mid,
);
}

View File

@@ -51,54 +51,55 @@ class _FavVideoPageState extends State<FavVideoPage>
Widget _buildBody(LoadingState<List<FavFolderInfo>?> loadingState) {
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return const VideoCardHSkeleton();
},
childCount: 10,
),
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return const VideoCardHSkeleton();
},
childCount: 10,
),
Success(:var response) => response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
childCount: response!.length,
(BuildContext context, int index) {
if (index == response.length - 1) {
_favController.onLoadMore();
}
final item = response[index];
String heroTag = Utils.makeHeroTag(item.fid);
return FavVideoItem(
heroTag: heroTag,
item: item,
onTap: () async {
var res = await Get.toNamed(
'/favDetail',
arguments: item,
parameters: {
'heroTag': heroTag,
'mediaId': item.id.toString(),
},
);
if (res == true) {
_favController.loadingState
..value.data!.removeAt(index)
..refresh();
}
},
);
},
),
Success(:var response) =>
response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
childCount: response!.length,
(BuildContext context, int index) {
if (index == response.length - 1) {
_favController.onLoadMore();
}
final item = response[index];
String heroTag = Utils.makeHeroTag(item.fid);
return FavVideoItem(
heroTag: heroTag,
item: item,
onTap: () async {
var res = await Get.toNamed(
'/favDetail',
arguments: item,
parameters: {
'heroTag': heroTag,
'mediaId': item.id.toString(),
},
);
if (res == true) {
_favController.loadingState
..value.data!.removeAt(index)
..refresh();
}
},
);
},
),
)
: HttpError(
onReload: _favController.onReload,
),
)
: HttpError(
onReload: _favController.onReload,
),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _favController.onReload,
),
errMsg: errMsg,
onReload: _favController.onReload,
),
};
}
}

View File

@@ -25,13 +25,14 @@ class FavVideoItem extends StatelessWidget {
type: MaterialType.transparency,
child: InkWell(
onTap: onTap,
onLongPress: onLongPress ??
onLongPress:
onLongPress ??
(onTap == null
? null
: () => imageSaveDialog(
title: item.title,
cover: item.cover,
)),
title: item.title,
cover: item.cover,
)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
child: Row(

View File

@@ -62,8 +62,8 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
if (data != null) {
List<FavFolderInfo>? list =
_favController.loadingState.value.isSuccess
? _favController.loadingState.value.data
: null;
? _favController.loadingState.value.data
: null;
if (list?.isNotEmpty == true) {
list!.insert(1, data);
_favController.loadingState.refresh();
@@ -88,7 +88,8 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
return;
}
Get.to(
FavFolderSortPage(favController: _favController));
FavFolderSortPage(favController: _favController),
);
}
},
icon: const Icon(Icons.sort),
@@ -136,8 +137,7 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
case FavTabType.video:
_favController.scrollController.animToTop();
case FavTabType.article:
Get.find<FavArticleController>()
.scrollController
Get.find<FavArticleController>().scrollController
.animToTop();
case FavTabType.topic:
Get.find<FavTopicController>().scrollController.animToTop();