Browse Source

fix : 没有企业、问题时无法下拉刷新

dev
徐振升 2 months ago
parent
commit
a25bf1ef1b
  1. 77
      lib/app/features/enterprise/presentation/pages/enterprise_list_page.dart
  2. 76
      lib/app/features/problem/presentation/pages/problem_list_page.dart

77
lib/app/features/enterprise/presentation/pages/enterprise_list_page.dart

@ -180,37 +180,51 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
/// ///
Widget _buildEnterpriseList() { Widget _buildEnterpriseList() {
// 使 Obx controller Rx // 使
return Obx(() { return RefreshIndicator(
// onRefresh: () async => controller.loadAndSyncEnterprises(),
if (controller.isLoading.value) { child: Obx(() {
return const Center(child: CircularProgressIndicator()); // 3.
} if (controller.isLoading.value && controller.enterpriseList.isEmpty) {
// return const Center(child: CircularProgressIndicator());
if (controller.enterpriseList.isEmpty) { }
return Center(
child: Column( // 4. ListView
mainAxisAlignment: MainAxisAlignment.center, if (controller.enterpriseList.isEmpty) {
// 使 ListView AlwaysScrollableScrollPhysics
return ListView(
// [!!!] ListView 使
physics: const AlwaysScrollableScrollPhysics(),
children: [ children: [
Icon( //
Icons.folder_off_outlined, SizedBox(
size: 60.sp, // Expanded
color: Colors.grey[400], height: Get.height * 0.5, //
), child: Center(
SizedBox(height: 16.h), child: Column(
Text( mainAxisAlignment: MainAxisAlignment.center,
'没有找到相关企业', children: [
style: TextStyle(fontSize: 16.sp, color: Colors.grey[600]), 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 ListView.builder(
// 使
return RefreshIndicator(
onRefresh: () async => controller.loadAndSyncEnterprises(),
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
itemCount: controller.enterpriseList.length, itemCount: controller.enterpriseList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -296,8 +310,9 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
), ),
); );
}, },
), );
); }),
}); );
// });
} }
} }

76
lib/app/features/problem/presentation/pages/problem_list_page.dart

@ -273,37 +273,52 @@ class ProblemListPage extends GetView<ProblemListController> {
/// ///
Widget _buildEnterpriseList() { Widget _buildEnterpriseList() {
// 使 Obx controller Rx // 使
return Obx(() { return RefreshIndicator(
// onRefresh: () async => controller.loadAndSyncProblems(),
if (controller.isLoading.value) { child: Obx(() {
return const Center(child: CircularProgressIndicator()); // 3.
} if (controller.isLoading.value && controller.enterpriseList.isEmpty) {
// return const Center(child: CircularProgressIndicator());
if (controller.problemList.isEmpty) { }
return Center(
child: Column( // 4. ListView
mainAxisAlignment: MainAxisAlignment.center, if (controller.enterpriseList.isEmpty) {
// 使 ListView AlwaysScrollableScrollPhysics
return ListView(
// [!!!] ListView 使
physics: const AlwaysScrollableScrollPhysics(),
children: [ children: [
Icon( //
Icons.folder_off_outlined, SizedBox(
size: 60.sp, // Expanded
color: Colors.grey[400], height: Get.height * 0.5, //
), child: Center(
SizedBox(height: 16.h), child: Column(
Text( mainAxisAlignment: MainAxisAlignment.center,
'没有找到相关问题', children: [
style: TextStyle(fontSize: 16.sp, color: Colors.grey[600]), 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 ListView.builder(
return RefreshIndicator(
onRefresh: () async => controller.loadAndSyncProblems(),
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
itemCount: controller.problemList.length, itemCount: controller.problemList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -388,8 +403,9 @@ class ProblemListPage extends GetView<ProblemListController> {
), ),
); );
}, },
), );
); }),
}); );
// });
} }
} }

Loading…
Cancel
Save