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() {
// 使 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> {
),
);
},
),
);
});
);
}),
);
// });
}
}

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

@ -273,37 +273,52 @@ class ProblemListPage extends GetView<ProblemListController> {
///
Widget _buildEnterpriseList() {
// 使 Obx controller Rx
return Obx(() {
//
if (controller.isLoading.value) {
return const Center(child: CircularProgressIndicator());
}
//
if (controller.problemList.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
// 使
return RefreshIndicator(
onRefresh: () async => controller.loadAndSyncProblems(),
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.loadAndSyncProblems(),
child: ListView.builder(
return ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
itemCount: controller.problemList.length,
itemBuilder: (context, index) {
@ -388,8 +403,9 @@ class ProblemListPage extends GetView<ProblemListController> {
),
);
},
),
);
});
);
}),
);
// });
}
}

Loading…
Cancel
Save