|
|
|
|
@ -180,37 +180,51 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
|
|
|
|
|
|
|
|
|
|
/// 构建企业列表 |
|
|
|
|
Widget _buildEnterpriseList() { |
|
|
|
|
// 使用 Obx 包裹以监听 controller 中所有 Rx 变量的变化 |
|
|
|
|
return Obx(() { |
|
|
|
|
// 在列表为空且仍在加载时显示加载指示器 |
|
|
|
|
if (controller.isLoading.value) { |
|
|
|
|
return const Center(child: CircularProgressIndicator()); |
|
|
|
|
} |
|
|
|
|
// 在加载完成但列表为空时显示提示信息 |
|
|
|
|
if (controller.enterpriseList.isEmpty) { |
|
|
|
|
return Center( |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
// 使用下拉刷新包裹列表 |
|
|
|
|
return RefreshIndicator( |
|
|
|
|
onRefresh: () async => controller.loadAndSyncEnterprises(), |
|
|
|
|
child: Obx(() { |
|
|
|
|
// 3. 在加载中状态,直接显示加载动画(此时不可滚动是合理的) |
|
|
|
|
if (controller.isLoading.value && controller.enterpriseList.isEmpty) { |
|
|
|
|
return const Center(child: CircularProgressIndicator()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 4. 当列表为空时,将空状态提示也放入一个 ListView 中 |
|
|
|
|
if (controller.enterpriseList.isEmpty) { |
|
|
|
|
// 使用 ListView 包裹,并设置 AlwaysScrollableScrollPhysics |
|
|
|
|
return ListView( |
|
|
|
|
// [!!!] 关键:这行代码让 ListView 即使在内容不足一屏时也能滚动 |
|
|
|
|
physics: const AlwaysScrollableScrollPhysics(), |
|
|
|
|
children: [ |
|
|
|
|
Icon( |
|
|
|
|
Icons.folder_off_outlined, |
|
|
|
|
size: 60.sp, |
|
|
|
|
color: Colors.grey[400], |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 16.h), |
|
|
|
|
Text( |
|
|
|
|
'没有找到相关企业', |
|
|
|
|
style: TextStyle(fontSize: 16.sp, color: Colors.grey[600]), |
|
|
|
|
// 为了让空状态提示在屏幕中居中,我们需要计算一下它的高度 |
|
|
|
|
SizedBox( |
|
|
|
|
// 获取父容器(Expanded)的高度 |
|
|
|
|
height: Get.height * 0.5, // 可以根据实际情况调整这个高度 |
|
|
|
|
child: Center( |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Icon( |
|
|
|
|
Icons.folder_off_outlined, |
|
|
|
|
size: 60.sp, |
|
|
|
|
color: Colors.grey[400], |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 16.h), |
|
|
|
|
Text( |
|
|
|
|
'没有找到相关企业', |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
color: Colors.grey[600], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 使用下拉刷新包裹列表 |
|
|
|
|
return RefreshIndicator( |
|
|
|
|
onRefresh: () async => controller.loadAndSyncEnterprises(), |
|
|
|
|
child: ListView.builder( |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
return ListView.builder( |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), |
|
|
|
|
itemCount: controller.enterpriseList.length, |
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
@ -296,8 +310,9 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
|
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
); |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
// }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|