opt fan item

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-22 10:32:23 +08:00
parent d4a1568b28
commit c7437225eb

View File

@@ -51,6 +51,7 @@ class _FansPageState extends State<FansPage> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context).colorScheme;
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: widget.mid != null
@@ -64,7 +65,7 @@ class _FansPageState extends State<FansPage> {
slivers: [
ViewSliverSafeArea(
sliver: Obx(
() => _buildBody(_fansController.loadingState.value),
() => _buildBody(theme, _fansController.loadingState.value),
),
),
],
@@ -78,7 +79,10 @@ class _FansPageState extends State<FansPage> {
mainAxisExtent: 66,
);
Widget _buildBody(LoadingState<List<FansItemModel>?> loadingState) {
Widget _buildBody(
ColorScheme theme,
LoadingState<List<FansItemModel>?> loadingState,
) {
return switch (loadingState) {
Loading() => SliverGrid.builder(
gridDelegate: gridDelegate,
@@ -93,7 +97,19 @@ class _FansPageState extends State<FansPage> {
if (index == response.length - 1) {
_fansController.onLoadMore();
}
final item = response[index];
return _buildItem(theme, index, response[index]);
},
itemCount: response!.length,
)
: HttpError(onReload: _fansController.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _fansController.onReload,
),
};
}
Widget _buildItem(ColorScheme theme, int index, FansItemModel item) {
return SizedBox(
height: 66,
child: InkWell(
@@ -116,8 +132,7 @@ class _FansPageState extends State<FansPage> {
? () => showConfirmDialog(
context: context,
title: '确定移除 ${item.uname} ',
onConfirm: () =>
_fansController.onRemoveFan(index, item.mid!),
onConfirm: () => _fansController.onRemoveFan(index, item.mid!),
)
: null,
child: Padding(
@@ -136,7 +151,8 @@ class _FansPageState extends State<FansPage> {
src: item.face,
),
Column(
spacing: 5,
spacing: 4,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.uname!,
@@ -146,6 +162,7 @@ class _FansPageState extends State<FansPage> {
item.sign ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: theme.outline),
),
],
),
@@ -154,14 +171,5 @@ class _FansPageState extends State<FansPage> {
),
),
);
},
itemCount: response!.length,
)
: HttpError(onReload: _fansController.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _fansController.onReload,
),
};
}
}