|
|
|
@ -95,44 +95,46 @@ class _RecommendTabState extends State<RecommendTab> |
|
|
|
child: ListView.separated( |
|
|
|
// 关键:始终允许滚动,即使内容不足 |
|
|
|
// 移除顶部 padding,让刷新指示器可以正确显示在 AppBar 下方 |
|
|
|
padding: EdgeInsets.only(left: 12, right: 12, bottom: 12), |
|
|
|
itemBuilder: (context, index) { |
|
|
|
padding: EdgeInsets.only(left: 12, right: 12, bottom: 12), |
|
|
|
itemBuilder: (context, index) { |
|
|
|
// 空数据状态 |
|
|
|
if (controller.recommendFeed.isEmpty && index == 0) { |
|
|
|
if (controller.recommendFeed.isEmpty && index == 0) { |
|
|
|
// 使用足够的高度确保可以滚动 |
|
|
|
if (controller.recommendIsLoading.value) { |
|
|
|
return SizedBox( |
|
|
|
height: MediaQuery.of(context).size.height - totalBottomPadding, |
|
|
|
child: Center( |
|
|
|
child: Column( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
CircularProgressIndicator(), |
|
|
|
SizedBox(height: 16), |
|
|
|
Text('加载数据中...'), |
|
|
|
], |
|
|
|
if (controller.recommendIsLoading.value) { |
|
|
|
return SizedBox( |
|
|
|
height: MediaQuery.of(context).size.height - totalBottomPadding, |
|
|
|
child: Center( |
|
|
|
child: Column( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
CircularProgressIndicator(), |
|
|
|
SizedBox(height: 16), |
|
|
|
Text('加载数据中...'), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} else { |
|
|
|
return SizedBox( |
|
|
|
height: MediaQuery.of(context).size.height - totalBottomPadding, |
|
|
|
child: const Center( |
|
|
|
child: Text( |
|
|
|
"暂无数据", |
|
|
|
style: TextStyle(fontSize: 14, color: Color(0xFF999999)), |
|
|
|
); |
|
|
|
} else { |
|
|
|
return SizedBox( |
|
|
|
height: MediaQuery.of(context).size.height - totalBottomPadding, |
|
|
|
child: const Center( |
|
|
|
child: Text( |
|
|
|
"暂无数据", |
|
|
|
style: TextStyle(fontSize: 14, color: Color(0xFF999999)), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 数据项 |
|
|
|
final item = controller.recommendFeed[index]; |
|
|
|
return ContentCard(item: item); |
|
|
|
}, |
|
|
|
separatorBuilder: (context, index) { |
|
|
|
// 数据项 |
|
|
|
final item = controller.recommendFeed[index]; |
|
|
|
return ContentCard(item: item); |
|
|
|
}, |
|
|
|
separatorBuilder: (context, index) { |
|
|
|
// 空状态或加载状态时不显示分隔符 |
|
|
|
if (controller.recommendFeed.isEmpty) return const SizedBox.shrink(); |
|
|
|
if (controller.recommendFeed.isEmpty) { |
|
|
|
return const SizedBox.shrink(); |
|
|
|
} |
|
|
|
return const SizedBox(height: 12); |
|
|
|
}, |
|
|
|
// 至少显示一个 item(用于显示加载或空状态) |
|
|
|
|