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

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